Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: crdt delete #31

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/crdt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,28 @@
* @param {API.EventLink<API.Operation>[]} head Merkle clock head.
* @param {string} key The key of the value to delete.
* @param {object} [options]
* @returns {Promise<API.Result>}

Check failure on line 128 in src/crdt/index.js

View workflow job for this annotation

GitHub Actions / Test (18, ubuntu-latest)

Function lacks ending return statement and return type does not include 'undefined'.

Check failure on line 128 in src/crdt/index.js

View workflow job for this annotation

GitHub Actions / Test (20, ubuntu-latest)

Function lacks ending return statement and return type does not include 'undefined'.
*/
export const del = async (blocks, head, key, options) => {
throw new Error('not implemented')
const mblocks = new MemoryBlockstore()
blocks = new MultiBlockFetcher(mblocks, blocks)

if (!head.length) {
const shard = await ShardBlock.create()
mblocks.putSync(shard.cid, shard.bytes)
const result = await Pail.put(blocks, shard.cid, key, value)

Check failure on line 137 in src/crdt/index.js

View workflow job for this annotation

GitHub Actions / Test (18, ubuntu-latest)

Cannot find name 'value'.

Check failure on line 137 in src/crdt/index.js

View workflow job for this annotation

GitHub Actions / Test (20, ubuntu-latest)

Cannot find name 'value'.
/** @type {API.Operation} */
const data = { type: 'put', root: result.root, key, value }

Check failure on line 139 in src/crdt/index.js

View workflow job for this annotation

GitHub Actions / Test (18, ubuntu-latest)

No value exists in scope for the shorthand property 'value'. Either declare one or provide an initializer.

Check failure on line 139 in src/crdt/index.js

View workflow job for this annotation

GitHub Actions / Test (20, ubuntu-latest)

No value exists in scope for the shorthand property 'value'. Either declare one or provide an initializer.
const event = await EventBlock.create(data, head)
head = await Clock.advance(blocks, head, event.cid)
return {
root: result.root,
additions: [shard, ...result.additions],
removals: result.removals,
head,
event
}
}
}

/**
Expand Down
Loading