mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
Remove obsolete useRefs option in log traverse function
This commit is contained in:
parent
e6afa0b7e7
commit
1564ee0325
@ -326,7 +326,7 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora
|
|||||||
* @memberof module:Log~Log
|
* @memberof module:Log~Log
|
||||||
* @instance
|
* @instance
|
||||||
*/
|
*/
|
||||||
const traverse = async function * (rootEntries, shouldStopFn, useRefs = true) {
|
const traverse = async function * (rootEntries, shouldStopFn) {
|
||||||
// By default, we don't stop traversal and traverse
|
// By default, we don't stop traversal and traverse
|
||||||
// until the end of the log
|
// until the end of the log
|
||||||
const defaultStopFn = () => false
|
const defaultStopFn = () => false
|
||||||
@ -350,7 +350,7 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora
|
|||||||
// Get the next entry from the stack
|
// Get the next entry from the stack
|
||||||
entry = stack.pop()
|
entry = stack.pop()
|
||||||
if (entry) {
|
if (entry) {
|
||||||
const { hash, next, refs } = entry
|
const { hash, next } = entry
|
||||||
// If we have an entry that we haven't traversed yet, process it
|
// If we have an entry that we haven't traversed yet, process it
|
||||||
if (!traversed[hash]) {
|
if (!traversed[hash]) {
|
||||||
// Yield the current entry
|
// Yield the current entry
|
||||||
@ -365,7 +365,7 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora
|
|||||||
fetched[hash] = true
|
fetched[hash] = true
|
||||||
// Add the next and refs hashes to the list of hashes to fetch next,
|
// Add the next and refs hashes to the list of hashes to fetch next,
|
||||||
// filter out traversed and fetched hashes
|
// filter out traversed and fetched hashes
|
||||||
toFetch = [...toFetch, ...next, ...(useRefs ? refs : [])].filter(notIndexed)
|
toFetch = [...toFetch, ...next].filter(notIndexed)
|
||||||
// Function to fetch an entry and making sure it's not a duplicate (check the hash indices)
|
// Function to fetch an entry and making sure it's not a duplicate (check the hash indices)
|
||||||
const fetchEntries = (hash) => {
|
const fetchEntries = (hash) => {
|
||||||
if (!traversed[hash] && !fetched[hash]) {
|
if (!traversed[hash] && !fetched[hash]) {
|
||||||
@ -379,7 +379,7 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora
|
|||||||
// Add the next and refs fields from the fetched entries to the next round
|
// Add the next and refs fields from the fetched entries to the next round
|
||||||
toFetch = nexts
|
toFetch = nexts
|
||||||
.filter(e => e !== null && e !== undefined)
|
.filter(e => e !== null && e !== undefined)
|
||||||
.reduce((res, acc) => Array.from(new Set([...res, ...acc.next, ...(useRefs ? acc.refs : [])])), [])
|
.reduce((res, acc) => Array.from(new Set([...res, ...acc.next])), [])
|
||||||
.filter(notIndexed)
|
.filter(notIndexed)
|
||||||
// Add the fetched entries to the stack to be processed
|
// Add the fetched entries to the stack to be processed
|
||||||
stack = [...nexts, ...stack]
|
stack = [...nexts, ...stack]
|
||||||
@ -543,7 +543,7 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora
|
|||||||
const shouldStopTraversal = async (entry) => {
|
const shouldStopTraversal = async (entry) => {
|
||||||
return refs.length >= amount && amount !== -1
|
return refs.length >= amount && amount !== -1
|
||||||
}
|
}
|
||||||
for await (const { hash } of traverse(heads, shouldStopTraversal, false)) {
|
for await (const { hash } of traverse(heads, shouldStopTraversal)) {
|
||||||
refs.push(hash)
|
refs.push(hash)
|
||||||
}
|
}
|
||||||
refs = refs.slice(heads.length + 1, amount)
|
refs = refs.slice(heads.length + 1, amount)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user