mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
fix: Put entry and index before setting heads to avoid retrieving a head not in the database.
This commit is contained in:
parent
dc150b9cc2
commit
6f72fdddfe
3899
package-lock.json
generated
3899
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -35,7 +35,7 @@
|
||||
"c8": "^8.0.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"fs-extra": "^11.2.0",
|
||||
"helia": "^5.2.1",
|
||||
"helia": "^5.3.0",
|
||||
"it-all": "^3.0.4",
|
||||
"jsdoc": "^4.0.2",
|
||||
"mocha": "^10.2.0",
|
||||
|
||||
@ -48,12 +48,12 @@ const OplogStore = async ({ logHeads, entryStorage, headsStorage, indexStorage,
|
||||
|
||||
const setHead = async (entry) => {
|
||||
const { hash, bytes } = await Entry.encode(entry, encryptEntryFn, encryptPayloadFn)
|
||||
// The appended entry is now the latest head
|
||||
await _heads.set([{ hash, next: entry.next }])
|
||||
// Add entry to the entry storage
|
||||
await _entries.put(hash, bytes)
|
||||
// Add entry to the entry index
|
||||
await _index.put(hash, true)
|
||||
// The appended entry is now the latest head
|
||||
await _heads.set([{ hash, next: entry.next }])
|
||||
|
||||
return hash
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user