Skip to content

Commit b914203

Browse files
authored
Merge pull request #1655 from input-output-hk/jpraynaud/1633-optimize-block-range-root-computation
Optimize block range roots computation
2 parents 0673352 + 4c28f6c commit b914203

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.4.64"
3+
version = "0.4.65"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/services/cardano_transactions_importer.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::mem;
12
use std::ops::Range;
23
use std::path::{Path, PathBuf};
34
use std::sync::Arc;
@@ -155,6 +156,14 @@ impl CardanoTransactionsImporter {
155156

156157
let merkle_root = MKTree::new(&transactions)?.compute_root()?;
157158
block_ranges_with_merkle_root.push((block_range, merkle_root));
159+
160+
if block_ranges_with_merkle_root.len() >= 100 {
161+
let block_ranges_with_merkle_root_save =
162+
mem::take(&mut block_ranges_with_merkle_root);
163+
self.transaction_store
164+
.store_block_range_roots(block_ranges_with_merkle_root_save)
165+
.await?;
166+
}
158167
}
159168

160169
self.transaction_store

mithril-signer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-signer"
3-
version = "0.2.128"
3+
version = "0.2.129"
44
description = "A Mithril Signer"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-signer/src/cardano_transactions_importer.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::mem;
12
use std::ops::Range;
23
use std::path::{Path, PathBuf};
34
use std::sync::Arc;
@@ -155,6 +156,14 @@ impl CardanoTransactionsImporter {
155156

156157
let merkle_root = MKTree::new(&transactions)?.compute_root()?;
157158
block_ranges_with_merkle_root.push((block_range, merkle_root));
159+
160+
if block_ranges_with_merkle_root.len() >= 100 {
161+
let block_ranges_with_merkle_root_save =
162+
mem::take(&mut block_ranges_with_merkle_root);
163+
self.transaction_store
164+
.store_block_range_roots(block_ranges_with_merkle_root_save)
165+
.await?;
166+
}
158167
}
159168

160169
self.transaction_store

0 commit comments

Comments
 (0)