feat(wallet)!: change persist API to use StageExt and StageExtAsync

This commit is contained in:
志宇
2024-06-13 18:22:43 +08:00
committed by Steve Myers
parent 2e40b0118c
commit 19328d4999
7 changed files with 66 additions and 44 deletions

View File

@@ -147,7 +147,7 @@ fn main() -> anyhow::Result<()> {
let connected_to = block_emission.connected_to();
let start_apply_block = Instant::now();
wallet.apply_block_connected_to(&block_emission.block, height, connected_to)?;
db.write_changes(&wallet.take_staged())?;
wallet.commit_to(&mut db)?;
let elapsed = start_apply_block.elapsed().as_secs_f32();
println!(
"Applied block {} at height {} in {}s",
@@ -157,7 +157,7 @@ fn main() -> anyhow::Result<()> {
Emission::Mempool(mempool_emission) => {
let start_apply_mempool = Instant::now();
wallet.apply_unconfirmed_txs(mempool_emission.iter().map(|(tx, time)| (tx, *time)));
db.write_changes(&wallet.take_staged())?;
wallet.commit_to(&mut db)?;
println!(
"Applied unconfirmed transactions in {}s",
start_apply_mempool.elapsed().as_secs_f32()