Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: treeHash for not-locally-available block #489

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HDegroote
Copy link
Contributor

@HDegroote HDegroote commented Mar 18, 2024

Current behaviour is a low-level error, even when the required block is available from the swarm and core.length is higher:

/home/hans/holepunch/hypercore/node_modules/random-access-memory/index.js:86
      return req.callback(new Error('Could not satisfy length'), null)
                          ^

Error: Could not satisfy length
    at RAM._read (/home/hans/holepunch/hypercore/node_modules/random-access-memory/index.js:86:27)
    at Request._run (/home/hans/holepunch/hypercore/node_modules/random-access-storage/index.js:258:42)
    at RAM.run (/home/hans/holepunch/hypercore/node_modules/random-access-storage/index.js:153:14)
    at RAM.read (/home/hans/holepunch/hypercore/node_modules/random-access-storage/index.js:60:10)
    at /home/hans/holepunch/hypercore/lib/merkle-tree.js:1111:13
    at new Promise (<anonymous>)
    at getStoredNode (/home/hans/holepunch/hypercore/lib/merkle-tree.js:1110:10)
    at MerkleTree.get (/home/hans/holepunch/hypercore/lib/merkle-tree.js:470:12)
    at MerkleTree.getRoots (/home/hans/holepunch/hypercore/lib/merkle-tree.js:422:23)
    at Hypercore.treeHash (/home/hans/holepunch/hypercore/index.js:1060:40)

Note: also always running the opened-check now, because calling treeHash(...) with a specified length without awaiting ready causes a crash (this.core.tree doesn't exist yet)

@HDegroote HDegroote marked this pull request as draft March 26, 2024 12:12
@HDegroote
Copy link
Contributor Author

Converted to draft until I updated it. The clean solution is to throw a clearer error when the block is not locally available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant