Skip to content

Commit

Permalink
Nits
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Dec 17, 2024
1 parent c5d63a2 commit 6c278b4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 36 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl DumpTxOutSetCmd {
let utxo_set_size = fetch_utxo_set_at(&client, height)?.2.count() as u64;

println!(
"Exporting UTXO set (utxo_set_size) at #{block_number},{bitcoin_block_hash} to binary file: {}",
"Exporting UTXO set ({utxo_set_size}) at #{block_number},{bitcoin_block_hash} to binary file: {}",
path.display()
);

Expand Down
2 changes: 0 additions & 2 deletions crates/subcoin-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ sc-network = { workspace = true }
sc-network-sync = { workspace = true }
sc-rpc = { workspace = true }
sc-rpc-api = { workspace = true }
# `test-helpers` for the exposed Client type.
# sc-service = { workspace = true, features = ["test-helpers"], default-features = false }
sc-service = { workspace = true, default-features = false }
sc-storage-monitor = { workspace = true }
sc-sysinfo = { workspace = true }
Expand Down
47 changes: 19 additions & 28 deletions crates/subcoin-snapcake/src/snapshot_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,34 +119,24 @@ impl SnapshotStore {
utxos_count: u64,
) -> std::io::Result<()> {
match self {
Self::InMem(list) => {
let utxos = std::mem::take(list);

snapshot_generator.generate_snapshot_in_mem(
target_bitcoin_block_hash,
utxos_count as u64,
utxos,
)?;
}
Self::Csv(path) => {
generate_from_csv(
path,
snapshot_generator,
target_bitcoin_block_hash,
utxos_count,
)?;
}
Self::Rocksdb(db) => {
generate_from_rocksdb(
db,
snapshot_generator,
target_bitcoin_block_hash,
utxos_count,
)?;
}
Self::InMem(list) => snapshot_generator.generate_snapshot_in_mem(
target_bitcoin_block_hash,
utxos_count as u64,
std::mem::take(list),
),
Self::Csv(path) => generate_from_csv(
path,
snapshot_generator,
target_bitcoin_block_hash,
utxos_count,
),
Self::Rocksdb(db) => generate_from_rocksdb(
db,
snapshot_generator,
target_bitcoin_block_hash,
utxos_count,
),
}

Ok(())
}
}

Expand Down Expand Up @@ -229,7 +219,7 @@ fn generate_from_rocksdb(
let mut written = 0;
let mut last_progress_update_time = Instant::now();

snapshot_generator.write_snapshot_metadata(bitcoin_block_hash, utxos_count)?;
snapshot_generator.write_metadata(bitcoin_block_hash, utxos_count)?;

for entry in db.iterator(rocksdb::IteratorMode::Start) {
let (key, value) = entry.unwrap();
Expand Down Expand Up @@ -358,3 +348,4 @@ impl SnapshotProcessor {
.expect("Failed to write UTXO set snapshot");
}
}

2 changes: 0 additions & 2 deletions crates/subcoin-utxo-snapshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ bitcoin = { workspace = true, features = ["serde"] }
serde = { workspace = true }
subcoin-primitives = { workspace = true }
txoutset = { workspace = true }
tracing = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
fastrand = { workspace = true }
Expand Down
4 changes: 3 additions & 1 deletion crates/subcoin-utxo-snapshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl UtxoSnapshotGenerator {
}

/// Writes the metadata of snapshot.
pub fn write_snapshot_metadata(
pub fn write_metadata(
&mut self,
bitcoin_block_hash: BlockHash,
coins_count: u64,
Expand Down Expand Up @@ -310,6 +310,7 @@ fn generate_snapshot_in_mem_inner<W: std::io::Write>(
Ok(())
}

///
pub fn write_coins<W: std::io::Write>(
writer: &mut W,
txid: bitcoin::Txid,
Expand Down Expand Up @@ -351,3 +352,4 @@ fn serialize_coin<W: std::io::Write>(writer: &mut W, coin: Coin) -> std::io::Res

Ok(())
}

0 comments on commit 6c278b4

Please sign in to comment.