Skip to content

Commit

Permalink
fix: build failing
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalabru committed Jul 5, 2023
1 parent 6ebeb77 commit 83f1496
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 123 deletions.
4 changes: 0 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/hord-cli/Cargo.toml
Expand Up @@ -14,7 +14,7 @@ redis = "0.21.5"
serde-redis = "0.12.0"
hex = "0.4.3"
rand = "0.8.5"
chainhook-sdk = { version = "0.5.0", default-features = false, features = ["ordinals", "zeromq"], path = "../../../chainhook/components/chainhook-sdk" }
chainhook-sdk = { version = "0.5.0", default-features = false, features = ["zeromq"], path = "../../../chainhook/components/chainhook-sdk" }
chainhook-types = { version = "1.0.6", path = "../../../chainhook/components/chainhook-types-rs" }
clarinet-files = "1.0.1"
hiro-system-kit = "0.1.0"
Expand Down
72 changes: 12 additions & 60 deletions components/hord-cli/src/cli/mod.rs
@@ -1,35 +1,31 @@
use crate::config::generator::generate_config;
use crate::config::{Config, PredicatesApi};
use crate::scan::bitcoin::scan_bitcoin_chainstate_via_rpc_using_predicate;
use crate::service::Service;
use crate::storage::get_last_block_height_inserted;

use chainhook_sdk::chainhooks::types::ChainhookFullSpecification;
use chainhook_sdk::hord::db::{
use crate::db::{
delete_data_in_hord_db, find_last_block_inserted, find_lazy_block_at_block_height,
find_watched_satpoint_for_inscription, initialize_hord_db, open_readonly_hord_db_conn,
open_readonly_hord_db_conn_rocks_db, open_readwrite_hord_db_conn,
open_readwrite_hord_db_conn_rocks_db, retrieve_satoshi_point_using_lazy_storage,
};
use chainhook_sdk::hord::{
use crate::hord::{
new_traversals_lazy_cache, retrieve_inscribed_satoshi_points_from_block,
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data, Storage,
};
use chainhook_sdk::chainhooks::types::ChainhookFullSpecification;
use chainhook_sdk::indexer;
use chainhook_sdk::indexer::bitcoin::{
download_and_parse_block_with_retry, retrieve_block_hash_with_retry,
};
use chainhook_sdk::observer::BitcoinConfig;
use chainhook_sdk::utils::Context;
use chainhook_types::{BitcoinBlockData, BitcoinNetwork, BlockIdentifier, TransactionIdentifier};
use chainhook_types::{BitcoinBlockData, BlockIdentifier, TransactionIdentifier};
use clap::{Parser, Subcommand};
use ctrlc;
use hiro_system_kit;
use std::collections::BTreeMap;
use std::io::{BufReader, Read};
use std::path::PathBuf;
use std::process;
use std::sync::mpsc::Sender;
use std::sync::Arc;

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -153,26 +149,6 @@ enum HordDbCommand {
Check(CheckDbCommand),
}

#[derive(Subcommand, PartialEq, Clone, Debug)]
enum StacksCommand {
/// Db maintenance related commands
#[clap(subcommand)]
Db(StacksDbCommand),
}

#[derive(Subcommand, PartialEq, Clone, Debug)]
enum StacksDbCommand {
/// Check integrity
#[clap(name = "check", bin_name = "check")]
Check(CheckDbCommand),
/// Update database using latest Stacks archive file
#[clap(name = "update", bin_name = "update")]
Update(UpdateDbCommand),
/// Retrieve a block from the Stacks db
#[clap(name = "get", bin_name = "get")]
GetBlock(GetBlockDbCommand),
}

#[derive(Subcommand, PartialEq, Clone, Debug)]
enum ScanCommand {
/// Compute ordinal number of the 1st satoshi of the 1st input of a given transaction
Expand Down Expand Up @@ -307,30 +283,6 @@ struct CheckDbCommand {
pub config_path: Option<String>,
}

#[derive(Parser, PartialEq, Clone, Debug)]
struct UpdateDbCommand {
/// Load config file path
#[clap(long = "config-path")]
pub config_path: Option<String>,
}

#[derive(Parser, PartialEq, Clone, Debug)]
struct GetBlockDbCommand {
/// Block index to retrieve
#[clap(long = "block-height")]
pub block_height: u64,
/// Load config file path
#[clap(long = "config-path")]
pub config_path: Option<String>,
}

#[derive(Parser, PartialEq, Clone, Debug)]
struct InitHordDbCommand {
/// Load config file path
#[clap(long = "config-path")]
pub config_path: Option<String>,
}

pub fn main() {
let logger = hiro_system_kit::log::setup_logger();
let _guard = hiro_system_kit::log::setup_global_logger(logger.clone());
Expand Down Expand Up @@ -444,6 +396,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
}
None => {
let event_observer_config = config.get_event_observer_config();
let hord_config = config.get_hord_config();
let bitcoin_config = event_observer_config.get_bitcoin_config();
let block =
fetch_and_standardize_block(cmd.block_height, &bitcoin_config, &ctx)
Expand All @@ -453,7 +406,7 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
let _traversals = retrieve_inscribed_satoshi_points_from_block(
&block,
None,
event_observer_config.hord_config.as_ref().unwrap(),
&hord_config,
&traversals_cache,
&ctx,
);
Expand Down Expand Up @@ -621,13 +574,12 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
"Cleaning hord_db: {} blocks dropped",
cmd.end_block - cmd.start_block + 1
);
}
// HordDbCommand::Patch(_cmd) => {
// unimplemented!()
// }
// HordDbCommand::Migrate(_cmd) => {
// unimplemented!()
// }
} // HordDbCommand::Patch(_cmd) => {
// unimplemented!()
// }
// HordDbCommand::Migrate(_cmd) => {
// unimplemented!()
// }
}
Ok(())
}
Expand Down
1 change: 0 additions & 1 deletion components/hord-cli/src/config/mod.rs
Expand Up @@ -136,7 +136,6 @@ impl Config {
cache_path: self.storage.working_dir.clone(),
bitcoin_network: self.network.bitcoin_network.clone(),
stacks_network: self.network.stacks_network.clone(),
hord_config: None,
}
}

