Skip to content

Commit 5aab1d5

Browse files
committed
Importing transactions won't load anymore all transactions in memory
Instead the streamer api is used to loaded them by chunks, right now those chunks are by immutable files but the API is agnostic to them and could be used with the chain sync protocol.
1 parent 51e51b4 commit 5aab1d5

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

mithril-aggregator/src/services/cardano_transactions_importer.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,18 @@ impl CardanoTransactionsImporter {
108108
);
109109

110110
let mut streamer = self.block_scanner.scan(&self.dirpath, from, until).await?;
111-
let parsed_transactions: Vec<CardanoTransaction> = streamer
112-
.poll_all()
113-
.await?
114-
.into_iter()
115-
.flat_map(|b| b.into_transactions())
116-
.collect();
117111

118-
self.transaction_store
119-
.store_transactions(parsed_transactions)
120-
.await?;
112+
while let Some(blocks) = streamer.poll_next().await? {
113+
let parsed_transactions: Vec<CardanoTransaction> = blocks
114+
.into_iter()
115+
.flat_map(|b| b.into_transactions())
116+
.collect();
117+
118+
self.transaction_store
119+
.store_transactions(parsed_transactions)
120+
.await?;
121+
}
122+
121123
Ok(())
122124
}
123125

mithril-signer/src/cardano_transactions_importer.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,18 @@ impl CardanoTransactionsImporter {
108108
);
109109

110110
let mut streamer = self.block_scanner.scan(&self.dirpath, from, until).await?;
111-
let parsed_transactions: Vec<CardanoTransaction> = streamer
112-
.poll_all()
113-
.await?
114-
.into_iter()
115-
.flat_map(|b| b.into_transactions())
116-
.collect();
117111

118-
self.transaction_store
119-
.store_transactions(parsed_transactions)
120-
.await?;
112+
while let Some(blocks) = streamer.poll_next().await? {
113+
let parsed_transactions: Vec<CardanoTransaction> = blocks
114+
.into_iter()
115+
.flat_map(|b| b.into_transactions())
116+
.collect();
117+
118+
self.transaction_store
119+
.store_transactions(parsed_transactions)
120+
.await?;
121+
}
122+
121123
Ok(())
122124
}
123125

0 commit comments

Comments
 (0)