mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
fix: Add the encrypted entry to entries to ensure the entry is pinned.
This commit is contained in:
parent
5f54993660
commit
7110da6e2d
@ -302,7 +302,9 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora
|
|||||||
await index.addVerified(hashesToAdd.values())
|
await index.addVerified(hashesToAdd.values())
|
||||||
/* 5. Remove heads which new entries are connect to */
|
/* 5. Remove heads which new entries are connect to */
|
||||||
await index.removeHeads(connectedHeads.values())
|
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)
|
await index.addHead(entry)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@ -58,8 +58,15 @@ const OplogIndex = async ({ logHeads, entryStorage, headsStorage, indexStorage,
|
|||||||
return hash
|
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) => {
|
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)
|
await _heads.add(entry)
|
||||||
return entry.hash
|
return entry.hash
|
||||||
}
|
}
|
||||||
@ -97,6 +104,7 @@ const OplogIndex = async ({ logHeads, entryStorage, headsStorage, indexStorage,
|
|||||||
heads,
|
heads,
|
||||||
setHead,
|
setHead,
|
||||||
addHead,
|
addHead,
|
||||||
|
pinEntry,
|
||||||
removeHeads,
|
removeHeads,
|
||||||
addVerified,
|
addVerified,
|
||||||
storage: _entries,
|
storage: _entries,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user