fix: Add the encrypted entry to entries to ensure the entry is pinned.

This commit is contained in:
Hayden Young 2025-02-22 16:09:09 +01:00
parent 5f54993660
commit 7110da6e2d
2 changed files with 12 additions and 2 deletions

View File

@ -302,7 +302,9 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora
await index.addVerified(hashesToAdd.values())
/* 5. Remove heads which new entries are connect to */
await index.removeHeads(connectedHeads.values())
/* 6. Add the new entry to heads (=union with current heads) */
/* 6. Add new entry to entries (for pinning) */
await index.pinEntry(entry)
/* 7. Add the new entry to heads (=union with current heads) */
await index.addHead(entry)
return true

View File

@ -58,8 +58,15 @@ const OplogIndex = async ({ logHeads, entryStorage, headsStorage, indexStorage,
return hash
}
const pinEntry = async (entry) => {
/* 6. Add new entry to entries (for pinning) */
const { hash, bytes } = await Entry.encode(entry, encryptEntryFn, encryptPayloadFn)
await _entries.put(hash, bytes)
}
const addHead = async (entry) => {
/* 6. Add the new entry to heads (=union with current heads) */
/* 7. Add the new entry to heads (=union with current heads) */
await _heads.add(entry)
return entry.hash
}
@ -97,6 +104,7 @@ const OplogIndex = async ({ logHeads, entryStorage, headsStorage, indexStorage,
heads,
setHead,
addHead,
pinEntry,
removeHeads,
addVerified,
storage: _entries,