mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
fix: Pin when adding verified entries.
This commit is contained in:
parent
7110da6e2d
commit
e144bf760c
@ -299,11 +299,10 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora
|
|||||||
await traverseAndVerify()
|
await traverseAndVerify()
|
||||||
|
|
||||||
/* 4. Add missing entries to the index (=to the log) */
|
/* 4. Add missing entries to the index (=to the log) */
|
||||||
|
/* 5. Add new entry to entries (for pinning) */
|
||||||
await index.addVerified(hashesToAdd.values())
|
await index.addVerified(hashesToAdd.values())
|
||||||
/* 5. Remove heads which new entries are connect to */
|
/* 6. Remove heads which new entries are connect to */
|
||||||
await index.removeHeads(connectedHeads.values())
|
await index.removeHeads(connectedHeads.values())
|
||||||
/* 6. Add new entry to entries (for pinning) */
|
|
||||||
await index.pinEntry(entry)
|
|
||||||
/* 7. Add the new entry to heads (=union with current heads) */
|
/* 7. Add the new entry to heads (=union with current heads) */
|
||||||
await index.addHead(entry)
|
await index.addHead(entry)
|
||||||
|
|
||||||
|
|||||||
@ -58,13 +58,6 @@ 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) => {
|
||||||
/* 7. 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)
|
||||||
@ -82,6 +75,9 @@ const OplogIndex = async ({ logHeads, entryStorage, headsStorage, indexStorage,
|
|||||||
/* 4. Add missing entries to the index (=to the log) */
|
/* 4. Add missing entries to the index (=to the log) */
|
||||||
for (const hash of hashes) {
|
for (const hash of hashes) {
|
||||||
await _index.put(hash, true)
|
await _index.put(hash, true)
|
||||||
|
const bytes = await getBytes(hash)
|
||||||
|
/* 5. Add new entry to entries (for pinning) */
|
||||||
|
await _entries.put(hash, bytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +100,6 @@ 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