Expand Down
17 changes: 17 additions & 0 deletions components/hord-cli/src/hord/mod.rs
Expand Up @@ -977,3 +977,20 @@ fn test_identify_next_output_index_destination() {
SatPosition::Fee(0)
);
}

#[test]
fn test_ordinal_inscription_parsing() {
let bytes = hex::decode("208737bc46923c3e64c7e6768c0346879468bf3aba795a5f5f56efca288f50ed2aac0063036f7264010118746578742f706c61696e3b636861727365743d7574662d38004c9948656c6c6f2030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030300a68").unwrap();

let script = Script::from(bytes);
let parser = InscriptionParser {
instructions: script.instructions().peekable(),
};

let inscription = match parser.parse_script() {
Ok(inscription) => inscription,
Err(_) => panic!(),
};

println!("{:?}", inscription);
}
5 changes: 1 addition & 4 deletions components/hord-cli/src/hord/ordinals.rs
@@ -1,7 +1,4 @@
use std::{
collections::HashMap,
sync::mpsc::{channel, Sender},
};
use std::sync::mpsc::{channel, Sender};

use super::HordConfig;

Expand Down
18 changes: 9 additions & 9 deletions components/hord-cli/src/scan/bitcoin.rs
@@ -1,5 +1,13 @@
use crate::archive::download_ordinals_dataset_if_required;
use crate::config::{Config, PredicatesApi};
use crate::db::{
find_all_inscriptions_in_block, get_any_entry_in_ordinal_activities, open_readonly_hord_db_conn,
};
use crate::hord::{
get_inscriptions_revealed_in_block,
update_storage_and_augment_bitcoin_block_with_inscription_reveal_data,
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data, Storage,
};
use crate::service::{
open_readwrite_predicates_db_conn_or_panic, update_predicate_status, PredicateStatus,
ScanningData,
Expand All @@ -11,14 +19,6 @@ use chainhook_sdk::chainhooks::bitcoin::{
BitcoinChainhookOccurrence, BitcoinTriggerChainhook,
};
use chainhook_sdk::chainhooks::types::{BitcoinChainhookSpecification, BitcoinPredicateType};
use chainhook_sdk::hord::db::{
find_all_inscriptions_in_block, get_any_entry_in_ordinal_activities, open_readonly_hord_db_conn,
};
use chainhook_sdk::hord::{
get_inscriptions_revealed_in_block,
update_storage_and_augment_bitcoin_block_with_inscription_reveal_data,
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data, Storage,
};
use chainhook_sdk::indexer;
use chainhook_sdk::indexer::bitcoin::{
download_and_parse_block_with_retry, retrieve_block_hash_with_retry,
Expand Down Expand Up @@ -88,7 +88,7 @@ pub async fn scan_bitcoin_chainstate_via_rpc_using_predicate(

let mut blocks_scanned = 0;
let mut actions_triggered = 0;
let mut occurrences_found = 0u64;
let occurrences_found = 0u64;
let mut err_count = 0;

let event_observer_config = config.get_event_observer_config();
Expand Down

0 comments on commit 83f1496

Please sign in to comment.