diff --git a/src/oplog/heads.js b/src/oplog/heads.js index 353ae51..f9cb23e 100644 --- a/src/oplog/heads.js +++ b/src/oplog/heads.js @@ -25,6 +25,8 @@ const Heads = async ({ storage, heads }) => { } const newHeads = findHeads([...currentHeads, head]) await set(newHeads) + + return newHeads } const iterator = async function * () { diff --git a/src/oplog/log.js b/src/oplog/log.js index 354140b..a8351a2 100644 --- a/src/oplog/log.js +++ b/src/oplog/log.js @@ -222,8 +222,14 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora if (!isValid) { throw new Error(`Could not validate signature for entry "${entry.hash}"`) } + // Add the new entry to heads (union with current heads) - await _heads.add(entry) + const newHeads = await _heads.add(entry) + + if (!newHeads) { + return false + } + // Add the new entry to the entry storage await _entries.put(entry.hash, entry.bytes) // Add the new entry to the entry index