Skip to content

Commit d3e998c

Browse files
author
Ludo Galabru
committed
fix: build warnings
1 parent 9e54bff commit d3e998c

File tree

6 files changed

+39
-30
lines changed

6 files changed

+39
-30
lines changed

components/chainhook-cli/src/archive/mod.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -266,21 +266,26 @@ pub async fn download_ordinals_dataset_if_required(config: &Config, ctx: &Contex
266266
Ok(response) => response.bytes().await,
267267
Err(e) => Err(e),
268268
};
269-
match (local_sha_file, remote_sha_file) {
269+
let should_download = match (local_sha_file, remote_sha_file) {
270270
(Ok(local), Ok(remote_response)) => {
271-
println!("{:?}", local);
272-
println!("{:?}", remote_response);
273-
}
274-
(Ok(local), _) => {
275-
// println!("Local: {:?}", local)
271+
let cache_not_expired = remote_response.starts_with(&local[0..32]) == false;
272+
if cache_not_expired {
273+
info!(
274+
ctx.expect_logger(),
275+
"More recent Stacks archive file detected"
276+
);
277+
}
278+
cache_not_expired == false
276279
}
277280
(_, _) => {
278-
// We will download the latest file
279-
println!("error reading local / remote");
281+
info!(
282+
ctx.expect_logger(),
283+
"Unable to retrieve Stacks archive file locally"
284+
);
285+
true
280286
}
281-
}
282-
283-
if !sqlite_file_path.exists() {
287+
};
288+
if should_download {
284289
info!(ctx.expect_logger(), "Downloading {}", url);
285290
match download_sqlite_file(&config).await {
286291
Ok(_) => {}

components/chainhook-cli/src/cli/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
739739
open_readwrite_hord_db_conn_rocks_db(&config.expected_cache_path(), &ctx)?;
740740

741741
let tip_height = find_last_block_inserted(&blocks_db_conn) as u64;
742-
let end_at = match cmd.block_height {
742+
let _end_at = match cmd.block_height {
743743
Some(block_height) if block_height > tip_height => {
744744
perform_hord_db_update(
745745
tip_height,
@@ -754,7 +754,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
754754
_ => tip_height,
755755
};
756756

757-
let (start_at_height, watched_satpoint) = find_watched_satpoint_for_inscription(
757+
let (_start_at_height, watched_satpoint) = find_watched_satpoint_for_inscription(
758758
&cmd.inscription_id,
759759
&inscriptions_db_conn,
760760
)?;

components/chainhook-cli/src/scan/stacks.rs

+4
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ pub async fn scan_stacks_chainstate_via_csv_using_predicate(
293293
let mut last_block_scanned = BlockIdentifier::default();
294294
let mut err_count = 0;
295295
for (block_identifier, _parent_block_identifier, blob) in canonical_fork.drain(..) {
296+
if block_identifier.index <= start_block {
297+
continue
298+
}
299+
296300
last_block_scanned = block_identifier;
297301
blocks_scanned += 1;
298302
let block_data = match indexer::stacks::standardize_stacks_serialized_block(

components/chainhook-cli/src/service/http_api.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -301,20 +301,15 @@ pub fn get_entry_from_predicates_db(
301301
Some(payload) => payload,
302302
};
303303

304-
let spec = match ChainhookSpecification::deserialize_specification(&encoded_spec) {
305-
Err(e) => unimplemented!(),
306-
Ok(spec) => spec,
307-
};
304+
let spec = ChainhookSpecification::deserialize_specification(&encoded_spec)?;
308305

309306
let encoded_status = match entry.get("status") {
310307
None => unimplemented!(),
311308
Some(payload) => payload,
312309
};
313310

314-
let status = match serde_json::from_str(&encoded_status) {
315-
Err(e) => unimplemented!(), // TODO
316-
Ok(status) => status,
317-
};
311+
let status = serde_json::from_str(&encoded_status)
312+
.map_err(|e| format!("{}", e.to_string()))?;
318313

319314
Ok(Some((spec, status)))
320315
}

components/chainhook-cli/src/service/runloops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@ pub fn start_bitcoin_scan_runloop(
142142
));
143143
});
144144
}
145-
let res = bitcoin_scan_pool.join();
145+
let _ = bitcoin_scan_pool.join();
146146
}

components/chainhook-sdk/src/hord/db/mod.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,9 @@ pub fn find_all_inscriptions_in_block(
484484
let inscription_number: i64 = row.get(0).unwrap();
485485
let ordinal_number: u64 = row.get(1).unwrap();
486486
let block_height: u64 = row.get(2).unwrap();
487-
let transaction_id = {
487+
let (transaction_id, _) = {
488488
let inscription_id: String = row.get(3).unwrap();
489-
TransactionIdentifier {
490-
hash: format!("0x{}", &inscription_id[0..inscription_id.len() - 2]),
491-
}
489+
parse_inscription_id(&inscription_id)
492490
};
493491
let inscription_offset: u64 = row.get(4).unwrap();
494492
let outpoint_to_watch: String = row.get(5).unwrap();
@@ -517,10 +515,8 @@ pub struct WatchedSatpoint {
517515

518516
impl WatchedSatpoint {
519517
pub fn get_genesis_satpoint(&self) -> String {
520-
format!(
521-
"{}:0",
522-
&self.inscription_id[0..self.inscription_id.len() - 2]
523-
)
518+
let (transaction_id, input) = parse_inscription_id(&self.inscription_id);
519+
format!("{}:{}", transaction_id.hash, input)
524520
}
525521
}
526522

@@ -902,6 +898,15 @@ pub fn format_outpoint_to_watch(
902898
)
903899
}
904900

901+
pub fn parse_inscription_id(inscription_id: &str) -> (TransactionIdentifier, usize) {
902+
let comps: Vec<&str> = inscription_id.split("i").collect();
903+
let tx = TransactionIdentifier {
904+
hash: format!("0x{}", comps[0]),
905+
};
906+
let output_index = comps[1].to_string().parse::<usize>().unwrap();
907+
(tx, output_index)
908+
}
909+
905910
pub fn parse_outpoint_to_watch(outpoint_to_watch: &str) -> (TransactionIdentifier, usize) {
906911
let comps: Vec<&str> = outpoint_to_watch.split(":").collect();
907912
let tx = TransactionIdentifier {

0 commit comments

Comments
 (0)