fix: Check for new heads.

This commit is contained in:
Hayden Young 2023-03-07 20:35:46 +00:00
parent 8fc5b77c51
commit 4a5c59449b
2 changed files with 9 additions and 1 deletions

View File

@ -25,6 +25,8 @@ const Heads = async ({ storage, heads }) => {
}
const newHeads = findHeads([...currentHeads, head])
await set(newHeads)
return newHeads
}
const iterator = async function * () {

View File

@ -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