Skip to content

Commit 340f550

Browse files
committed
Switch to hintsfile crate
1 parent 8ed944b commit 340f550

File tree

7 files changed

+16
-171
lines changed

7 files changed

+16
-171
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
[workspace]
2-
members = ["accumulator", "hintfile", "node"]
2+
members = ["accumulator", "node"]
33
default-members = ["accumulator"]
44
resolver = "2"
55

66
[workspace.dependencies]
77
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = false, rev = "16cc257c3695dea0e7301a5fa9cab44b8ed60598" }
8+
hintsfile = { git = "https://github.com/rustaceanrob/hintsfile.git" }
9+
# hintsfile = { path = "../hintsfile/" }
810
kernel = { package = "bitcoinkernel", git = "https://github.com/alexanderwiederin/rust-bitcoinkernel.git", rev = "353533221e3ba91d672418eab1ae7b83a61214f9" }
911
p2p = { package = "bitcoin-p2p", git = "https://github.com/2140-dev/bitcoin-p2p.git", rev = "a8b3af8dfc32a06eadb867b07afd537ebf347104" }

hintfile/Cargo.toml

Lines changed: 0 additions & 6 deletions
This file was deleted.

hintfile/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

hintfile/src/lib.rs

Lines changed: 0 additions & 152 deletions
This file was deleted.

node/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build = "build.rs"
88
accumulator = { path = "../accumulator/" }
99
bitcoin = { workspace = true }
1010
kernel = { workspace = true }
11-
hintfile = { path = "../hintfile/" }
11+
hintsfile = { workspace = true }
1212
p2p = { workspace = true }
1313

1414
configure_me = "0.4.0"

node/src/bin/ibd.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
};
77

88
use bitcoin::Network;
9-
use hintfile::Hints;
9+
use hintsfile::Hintsfile;
1010
use kernel::{ChainstateManager, ChainstateManagerOptions, ContextBuilder};
1111

1212
use node::{
@@ -41,8 +41,8 @@ fn main() {
4141
tracing::subscriber::set_global_default(subscriber).unwrap();
4242
let hintfile_start_time = Instant::now();
4343
tracing::info!("Reading in {hint_path}");
44-
let hintfile = File::open(hint_path).expect("invalid hintfile path");
45-
let hints = Hints::from_file(hintfile);
44+
let mut hintfile = File::open(hint_path).expect("invalid hintfile path");
45+
let hints = Hintsfile::from_reader(&mut hintfile);
4646
let stop_height = hints.stop_height();
4747
elapsed_time(hintfile_start_time);
4848
tracing::info!("Syncing to height {}", hints.stop_height());

node/src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use bitcoin::{
1919
transaction::TransactionExt,
2020
BlockHash, Network, OutPoint,
2121
};
22-
use hintfile::Hints;
22+
use hintsfile::Hintsfile;
2323
use kernel::{ChainType, ChainstateManager};
2424
use p2p::{
2525
dns::DnsQueryExt,
@@ -177,7 +177,7 @@ pub fn get_blocks_for_range(
177177
network: Network,
178178
block_dir: Option<PathBuf>,
179179
chain: Arc<ChainstateManager>,
180-
hints: Arc<Mutex<Hints>>,
180+
hints: Arc<Mutex<Hintsfile>>,
181181
peers: Arc<Mutex<Vec<SocketAddr>>>,
182182
updater: Sender<AccumulatorUpdate>,
183183
hashes: Arc<Mutex<Vec<Vec<BlockHash>>>>,
@@ -234,9 +234,13 @@ pub fn get_blocks_for_range(
234234
.block_index_by_hash(kernal_hash)
235235
.expect("header is in best chain.");
236236
let block_height = block_index.height().unsigned_abs();
237-
let unspent_indexes: HashSet<u64> = {
238-
let mut hint_ref = hints.lock().unwrap();
239-
hint_ref.get_indexes(block_height).into_iter().collect()
237+
let unspent_indexes: HashSet<u16> = {
238+
let hint_ref = hints.lock().unwrap();
239+
hint_ref
240+
.indices_at_height(block_height)
241+
.expect("hints should exist")
242+
.into_iter()
243+
.collect()
240244
};
241245
if let Some(block_dir) = block_dir.as_ref() {
242246
let file_path = block_dir.join(format!("{hash}.block"));

0 commit comments

Comments
 (0)