Skip to content

Commit 83f1496

Browse files
author
Ludo Galabru
committed
fix: build failing
1 parent 6ebeb77 commit 83f1496

File tree

10 files changed

+169
-123
lines changed

10 files changed

+169
-123
lines changed

Cargo.lock

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/hord-cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ redis = "0.21.5"
1414
serde-redis = "0.12.0"
1515
hex = "0.4.3"
1616
rand = "0.8.5"
17-
chainhook-sdk = { version = "0.5.0", default-features = false, features = ["ordinals", "zeromq"], path = "../../../chainhook/components/chainhook-sdk" }
17+
chainhook-sdk = { version = "0.5.0", default-features = false, features = ["zeromq"], path = "../../../chainhook/components/chainhook-sdk" }
1818
chainhook-types = { version = "1.0.6", path = "../../../chainhook/components/chainhook-types-rs" }
1919
clarinet-files = "1.0.1"
2020
hiro-system-kit = "0.1.0"

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

+12-60
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
11
use crate::config::generator::generate_config;
22
use crate::config::{Config, PredicatesApi};
3-
use crate::scan::bitcoin::scan_bitcoin_chainstate_via_rpc_using_predicate;
43
use crate::service::Service;
5-
use crate::storage::get_last_block_height_inserted;
64

7-
use chainhook_sdk::chainhooks::types::ChainhookFullSpecification;
8-
use chainhook_sdk::hord::db::{
5+
use crate::db::{
96
delete_data_in_hord_db, find_last_block_inserted, find_lazy_block_at_block_height,
107
find_watched_satpoint_for_inscription, initialize_hord_db, open_readonly_hord_db_conn,
118
open_readonly_hord_db_conn_rocks_db, open_readwrite_hord_db_conn,
129
open_readwrite_hord_db_conn_rocks_db, retrieve_satoshi_point_using_lazy_storage,
1310
};
14-
use chainhook_sdk::hord::{
11+
use crate::hord::{
1512
new_traversals_lazy_cache, retrieve_inscribed_satoshi_points_from_block,
1613
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data, Storage,
1714
};
15+
use chainhook_sdk::chainhooks::types::ChainhookFullSpecification;
1816
use chainhook_sdk::indexer;
1917
use chainhook_sdk::indexer::bitcoin::{
2018
download_and_parse_block_with_retry, retrieve_block_hash_with_retry,
2119
};
2220
use chainhook_sdk::observer::BitcoinConfig;
2321
use chainhook_sdk::utils::Context;
24-
use chainhook_types::{BitcoinBlockData, BitcoinNetwork, BlockIdentifier, TransactionIdentifier};
22+
use chainhook_types::{BitcoinBlockData, BlockIdentifier, TransactionIdentifier};
2523
use clap::{Parser, Subcommand};
26-
use ctrlc;
2724
use hiro_system_kit;
2825
use std::collections::BTreeMap;
2926
use std::io::{BufReader, Read};
3027
use std::path::PathBuf;
3128
use std::process;
32-
use std::sync::mpsc::Sender;
3329
use std::sync::Arc;
3430

3531
#[derive(Parser, Debug)]
@@ -153,26 +149,6 @@ enum HordDbCommand {
153149
Check(CheckDbCommand),
154150
}
155151

156-
#[derive(Subcommand, PartialEq, Clone, Debug)]
157-
enum StacksCommand {
158-
/// Db maintenance related commands
159-
#[clap(subcommand)]
160-
Db(StacksDbCommand),
161-
}
162-
163-
#[derive(Subcommand, PartialEq, Clone, Debug)]
164-
enum StacksDbCommand {
165-
/// Check integrity
166-
#[clap(name = "check", bin_name = "check")]
167-
Check(CheckDbCommand),
168-
/// Update database using latest Stacks archive file
169-
#[clap(name = "update", bin_name = "update")]
170-
Update(UpdateDbCommand),
171-
/// Retrieve a block from the Stacks db
172-
#[clap(name = "get", bin_name = "get")]
173-
GetBlock(GetBlockDbCommand),
174-
}
175-
176152
#[derive(Subcommand, PartialEq, Clone, Debug)]
177153
enum ScanCommand {
178154
/// Compute ordinal number of the 1st satoshi of the 1st input of a given transaction
@@ -307,30 +283,6 @@ struct CheckDbCommand {
307283
pub config_path: Option<String>,
308284
}
309285

310-
#[derive(Parser, PartialEq, Clone, Debug)]
311-
struct UpdateDbCommand {
312-
/// Load config file path
313-
#[clap(long = "config-path")]
314-
pub config_path: Option<String>,
315-
}
316-
317-
#[derive(Parser, PartialEq, Clone, Debug)]
318-
struct GetBlockDbCommand {
319-
/// Block index to retrieve
320-
#[clap(long = "block-height")]
321-
pub block_height: u64,
322-
/// Load config file path
323-
#[clap(long = "config-path")]
324-
pub config_path: Option<String>,
325-
}
326-
327-
#[derive(Parser, PartialEq, Clone, Debug)]
328-
struct InitHordDbCommand {
329-
/// Load config file path
330-
#[clap(long = "config-path")]
331-
pub config_path: Option<String>,
332-
}
333-
334286
pub fn main() {
335287
let logger = hiro_system_kit::log::setup_logger();
336288
let _guard = hiro_system_kit::log::setup_global_logger(logger.clone());
@@ -444,6 +396,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
444396
}
445397
None => {
446398
let event_observer_config = config.get_event_observer_config();
399+
let hord_config = config.get_hord_config();
447400
let bitcoin_config = event_observer_config.get_bitcoin_config();
448401
let block =
449402
fetch_and_standardize_block(cmd.block_height, &bitcoin_config, &ctx)
@@ -453,7 +406,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
453406
let _traversals = retrieve_inscribed_satoshi_points_from_block(
454407
&block,
455408
None,
456-
event_observer_config.hord_config.as_ref().unwrap(),
409+
&hord_config,
457410
&traversals_cache,
458411
&ctx,
459412
);
@@ -621,13 +574,12 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
621574
"Cleaning hord_db: {} blocks dropped",
622575
cmd.end_block - cmd.start_block + 1
623576
);
624-
}
625-
// HordDbCommand::Patch(_cmd) => {
626-
// unimplemented!()
627-
// }
628-
// HordDbCommand::Migrate(_cmd) => {
629-
// unimplemented!()
630-
// }
577+
} // HordDbCommand::Patch(_cmd) => {
578+
// unimplemented!()
579+
// }
580+
// HordDbCommand::Migrate(_cmd) => {
581+
// unimplemented!()
582+
// }
631583
}
632584
Ok(())
633585
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ impl Config {
136136
cache_path: self.storage.working_dir.clone(),
137137
bitcoin_network: self.network.bitcoin_network.clone(),
138138
stacks_network: self.network.stacks_network.clone(),
139-
hord_config: None,
140139
}
141140
}
142141

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

