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

snapshots: refactor SnapshotRepository #2056

Merged
merged 16 commits into from
Jun 5, 2024
Merged

snapshots: refactor SnapshotRepository #2056

merged 16 commits into from
Jun 5, 2024

Conversation

battlmonstr
Copy link
Contributor

@battlmonstr battlmonstr commented May 30, 2024

Refactor data access layer (DAL) logic and schema definition out of SnapshotRepository.

  • schema is defined in snapshot_bundle.hpp and snapshot_type.hpp, indexes are defined in SnapshotBundleFactory
  • find_segment is exposed with a snapshot type parameter
  • view_xx_segments is replaced by iteration on bundles in a forward or reverse order (view_bundles_reverse)
  • find_block_number is replaced by a new query object - TransactionBlockNumByTxnHashRepoQuery
    that runs TransactionBlockNumByTxnHashQuery on a view of bundles and returns the first match
  • replace for_each_xx with nested for loops
  • refactor queries to take SnapshotAndIndex

DataModel::read_transactions_from_snapshot: remove an extra reserve

@battlmonstr battlmonstr force-pushed the pr/reporefac branch 4 times, most recently from 8127485 to fb8182d Compare May 30, 2024 21:54
@battlmonstr battlmonstr requested a review from canepat June 3, 2024 07:54
@battlmonstr battlmonstr marked this pull request as ready for review June 3, 2024 07:54
@battlmonstr battlmonstr enabled auto-merge (squash) June 3, 2024 12:01
@@ -227,44 +228,48 @@ void decode_segment(const SnapSettings& settings, int repetitions) {
SILK_INFO << "Decode snapshot elapsed: " << duration_as<std::chrono::milliseconds>(elapsed) << " msec";
}

static std::unique_ptr<SnapshotBundleFactory> bundle_factory() {
return std::make_unique<silkworm::db::SnapshotBundleFactoryImpl>();
}
Copy link
Member

Choose a reason for hiding this comment

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

I suggest moving this factory function into snapshot_bundle_factory_impl.hpp, so that we can use it everywhere and have a one-liner creation for SnapshotRepository as below:

SnapshotRepository snapshot_repo{settings, bundle_factory()};

@battlmonstr battlmonstr merged commit 1ec9695 into master Jun 5, 2024
4 checks passed
@battlmonstr battlmonstr deleted the pr/reporefac branch June 5, 2024 05:32
@canepat canepat added the snapshots Framework for BitTorrent-based snapshots label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
snapshots Framework for BitTorrent-based snapshots
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants