Skip to content
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 @@ -128,7 +128,25 @@ export const put = async (blocks, head, key, value) => {
* @returns {Promise<API.Result>}
*/
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)
/** @type {API.Operation} */
const data = { type: 'put', root: result.root, key, value }
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