Skip to content

Commit

Permalink
feat: wip crdt del
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed Jan 24, 2024
1 parent 586fd06 commit 308d4d7
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/crdt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,25 @@ export const put = async (blocks, head, key, value) => {
* @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

0 comments on commit 308d4d7

Please # to comment.