Skip to content

Commit 053cad2

Browse files
committed
Replaced printlns with info tracing calls
1 parent 017fbe8 commit 053cad2

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

common/src/snapshot/streaming_snapshot.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use serde::{Deserialize, Serialize};
2727
use std::collections::BTreeMap;
2828
use std::fs::File;
2929
use std::io::{Read, Seek, SeekFrom};
30+
use tracing::info;
3031

3132
pub use crate::hash::{AddrKeyhash, Hash, ScriptHash};
3233
pub use crate::stake_addresses::{AccountState, StakeAddressState};
@@ -1534,7 +1535,6 @@ impl StreamingSnapshotParser {
15341535
// Check for indefinite map break
15351536
if map_len == u64::MAX {
15361537
if matches!(entry_decoder.datatype(), Ok(Type::Break)) {
1537-
println!(" ✅ Found indefinite map break");
15381538
entries_processed = map_len; // Exit outer loop
15391539
break;
15401540
}
@@ -1557,8 +1557,8 @@ impl StreamingSnapshotParser {
15571557
// Progress reporting - less frequent for better performance
15581558
if utxo_count % 1000000 == 0 {
15591559
let buffer_usage = buffer.len();
1560-
println!(
1561-
" 🔄 Streamed {} UTXOs, buffer: {} MB, max entry: {} bytes",
1560+
info!(
1561+
" Streamed {} UTXOs, buffer: {} MB, max entry: {} bytes",
15621562
utxo_count,
15631563
buffer_usage / 1024 / 1024,
15641564
max_single_entry_size
@@ -1615,24 +1615,20 @@ impl StreamingSnapshotParser {
16151615
}
16161616
}
16171617

1618-
println!(" 🎯 TRUE STREAMING RESULTS:");
1619-
println!(" • UTXOs processed: {}", utxo_count);
1620-
println!(
1618+
info!(" 🎯 STREAMING RESULTS:");
1619+
info!(" • UTXOs processed: {}", utxo_count);
1620+
info!(
16211621
" • Total data streamed: {:.2} MB",
16221622
total_bytes_processed as f64 / 1024.0 / 1024.0
16231623
);
1624-
println!(
1624+
info!(
16251625
" • Peak buffer usage: {} MB (vs 2.1GB before!)",
16261626
PARSE_BUFFER_SIZE / 1024 / 1024
16271627
);
1628-
println!(
1628+
info!(
16291629
" • Largest single entry: {} bytes",
16301630
max_single_entry_size
16311631
);
1632-
println!(
1633-
" • Memory reduction: ~{}x smaller",
1634-
(2100 * 1024) / (PARSE_BUFFER_SIZE / 1024)
1635-
);
16361632

16371633
Ok(utxo_count)
16381634
}
@@ -1682,17 +1678,17 @@ impl StreamingSnapshotParser {
16821678
}
16831679
} else {
16841680
// Indefinite-length array
1685-
eprintln!("📦 Processing indefinite-length blocks array");
1681+
info!("📦 Processing indefinite-length blocks array");
16861682
let mut count = 0;
16871683
loop {
16881684
match decoder.datatype()? {
16891685
Type::Break => {
16901686
decoder.skip()?;
1691-
eprintln!("📦 Found array break after {} entries", count);
1687+
info!("📦 Found array break after {} entries", count);
16921688
break;
16931689
}
16941690
entry_type => {
1695-
eprintln!(" Block #{}: {:?}", count + 1, entry_type);
1691+
info!(" Block #{}: {:?}", count + 1, entry_type);
16961692
decoder.skip().context("Failed to skip block entry")?;
16971693
count += 1;
16981694
}
@@ -1755,19 +1751,19 @@ impl StreamingSnapshotParser {
17551751
match simple_type {
17561752
Type::U8 | Type::U16 | Type::U32 | Type::U64 => {
17571753
let value = decoder.u64().context("Failed to read block integer value")?;
1758-
eprintln!("📦 Block data is integer: {}", value);
1754+
info!("📦 Block data is integer: {}", value);
17591755
}
17601756
Type::Bytes => {
17611757
let bytes = decoder.bytes().context("Failed to read block bytes")?;
1762-
eprintln!("📦 Block data is {} bytes", bytes.len());
1758+
info!("📦 Block data is {} bytes", bytes.len());
17631759
}
17641760
Type::String => {
17651761
let text = decoder.str().context("Failed to read block text")?;
1766-
eprintln!("📦 Block data is text: '{}'", text);
1762+
info!("📦 Block data is text: '{}'", text);
17671763
}
17681764
Type::Null => {
17691765
decoder.skip()?;
1770-
eprintln!("📦 Block data is null");
1766+
info!("📦 Block data is null");
17711767
}
17721768
_ => {
17731769
decoder.skip().context("Failed to skip blocks value")?;
@@ -1939,7 +1935,7 @@ impl StreamingSnapshotParser {
19391935
.map(|relay| match relay {
19401936
Relay::SingleHostAddr(port, ipv4, ipv6) => {
19411937
let port_opt = match port {
1942-
Nullable::Some(p) => Some(*p as u16),
1938+
Nullable::Some(p) => u16::try_from(*p).ok(),
19431939
_ => None,
19441940
};
19451941
let ipv4_opt = match ipv4 {

0 commit comments

Comments
 (0)