+17
Original file line numberDiff line numberDiff line change
@@ -977,3 +977,20 @@ fn test_identify_next_output_index_destination() {
977977
SatPosition::Fee(0)
978978
);
979979
}
980+
981+
#[test]
982+
fn test_ordinal_inscription_parsing() {
983+
let bytes = hex::decode("208737bc46923c3e64c7e6768c0346879468bf3aba795a5f5f56efca288f50ed2aac0063036f7264010118746578742f706c61696e3b636861727365743d7574662d38004c9948656c6c6f2030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030300a68").unwrap();
984+
985+
let script = Script::from(bytes);
986+
let parser = InscriptionParser {
987+
instructions: script.instructions().peekable(),
988+
};
989+
990+
let inscription = match parser.parse_script() {
991+
Ok(inscription) => inscription,
992+
Err(_) => panic!(),
993+
};
994+
995+
println!("{:?}", inscription);
996+
}

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use std::{
2-
collections::HashMap,
3-
sync::mpsc::{channel, Sender},
4-
};
1+
use std::sync::mpsc::{channel, Sender};
52

63
use super::HordConfig;
74

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
use crate::archive::download_ordinals_dataset_if_required;
22
use crate::config::{Config, PredicatesApi};
3+
use crate::db::{
4+
find_all_inscriptions_in_block, get_any_entry_in_ordinal_activities, open_readonly_hord_db_conn,
5+
};
6+
use crate::hord::{
7+
get_inscriptions_revealed_in_block,
8+
update_storage_and_augment_bitcoin_block_with_inscription_reveal_data,
9+
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data, Storage,
10+
};
311
use crate::service::{
412
open_readwrite_predicates_db_conn_or_panic, update_predicate_status, PredicateStatus,
513
ScanningData,
@@ -11,14 +19,6 @@ use chainhook_sdk::chainhooks::bitcoin::{
1119
BitcoinChainhookOccurrence, BitcoinTriggerChainhook,
1220
};
1321
use chainhook_sdk::chainhooks::types::{BitcoinChainhookSpecification, BitcoinPredicateType};
14-
use chainhook_sdk::hord::db::{
15-
find_all_inscriptions_in_block, get_any_entry_in_ordinal_activities, open_readonly_hord_db_conn,
16-
};
17-
use chainhook_sdk::hord::{
18-
get_inscriptions_revealed_in_block,
19-
update_storage_and_augment_bitcoin_block_with_inscription_reveal_data,
20-
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data, Storage,
21-
};
2222
use chainhook_sdk::indexer;
2323
use chainhook_sdk::indexer::bitcoin::{
2424
download_and_parse_block_with_retry, retrieve_block_hash_with_retry,
@@ -88,7 +88,7 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(
8888

8989
let mut blocks_scanned = 0;
9090
let mut actions_triggered = 0;
91-
let mut occurrences_found = 0u64;
91+
let occurrences_found = 0u64;
9292
let mut err_count = 0;
9393

9494
let event_observer_config = config.get_event_observer_config();

0 commit comments

Comments
 (0)