Skip to content

Commit

Permalink
Reproduce bug
Browse files Browse the repository at this point in the history
  • Loading branch information
HDegroote committed Feb 5, 2025
1 parent 4f1b9d4 commit e059ad4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
19 changes: 16 additions & 3 deletions example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ await w.append({ hello: 'verden' })
s1.pipe(s2).pipe(s1)
}

let nextTarget = 1000
base.view.on('append', async function () {
console.log('onappend!', base.view.length, base.view.signedLength)
for (let i = 0; i < base.view.length; i++) {
console.log(i, await base.view.get(i))
if (base.view.length >= nextTarget || base.view.length > -10 + 2 ** 15) {
console.log('onappend!', base.view.length, base.view.signedLength)
nextTarget += 1000
}
})

Expand All @@ -43,3 +44,15 @@ await base.ack()
if (base.view.length === 0) {
await base.append({ type: 'add', key: w.local.key.toString('hex') })
}

if (base.view.length > 10) throw new Error('Clear your example-store storage (easier to test when starting form empty storage')

const nrBlocks = 10000 + 2 ** 15
console.log('appending', nrBlocks, 'blocks')
for (let i = 0; i < nrBlocks; i++) {
w.append({ content: `Block${i}` }).catch(e => console.error(e))
}

console.log('waiting now...')

await new Promise(resolve => setTimeout(resolve, 1000000))
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"test": "standard"
},
"dependencies": {
"autobase": "^7.0.0",
"compact-encoding": "^2.15.1"
"autobase": "holepunchto/autobase",
"compact-encoding": "^2.15.1",
"hypercore": "holepunchto/hypercore"
},
"devDependencies": {
"corestore": "^7.0.0",
Expand Down

0 comments on commit e059ad4

Please sign in to comment.