mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-06-15 08:58:29 +08:00
fix: build warnings
This commit is contained in:
@@ -266,21 +266,26 @@ pub async fn download_ordinals_dataset_if_required(config: &Config, ctx: &Contex
|
||||
Ok(response) => response.bytes().await,
|
||||
Err(e) => Err(e),
|
||||
};
|
||||
match (local_sha_file, remote_sha_file) {
|
||||
let should_download = match (local_sha_file, remote_sha_file) {
|
||||
(Ok(local), Ok(remote_response)) => {
|
||||
println!("{:?}", local);
|
||||
println!("{:?}", remote_response);
|
||||
}
|
||||
(Ok(local), _) => {
|
||||
// println!("Local: {:?}", local)
|
||||
let cache_not_expired = remote_response.starts_with(&local[0..32]) == false;
|
||||
if cache_not_expired {
|
||||
info!(
|
||||
ctx.expect_logger(),
|
||||
"More recent Stacks archive file detected"
|
||||
);
|
||||
}
|
||||
cache_not_expired == false
|
||||
}
|
||||
(_, _) => {
|
||||
// We will download the latest file
|
||||
println!("error reading local / remote");
|
||||
info!(
|
||||
ctx.expect_logger(),
|
||||
"Unable to retrieve Stacks archive file locally"
|
||||
);
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
if !sqlite_file_path.exists() {
|
||||
};
|
||||
if should_download {
|
||||
info!(ctx.expect_logger(), "Downloading {}", url);
|
||||
match download_sqlite_file(&config).await {
|
||||
Ok(_) => {}
|
||||
|
||||
@@ -739,7 +739,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
|
||||
open_readwrite_hord_db_conn_rocks_db(&config.expected_cache_path(), &ctx)?;
|
||||
|
||||
let tip_height = find_last_block_inserted(&blocks_db_conn) as u64;
|
||||
let end_at = match cmd.block_height {
|
||||
let _end_at = match cmd.block_height {
|
||||
Some(block_height) if block_height > tip_height => {
|
||||
perform_hord_db_update(
|
||||
tip_height,
|
||||
@@ -754,7 +754,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
|
||||
_ => tip_height,
|
||||
};
|
||||
|
||||
let (start_at_height, watched_satpoint) = find_watched_satpoint_for_inscription(
|
||||
let (_start_at_height, watched_satpoint) = find_watched_satpoint_for_inscription(
|
||||
&cmd.inscription_id,
|
||||
&inscriptions_db_conn,
|
||||
)?;
|
||||
|
||||
@@ -293,6 +293,10 @@ pub async fn scan_stacks_chainstate_via_csv_using_predicate(
|
||||
let mut last_block_scanned = BlockIdentifier::default();
|
||||
let mut err_count = 0;
|
||||
for (block_identifier, _parent_block_identifier, blob) in canonical_fork.drain(..) {
|
||||
if block_identifier.index <= start_block {
|
||||
continue
|
||||
}
|
||||
|
||||
last_block_scanned = block_identifier;
|
||||
blocks_scanned += 1;
|
||||
let block_data = match indexer::stacks::standardize_stacks_serialized_block(
|
||||
|
||||
@@ -301,20 +301,15 @@ pub fn get_entry_from_predicates_db(
|
||||
Some(payload) => payload,
|
||||
};
|
||||
|
||||
let spec = match ChainhookSpecification::deserialize_specification(&encoded_spec) {
|
||||
Err(e) => unimplemented!(),
|
||||
Ok(spec) => spec,
|
||||
};
|
||||
let spec = ChainhookSpecification::deserialize_specification(&encoded_spec)?;
|
||||
|
||||
let encoded_status = match entry.get("status") {
|
||||
None => unimplemented!(),
|
||||
Some(payload) => payload,
|
||||
};
|
||||
|
||||
let status = match serde_json::from_str(&encoded_status) {
|
||||
Err(e) => unimplemented!(), // TODO
|
||||
Ok(status) => status,
|
||||
};
|
||||
let status = serde_json::from_str(&encoded_status)
|
||||
.map_err(|e| format!("{}", e.to_string()))?;
|
||||
|
||||
Ok(Some((spec, status)))
|
||||
}
|
||||
|
||||
@@ -142,5 +142,5 @@ pub fn start_bitcoin_scan_runloop(
|
||||
));
|
||||
});
|
||||
}
|
||||
let res = bitcoin_scan_pool.join();
|
||||
let _ = bitcoin_scan_pool.join();
|
||||
}
|
||||
|
||||
@@ -484,11 +484,9 @@ pub fn find_all_inscriptions_in_block(
|
||||
let inscription_number: i64 = row.get(0).unwrap();
|
||||
let ordinal_number: u64 = row.get(1).unwrap();
|
||||
let block_height: u64 = row.get(2).unwrap();
|
||||
let transaction_id = {
|
||||
let (transaction_id, _) = {
|
||||
let inscription_id: String = row.get(3).unwrap();
|
||||
TransactionIdentifier {
|
||||
hash: format!("0x{}", &inscription_id[0..inscription_id.len() - 2]),
|
||||
}
|
||||
parse_inscription_id(&inscription_id)
|
||||
};
|
||||
let inscription_offset: u64 = row.get(4).unwrap();
|
||||
let outpoint_to_watch: String = row.get(5).unwrap();
|
||||
@@ -517,10 +515,8 @@ pub struct WatchedSatpoint {
|
||||
|
||||
impl WatchedSatpoint {
|
||||
pub fn get_genesis_satpoint(&self) -> String {
|
||||
format!(
|
||||
"{}:0",
|
||||
&self.inscription_id[0..self.inscription_id.len() - 2]
|
||||
)
|
||||
let (transaction_id, input) = parse_inscription_id(&self.inscription_id);
|
||||
format!("{}:{}", transaction_id.hash, input)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -902,6 +898,15 @@ pub fn format_outpoint_to_watch(
|
||||
)
|
||||
}
|
||||
|
||||
pub fn parse_inscription_id(inscription_id: &str) -> (TransactionIdentifier, usize) {
|
||||
let comps: Vec<&str> = inscription_id.split("i").collect();
|
||||
let tx = TransactionIdentifier {
|
||||
hash: format!("0x{}", comps[0]),
|
||||
};
|
||||
let output_index = comps[1].to_string().parse::<usize>().unwrap();
|
||||
(tx, output_index)
|
||||
}
|
||||
|
||||
pub fn parse_outpoint_to_watch(outpoint_to_watch: &str) -> (TransactionIdentifier, usize) {
|
||||
let comps: Vec<&str> = outpoint_to_watch.split(":").collect();
|
||||
let tx = TransactionIdentifier {
|
||||
|
||||
Reference in New Issue
Block a user