Skip to content

Commit 20d9df6

Browse files
author
Ludo Galabru
committed
fix: patch crach
1 parent 832b4dd commit 20d9df6

File tree

6 files changed

+35
-30
lines changed

6 files changed

+35
-30
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,9 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
666666
RepairCommand::Transfers(cmd) => {
667667
let config = Config::default(false, false, false, &cmd.config_path)?;
668668
let service = Service::new(config, ctx.clone());
669-
service.replay_transfers(cmd.start_block, cmd.end_block, None).await?;
669+
service
670+
.replay_transfers(cmd.start_block, cmd.end_block, None)
671+
.await?;
670672
}
671673
},
672674
Command::Db(HordDbCommand::Check(cmd)) => {

components/hord-cli/src/core/pipeline/mod.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,13 @@ pub async fn download_and_pipeline_blocks(
157157
loop {
158158
// Dequeue all the blocks available
159159
let mut new_blocks = vec![];
160-
while let Ok(Some((block_height, block, compacted_block))) = block_compressed_rx.try_recv()
160+
while let Ok(Some((block_height, block, compacted_block))) =
161+
block_compressed_rx.try_recv()
161162
{
162163
blocks_processed += 1;
163164
new_blocks.push((block_height, block, compacted_block));
164165
if new_blocks.len() >= 10_000 {
165-
break
166+
break;
166167
}
167168
}
168169
let mut ooo_compacted_blocks = vec![];
@@ -181,7 +182,10 @@ pub async fn download_and_pipeline_blocks(
181182
let _ = blocks_tx.send(PostProcessorCommand::Start);
182183
}
183184

184-
let _ = blocks_tx.send(PostProcessorCommand::ProcessBlocks(ooo_compacted_blocks, vec![]));
185+
let _ = blocks_tx.send(PostProcessorCommand::ProcessBlocks(
186+
ooo_compacted_blocks,
187+
vec![],
188+
));
185189
}
186190
}
187191

@@ -206,14 +210,17 @@ pub async fn download_and_pipeline_blocks(
206210
post_seq_processor_started = true;
207211
let _ = blocks_tx.send(PostProcessorCommand::Start);
208212
}
209-
let _ = blocks_tx.send(PostProcessorCommand::ProcessBlocks(compacted_blocks, blocks));
213+
let _ = blocks_tx.send(PostProcessorCommand::ProcessBlocks(
214+
compacted_blocks,
215+
blocks,
216+
));
210217
}
211218
} else {
212219
if blocks_processed == number_of_blocks_to_process {
213220
cloned_ctx.try_log(|logger| {
214221
info!(
215222
logger,
216-
"Local block storage successfully seeded with #{blocks_processed} blocks"
223+
"#{blocks_processed} blocks successfully sent to processor"
217224
)
218225
});
219226
break;

components/hord-cli/src/core/pipeline/processors/inscription_indexing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{
2-
sync::{Arc},
2+
sync::Arc,
33
thread::{sleep, JoinHandle},
44
time::Duration,
55
};
@@ -12,7 +12,7 @@ use chainhook_sdk::{
1212
},
1313
utils::Context,
1414
};
15-
use crossbeam_channel::{TryRecvError, Sender};
15+
use crossbeam_channel::{Sender, TryRecvError};
1616

1717
use dashmap::DashMap;
1818
use fxhash::FxHasher;

components/hord-cli/src/core/protocol/sequencing.rs

-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ pub fn update_storage_and_augment_bitcoin_block_with_inscription_transfer_data_t
443443
};
444444
for (tx_index, new_tx) in block.transactions.iter_mut().skip(1).enumerate() {
445445
for (input_index, input) in new_tx.metadata.inputs.iter().enumerate() {
446-
447446
let outpoint_pre_transfer = format_outpoint_to_watch(
448447
&input.previous_output.txid,
449448
input.previous_output.vout as usize,

components/hord-cli/src/db/mod.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -751,19 +751,25 @@ pub fn find_all_inscriptions_in_block(
751751
let inscription_id: String = row.get(2).unwrap();
752752
let (transaction_identifier_inscription, inscription_input_index) =
753753
{ parse_inscription_id(&inscription_id) };
754-
let transfer_data = transfers_data
754+
let Some(transfer_data) = transfers_data
755755
.get(&inscription_id)
756-
.unwrap()
757-
.first()
758-
.unwrap()
759-
.clone();
756+
.and_then(|entries| entries.first()) else {
757+
ctx.try_log(|logger| {
758+
error!(
759+
logger,
760+
"unable to retrieve inscription genesis transfer data: {}",
761+
inscription_id,
762+
)
763+
});
764+
continue;
765+
};
760766
let traversal = TraversalResult {
761767
inscription_number,
762768
ordinal_number,
763769
inscription_input_index,
764770
transfers: 0,
765771
transaction_identifier_inscription: transaction_identifier_inscription.clone(),
766-
transfer_data: transfer_data,
772+
transfer_data: transfer_data.clone(),
767773
};
768774
results.insert(
769775
(transaction_identifier_inscription, inscription_input_index),

components/hord-cli/src/service/mod.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,36 @@
11
mod http_api;
22
mod runloops;
33

4-
use crate::cli::fetch_and_standardize_block;
54
use crate::config::{Config, PredicatesApi, PredicatesApiConfig};
65
use crate::core::pipeline::processors::inscription_indexing::process_blocks;
76
use crate::core::pipeline::processors::start_inscription_indexing_processor;
87
use crate::core::pipeline::processors::transfers_recomputing::start_transfers_recomputing_processor;
98
use crate::core::pipeline::{download_and_pipeline_blocks, PostProcessorCommand};
10-
use crate::core::protocol::sequencing::update_storage_and_augment_bitcoin_block_with_inscription_transfer_data_tx;
119
use crate::core::{
1210
new_traversals_lazy_cache, parse_inscriptions_in_standardized_block,
1311
revert_hord_db_with_augmented_bitcoin_block, should_sync_hord_db,
1412
};
1513
use crate::db::{
16-
find_all_inscriptions_in_block, find_latest_inscription_block_height, format_satpoint_to_watch,
17-
insert_entry_in_blocks, insert_entry_in_locations, open_readonly_hord_db_conn,
18-
open_readwrite_hord_db_conn, open_readwrite_hord_dbs, parse_satpoint_to_watch,
19-
remove_entries_from_locations_at_block_height, InscriptionHeigthHint, LazyBlock, initialize_hord_db,
14+
find_latest_inscription_block_height, initialize_hord_db, insert_entry_in_blocks,
15+
open_readonly_hord_db_conn, open_readwrite_hord_dbs, InscriptionHeigthHint, LazyBlock,
2016
};
2117
use crate::scan::bitcoin::process_block_with_predicates;
2218
use crate::service::http_api::{load_predicates_from_redis, start_predicate_api_server};
2319
use crate::service::runloops::start_bitcoin_scan_runloop;
2420

25-
use chainhook_sdk::bitcoincore_rpc_json::bitcoin::hashes::hex::FromHex;
26-
use chainhook_sdk::bitcoincore_rpc_json::bitcoin::{Address, Network, Script};
2721
use chainhook_sdk::chainhooks::types::{
2822
BitcoinChainhookSpecification, ChainhookConfig, ChainhookFullSpecification,
2923
ChainhookSpecification,
3024
};
3125

32-
use chainhook_sdk::indexer::bitcoin::build_http_client;
3326
use chainhook_sdk::observer::{
34-
start_event_observer, BitcoinConfig, EventObserverConfig, HandleBlock, ObserverEvent,
35-
};
36-
use chainhook_sdk::types::{
37-
BitcoinBlockData, BitcoinNetwork, OrdinalInscriptionTransferData, OrdinalOperation,
27+
start_event_observer, EventObserverConfig, HandleBlock, ObserverEvent,
3828
};
29+
use chainhook_sdk::types::BitcoinBlockData;
3930
use chainhook_sdk::utils::Context;
4031
use crossbeam_channel::unbounded;
4132
use redis::{Commands, Connection};
4233

43-
use std::collections::BTreeMap;
4434
use std::sync::mpsc::{channel, Sender};
4535
use std::sync::Arc;
4636

@@ -126,7 +116,8 @@ impl Service {
126116
}
127117
};
128118

129-
self.replay_transfers(775808, tip, Some(tx_replayer.clone())).await?;
119+
self.replay_transfers(775808, tip, Some(tx_replayer.clone()))
120+
.await?;
130121
self.update_state(Some(tx_replayer.clone())).await?;
131122

132123
// Catch-up with chain tip

0 commit comments

Comments
 (0)