Skip to content

Extract ledger::block_find for block lookup given hash and root#5045

Merged
pwojcikdev merged 1 commit intonanocurrency:developfrom
pwojcikdev:extract-block-find
Mar 20, 2026
Merged

Extract ledger::block_find for block lookup given hash and root#5045
pwojcikdev merged 1 commit intonanocurrency:developfrom
pwojcikdev:extract-block-find

Conversation

@pwojcikdev
Copy link
Copy Markdown
Contributor

Removes the duplicated block lookup lambda in request_aggregator::aggregate and replaces it with a call to the newly extracted ledger::block_find, which implements the same three-step search strategy (hash, successor of root, open block of root-as-account).

@gr0vity-dev-bot
Copy link
Copy Markdown

Test Results for Commit 5e69c72

Pull Request 5045: Results
Overall Status:

Test Case Results

  • 5n4pr_conf_10k_bintree: PASS (Duration: 112s)
  • 5n4pr_conf_10k_change: PASS (Duration: 193s)
  • 5n4pr_conf_change_dependant: PASS (Duration: 128s)
  • 5n4pr_conf_change_independant: PASS (Duration: 130s)
  • 5n4pr_conf_send_dependant: PASS (Duration: 127s)
  • 5n4pr_conf_send_independant: PASS (Duration: 131s)
  • 5n4pr_rocks_10k_bintree: PASS (Duration: 113s)
  • 5n4pr_rocks_10k_change: FAIL (Duration: 276s)
  • Log

Last updated: 2026-03-20 02:35:40 UTC

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extracts the block-lookup logic used by request_aggregator::aggregate into a reusable nano::ledger::block_find helper, preserving the existing three-step search strategy while reducing duplication and adding targeted unit coverage.

Changes:

  • Add nano::ledger::block_find(transaction, hash, root) to centralize lookup by hash, then by root successor, then by root-as-account open block.
  • Replace the duplicated lookup lambda in request_aggregator::aggregate with a call to ledger.block_find.
  • Add comprehensive unit tests covering lookup precedence and edge cases (including epoch open and hash/account collisions).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
nano/secure/ledger.hpp Declares the new ledger::block_find API.
nano/secure/ledger.cpp Implements the extracted block lookup strategy.
nano/node/request_aggregator.cpp Uses ledger.block_find instead of an inline lambda.
nano/core_test/ledger.cpp Adds unit tests validating lookup behavior and precedence.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pwojcikdev pwojcikdev merged commit f43442d into nanocurrency:develop Mar 20, 2026
32 checks passed
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.

3 participants