Skip to content

Commit dc623a0

Browse files
author
Ludo Galabru
committed
fix: address build warnings
1 parent d5de40e commit dc623a0

File tree

12 files changed

+67
-123
lines changed

12 files changed

+67
-123
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
308308
ConfigCommand::New(cmd) => {
309309
use std::fs::File;
310310
use std::io::Write;
311+
let _config = Config::default(cmd.devnet, cmd.testnet, cmd.mainnet, &None)?;
311312
let config_content = generate_config();
312313
let mut file_path = PathBuf::new();
313314
file_path.push("Chainhook.toml");

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use chainhook_event_observer::chainhooks::bitcoin::{
66
use chainhook_event_observer::chainhooks::types::{
77
BitcoinPredicateType, ChainhookConfig, ChainhookFullSpecification, OrdinalOperations, Protocols,
88
};
9-
use chainhook_event_observer::indexer::ordinals::{self, ord::initialize_ordinal_index};
10-
use chainhook_event_observer::indexer::{self, BitcoinChainContext};
9+
use chainhook_event_observer::indexer;
1110
use chainhook_event_observer::observer::{
1211
start_event_observer, ApiKey, EventObserverConfig, ObserverEvent,
1312
};
@@ -136,13 +135,13 @@ impl Node {
136135
"Listening for chainhook predicate registrations on port {}", DEFAULT_CONTROL_PORT
137136
);
138137

139-
let ordinal_index = match initialize_ordinal_index(&event_observer_config, None, &self.ctx)
140-
{
141-
Ok(index) => index,
142-
Err(e) => {
143-
panic!()
144-
}
145-
};
138+
// let ordinal_index = match initialize_ordinal_index(&event_observer_config, None, &self.ctx)
139+
// {
140+
// Ok(index) => index,
141+
// Err(e) => {
142+
// panic!()
143+
// }
144+
// };
146145

147146
let context_cloned = self.ctx.clone();
148147
let event_observer_config_moved = event_observer_config.clone();

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use chainhook_event_observer::chainhooks::types::{
99
BitcoinChainhookFullSpecification, BitcoinPredicateType, HookAction, OrdinalOperations,
1010
Protocols,
1111
};
12+
use chainhook_event_observer::indexer;
1213
use chainhook_event_observer::indexer::bitcoin::{
1314
retrieve_block_hash, retrieve_full_block_breakdown_with_retry,
1415
};
@@ -22,9 +23,8 @@ use chainhook_event_observer::indexer::ordinals::ord::indexing::{
2223
};
2324
use chainhook_event_observer::indexer::ordinals::ord::initialize_ordinal_index;
2425
use chainhook_event_observer::indexer::ordinals::ord::inscription_id::InscriptionId;
25-
use chainhook_event_observer::indexer::{self, BitcoinChainContext};
2626
use chainhook_event_observer::observer::{
27-
BitcoinConfig, EventObserverConfig, DEFAULT_CONTROL_PORT, DEFAULT_INGESTION_PORT,
27+
EventObserverConfig, DEFAULT_CONTROL_PORT, DEFAULT_INGESTION_PORT,
2828
};
2929
use chainhook_event_observer::redb::ReadableTable;
3030
use chainhook_event_observer::utils::{file_append, send_request, Context};
@@ -348,9 +348,9 @@ pub async fn scan_bitcoin_chain_with_predicate(
348348

349349
if pipeline_started {
350350
let _ = retrieve_ordinal_tx.send(None);
351-
handle_3.join();
352-
handle_1.join();
353-
handle_2.join();
351+
let _ = handle_3.join();
352+
let _ = handle_1.join();
353+
let _ = handle_2.join();
354354
}
355355

356356
Ok(())

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

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{
2-
collections::{HashMap, HashSet, VecDeque},
2+
collections::{HashMap, VecDeque},
33
process,
44
};
55

@@ -12,7 +12,6 @@ use chainhook_event_observer::{
1212
chainhooks::stacks::{
1313
handle_stacks_hook_action, StacksChainhookOccurrence, StacksTriggerChainhook,
1414
},
15-
observer::{EventObserverConfig, DEFAULT_CONTROL_PORT, DEFAULT_INGESTION_PORT},
1615
utils::{file_append, send_request, AbstractStacksBlock},
1716
};
1817
use chainhook_event_observer::{
@@ -83,26 +82,6 @@ pub async fn scan_stacks_chain_with_predicate(
8382
let _ = record_tx.send(None);
8483
});
8584

86-
let event_observer_config = EventObserverConfig {
87-
normalization_enabled: true,
88-
grpc_server_enabled: false,
89-
hooks_enabled: true,
90-
bitcoin_rpc_proxy_enabled: true,
91-
event_handlers: vec![],
92-
chainhook_config: None,
93-
ingestion_port: DEFAULT_INGESTION_PORT,
94-
control_port: DEFAULT_CONTROL_PORT,
95-
bitcoin_node_username: config.network.bitcoin_node_rpc_username.clone(),
96-
bitcoin_node_password: config.network.bitcoin_node_rpc_password.clone(),
97-
bitcoin_node_rpc_url: config.network.bitcoin_node_rpc_url.clone(),
98-
stacks_node_rpc_url: config.network.stacks_node_rpc_url.clone(),
99-
operators: HashSet::new(),
100-
display_logs: false,
101-
cache_path: config.storage.cache_path.clone(),
102-
bitcoin_network: config.network.bitcoin_network.clone(),
103-
stacks_network: config.network.stacks_network.clone(),
104-
};
105-
10685
let mut indexer = Indexer::new(config.network.clone());
10786

10887
let mut canonical_fork = {

components/chainhook-event-observer/src/chainhooks/bitcoin/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl BitcoinPredicateType {
259259
pub fn evaluate_transaction_predicate(
260260
&self,
261261
tx: &BitcoinTransactionData,
262-
ctx: &Context,
262+
_ctx: &Context,
263263
) -> bool {
264264
// TODO(lgalabru): follow-up on this implementation
265265
match &self {

components/chainhook-event-observer/src/indexer/bitcoin/mod.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,9 @@ pub fn standardize_bitcoin_block(
265265
ctx.try_log(|logger| slog::debug!(logger, "Standardizing Bitcoin transaction {txid}"));
266266

267267
let mut stacks_operations = vec![];
268-
if let Some(op) = try_parse_stacks_operation(
269-
&tx.vout,
270-
&pox_config,
271-
&expected_magic_bytes,
272-
block_height,
273-
ctx,
274-
) {
268+
if let Some(op) =
269+
try_parse_stacks_operation(&tx.vout, &pox_config, &expected_magic_bytes, ctx)
270+
{
275271
stacks_operations.push(op);
276272
}
277273

@@ -370,7 +366,7 @@ pub fn standardize_bitcoin_block(
370366
fn try_parse_ordinal_operation(
371367
tx: &BitcoinTransactionFullBreakdown,
372368
_block_height: u64,
373-
ctx: &Context,
369+
_ctx: &Context,
374370
) -> Option<OrdinalOperation> {
375371
for input in tx.vin.iter() {
376372
if let Some(ref witnesses) = input.txinwitness {
@@ -433,7 +429,6 @@ fn try_parse_stacks_operation(
433429
outputs: &Vec<BitcoinTransactionOutputFullBreakdown>,
434430
pox_config: &PoxConfig,
435431
expected_magic_bytes: &[u8; 2],
436-
block_height: u64,
437432
ctx: &Context,
438433
) -> Option<StacksBaseChainOperation> {
439434
if outputs.is_empty() {

components/chainhook-event-observer/src/indexer/ordinals/db/mod.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ pub fn update_transfered_inscription(
287287

288288
pub fn find_last_inscription_number(
289289
storage_conn: &Connection,
290-
ctx: &Context,
290+
_ctx: &Context,
291291
) -> Result<u64, String> {
292292
let args: &[&dyn ToSql] = &[];
293293
let mut stmt = storage_conn
@@ -306,7 +306,7 @@ pub fn find_last_inscription_number(
306306
pub fn find_inscription_with_ordinal_number(
307307
ordinal_number: &u64,
308308
storage_conn: &Connection,
309-
ctx: &Context,
309+
_ctx: &Context,
310310
) -> Option<String> {
311311
let args: &[&dyn ToSql] = &[&ordinal_number.to_sql().unwrap()];
312312
let mut stmt = storage_conn
@@ -375,6 +375,7 @@ pub async fn build_bitcoin_traversal_local_storage(
375375
let block_height = block_cursor.clone();
376376
let block_hash_tx = block_hash_tx.clone();
377377
let config = bitcoin_config.clone();
378+
let moved_ctx = ctx.clone();
378379
retrieve_block_hash_pool.execute(move || {
379380
let mut err_count = 0;
380381
let mut rng = rand::thread_rng();
@@ -386,6 +387,9 @@ pub async fn build_bitcoin_traversal_local_storage(
386387
break;
387388
}
388389
Err(e) => {
390+
moved_ctx.try_log(|logger| {
391+
slog::error!(logger, "unable to retrieve block_hash: #{}", e)
392+
});
389393
err_count += 1;
390394
let delay = (err_count + (rng.next_u64() % 3)) * 1000;
391395
std::thread::sleep(std::time::Duration::from_millis(delay));
@@ -398,7 +402,7 @@ pub async fn build_bitcoin_traversal_local_storage(
398402
let bitcoin_config = bitcoin_config.clone();
399403
let moved_ctx = ctx.clone();
400404
let block_data_tx_moved = block_data_tx.clone();
401-
let handle_1 = hiro_system_kit::thread_named("Block data retrieval")
405+
let _ = hiro_system_kit::thread_named("Block data retrieval")
402406
.spawn(move || {
403407
while let Ok(Some((block_height, block_hash))) = block_hash_rx.recv() {
404408
let moved_bitcoin_config = bitcoin_config.clone();
@@ -421,7 +425,7 @@ pub async fn build_bitcoin_traversal_local_storage(
421425
})
422426
.expect("unable to spawn thread");
423427

424-
let handle_2 = hiro_system_kit::thread_named("Block data compression")
428+
let _ = hiro_system_kit::thread_named("Block data compression")
425429
.spawn(move || {
426430
while let Ok(Some(block_data)) = block_data_rx.recv() {
427431
let block_compressed_tx_moved = block_compressed_tx.clone();
@@ -432,7 +436,6 @@ pub async fn build_bitcoin_traversal_local_storage(
432436
});
433437

434438
let res = compress_block_data_pool.join();
435-
// let _ = block_compressed_tx.send(None);
436439
res
437440
}
438441
})

components/chainhook-event-observer/src/indexer/ordinals/inscription.rs

-47
Original file line numberDiff line numberDiff line change
@@ -30,57 +30,10 @@ impl Inscription {
3030
InscriptionParser::parse(&tx.input.get(0)?.witness).ok()
3131
}
3232

33-
fn append_reveal_script_to_builder(&self, mut builder: script::Builder) -> script::Builder {
34-
builder = builder
35-
.push_opcode(opcodes::OP_FALSE)
36-
.push_opcode(opcodes::all::OP_IF)
37-
.push_slice(PROTOCOL_ID);
38-
39-
if let Some(content_type) = &self.content_type {
40-
builder = builder
41-
.push_slice(CONTENT_TYPE_TAG)
42-
.push_slice(content_type);
43-
}
44-
45-
if let Some(body) = &self.body {
46-
builder = builder.push_slice(BODY_TAG);
47-
for chunk in body.chunks(520) {
48-
builder = builder.push_slice(chunk);
49-
}
50-
}
51-
52-
builder.push_opcode(opcodes::all::OP_ENDIF)
53-
}
54-
55-
pub(crate) fn append_reveal_script(&self, builder: script::Builder) -> Script {
56-
self.append_reveal_script_to_builder(builder).into_script()
57-
}
58-
59-
pub(crate) fn media(&self) -> Media {
60-
if self.body.is_none() {
61-
return Media::Unknown;
62-
}
63-
64-
let content_type = match self.content_type() {
65-
Some(content_type) => content_type,
66-
None => return Media::Unknown,
67-
};
68-
69-
content_type.parse().unwrap_or(Media::Unknown)
70-
}
71-
7233
pub(crate) fn body(&self) -> Option<&[u8]> {
7334
Some(self.body.as_ref()?)
7435
}
7536

76-
pub(crate) fn into_body(self) -> Option<Vec<u8>> {
77-
self.body
78-
}
79-
80-
pub(crate) fn content_length(&self) -> Option<usize> {
81-
Some(self.body()?.len())
82-
}
83-
8437
pub(crate) fn content_type(&self) -> Option<&str> {
8538
str::from_utf8(self.content_type.as_ref()?).ok()
8639
}

components/chainhook-event-observer/src/indexer/ordinals/ord/indexing/updater.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ impl OrdinalIndexUpdater {
224224
}
225225

226226
fn get_block_with_retries(
227-
client: &Client,
228-
height: u64,
229-
ctx: &Context,
227+
_client: &Client,
228+
_height: u64,
229+
_ctx: &Context,
230230
) -> Result<Option<BlockData>> {
231231
return Ok(None);
232232
}
@@ -278,7 +278,7 @@ impl OrdinalIndexUpdater {
278278
}
279279
let txs = match try_join_all(futs).await {
280280
Ok(txs) => txs,
281-
Err(e) => {
281+
Err(_e) => {
282282
// log::error!("Couldn't receive txs {e}");
283283
return;
284284
}
@@ -300,7 +300,7 @@ impl OrdinalIndexUpdater {
300300
async fn index_block(
301301
&mut self,
302302
index: &OrdinalIndex,
303-
outpoint_sender: &mut Sender<OutPoint>,
303+
_outpoint_sender: &mut Sender<OutPoint>,
304304
value_receiver: &mut Receiver<u64>,
305305
wtx: &mut WriteTransaction<'_>,
306306
block: BlockData,
@@ -317,7 +317,7 @@ impl OrdinalIndexUpdater {
317317

318318
let mut height_to_block_hash = wtx.open_table(HEIGHT_TO_BLOCK_HASH)?;
319319

320-
let start = Instant::now();
320+
let _start = Instant::now();
321321
let mut sat_ranges_written = 0;
322322
let mut outputs_in_block = 0;
323323

@@ -382,7 +382,7 @@ impl OrdinalIndexUpdater {
382382
self.sat_ranges_since_flush += 1;
383383
}
384384

385-
for (tx_offset, (tx, txid)) in block.txdata.iter().enumerate().skip(1) {
385+
for (_tx_offset, (tx, txid)) in block.txdata.iter().enumerate().skip(1) {
386386
let mut input_sat_ranges = VecDeque::new();
387387

388388
for input in &tx.input {

components/chainhook-event-observer/src/indexer/ordinals/ord/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![allow(dead_code)]
2+
#![allow(unused_variables)]
3+
14
use hiro_system_kit::slog;
25
use std::{path::PathBuf, time::Duration};
36

components/chainhook-event-observer/src/indexer/stacks/blocks_pool.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,10 @@ impl StacksBlockPool {
621621
ctx,
622622
) {
623623
Ok(res) => res,
624-
Err(e) => None,
624+
Err(e) => {
625+
ctx.try_log(|logger| slog::error!(logger, "Unable to detect convergence: {:?}", e));
626+
None
627+
}
625628
};
626629

627630
Ok(chain_event)

0 commit comments

Comments
 (0)