mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-01-12 08:34:17 +08:00
refactor: chainhook_event_observer to chainhook_sdk
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -466,7 +466,7 @@ version = "0.14.0"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"chainhook-event-observer",
|
||||
"chainhook-sdk",
|
||||
"chainhook-types 1.0.3",
|
||||
"clap 3.2.23",
|
||||
"clap_generate",
|
||||
@@ -499,7 +499,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chainhook-event-observer"
|
||||
name = "chainhook-sdk"
|
||||
version = "1.0.7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"components/chainhook-event-observer",
|
||||
"components/chainhook-sdk",
|
||||
"components/chainhook-cli",
|
||||
"components/chainhook-types-rs",
|
||||
]
|
||||
default-members = ["components/chainhook-cli", "components/chainhook-event-observer"]
|
||||
default-members = ["components/chainhook-cli", "components/chainhook-sdk"]
|
||||
|
||||
@@ -17,7 +17,7 @@ hex = "0.4.3"
|
||||
rand = "0.8.5"
|
||||
# tikv-client = { git = "https://github.com/tikv/client-rust.git", rev = "8f54e6114227718e256027df2577bbacdf425f86" }
|
||||
# raft-proto = { git = "https://github.com/tikv/raft-rs", rev="f73766712a538c2f6eb135b455297ad6c03fc58d", version = "0.7.0"}
|
||||
chainhook-event-observer = { version = "=1.0.7", default-features = false, features = ["ordinals", "zeromq"], path = "../chainhook-event-observer" }
|
||||
chainhook-sdk = { version = "=1.0.7", default-features = false, features = ["ordinals", "zeromq"], path = "../chainhook-sdk" }
|
||||
chainhook-types = { version = "=1.0.3", path = "../chainhook-types-rs" }
|
||||
clarinet-files = "1"
|
||||
hiro-system-kit = "0.1.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use chainhook_event_indexer::ingestion::start_ingesting;
|
||||
use chainhook_event_observer::indexer::IndexerConfig;
|
||||
use chainhook_sdk::indexer::IndexerConfig;
|
||||
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::config::Config;
|
||||
use chainhook_event_observer::utils::Context;
|
||||
use chainhook_sdk::utils::Context;
|
||||
use chainhook_types::{BitcoinNetwork, StacksNetwork};
|
||||
use clarinet_files::FileLocation;
|
||||
use flate2::read::GzDecoder;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::DigestingCommand;
|
||||
use crate::config::Config;
|
||||
use chainhook_event_observer::indexer;
|
||||
use chainhook_event_observer::indexer::Indexer;
|
||||
use chainhook_event_observer::utils::Context;
|
||||
use chainhook_sdk::indexer;
|
||||
use chainhook_sdk::indexer::Indexer;
|
||||
use chainhook_sdk::utils::Context;
|
||||
use redis::Commands;
|
||||
use std::cmp::Ordering;
|
||||
use std::{collections::BinaryHeap, process, sync::mpsc::Receiver};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::config::Config;
|
||||
use chainhook_event_observer::indexer::{self, Indexer};
|
||||
use chainhook_event_observer::utils::Context;
|
||||
use chainhook_sdk::indexer::{self, Indexer};
|
||||
use chainhook_sdk::utils::Context;
|
||||
use chainhook_types::BlockIdentifier;
|
||||
use redis::Commands;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -5,29 +5,29 @@ use crate::scan::bitcoin::scan_bitcoin_chainstate_via_rpc_using_predicate;
|
||||
use crate::scan::stacks::scan_stacks_chainstate_via_csv_using_predicate;
|
||||
use crate::service::Service;
|
||||
|
||||
use chainhook_event_observer::bitcoincore_rpc::{Auth, Client, RpcApi};
|
||||
use chainhook_event_observer::chainhooks::types::{
|
||||
use chainhook_sdk::bitcoincore_rpc::{Auth, Client, RpcApi};
|
||||
use chainhook_sdk::chainhooks::types::{
|
||||
BitcoinChainhookFullSpecification, BitcoinChainhookNetworkSpecification, BitcoinPredicateType,
|
||||
ChainhookFullSpecification, FileHook, HookAction, OrdinalOperations,
|
||||
StacksChainhookFullSpecification, StacksChainhookNetworkSpecification, StacksPredicate,
|
||||
StacksPrintEventBasedPredicate,
|
||||
};
|
||||
use chainhook_event_observer::hord::db::{
|
||||
use chainhook_sdk::hord::db::{
|
||||
delete_data_in_hord_db, fetch_and_cache_blocks_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_event_observer::hord::{
|
||||
use chainhook_sdk::hord::{
|
||||
new_traversals_lazy_cache, retrieve_inscribed_satoshi_points_from_block,
|
||||
update_storage_and_augment_bitcoin_block_with_inscription_transfer_data, HordConfig, Storage,
|
||||
};
|
||||
use chainhook_event_observer::indexer;
|
||||
use chainhook_event_observer::indexer::bitcoin::{
|
||||
use chainhook_sdk::indexer;
|
||||
use chainhook_sdk::indexer::bitcoin::{
|
||||
download_and_parse_block_with_retry, retrieve_block_hash_with_retry,
|
||||
};
|
||||
use chainhook_event_observer::observer::BitcoinConfig;
|
||||
use chainhook_event_observer::utils::Context;
|
||||
use chainhook_sdk::observer::BitcoinConfig;
|
||||
use chainhook_sdk::utils::Context;
|
||||
use chainhook_types::{
|
||||
BitcoinBlockData, BitcoinNetwork, BlockIdentifier, StacksNetwork, TransactionIdentifier,
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
pub mod file;
|
||||
pub mod generator;
|
||||
|
||||
use chainhook_event_observer::hord::HordConfig;
|
||||
pub use chainhook_event_observer::indexer::IndexerConfig;
|
||||
use chainhook_event_observer::observer::EventObserverConfig;
|
||||
use chainhook_sdk::hord::HordConfig;
|
||||
pub use chainhook_sdk::indexer::IndexerConfig;
|
||||
use chainhook_sdk::observer::EventObserverConfig;
|
||||
use chainhook_types::{BitcoinBlockSignaling, BitcoinNetwork, StacksNetwork};
|
||||
pub use file::ConfigFile;
|
||||
use std::fs::File;
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
use crate::archive::download_ordinals_dataset_if_required;
|
||||
use crate::config::Config;
|
||||
use chainhook_event_observer::bitcoincore_rpc::RpcApi;
|
||||
use chainhook_event_observer::bitcoincore_rpc::{Auth, Client};
|
||||
use chainhook_event_observer::chainhooks::bitcoin::{
|
||||
use chainhook_sdk::bitcoincore_rpc::RpcApi;
|
||||
use chainhook_sdk::bitcoincore_rpc::{Auth, Client};
|
||||
use chainhook_sdk::chainhooks::bitcoin::{
|
||||
evaluate_bitcoin_chainhooks_on_chain_event, handle_bitcoin_hook_action,
|
||||
BitcoinChainhookOccurrence, BitcoinTriggerChainhook,
|
||||
};
|
||||
use chainhook_event_observer::chainhooks::types::{
|
||||
BitcoinChainhookSpecification, BitcoinPredicateType,
|
||||
};
|
||||
use chainhook_event_observer::hord::db::{
|
||||
use chainhook_sdk::chainhooks::types::{BitcoinChainhookSpecification, BitcoinPredicateType};
|
||||
use chainhook_sdk::hord::db::{
|
||||
fetch_and_cache_blocks_in_hord_db, find_all_inscriptions, find_last_block_inserted,
|
||||
find_lazy_block_at_block_height, open_readonly_hord_db_conn,
|
||||
open_readonly_hord_db_conn_rocks_db, open_readwrite_hord_db_conn,
|
||||
open_readwrite_hord_db_conn_rocks_db,
|
||||
};
|
||||
use chainhook_event_observer::hord::{
|
||||
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_event_observer::indexer;
|
||||
use chainhook_event_observer::indexer::bitcoin::{
|
||||
use chainhook_sdk::indexer;
|
||||
use chainhook_sdk::indexer::bitcoin::{
|
||||
download_and_parse_block_with_retry, retrieve_block_hash_with_retry,
|
||||
};
|
||||
use chainhook_event_observer::observer::{gather_proofs, EventObserverConfig};
|
||||
use chainhook_event_observer::utils::{file_append, send_request, Context};
|
||||
use chainhook_sdk::observer::{gather_proofs, EventObserverConfig};
|
||||
use chainhook_sdk::utils::{file_append, send_request, Context};
|
||||
use chainhook_types::{BitcoinChainEvent, BitcoinChainUpdatedWithBlocksData};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ use crate::{
|
||||
open_readwrite_stacks_db_conn,
|
||||
},
|
||||
};
|
||||
use chainhook_event_observer::{
|
||||
use chainhook_sdk::{
|
||||
chainhooks::stacks::evaluate_stacks_chainhook_on_blocks,
|
||||
indexer::{self, stacks::standardize_stacks_serialized_block_header, Indexer},
|
||||
rocksdb::DB,
|
||||
utils::Context,
|
||||
};
|
||||
use chainhook_event_observer::{
|
||||
use chainhook_sdk::{
|
||||
chainhooks::{
|
||||
stacks::{handle_stacks_hook_action, StacksChainhookOccurrence, StacksTriggerChainhook},
|
||||
types::StacksChainhookSpecification,
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::{
|
||||
sync::{mpsc::Sender, Arc, Mutex},
|
||||
};
|
||||
|
||||
use chainhook_event_observer::{
|
||||
use chainhook_sdk::{
|
||||
chainhooks::types::{ChainhookFullSpecification, ChainhookSpecification},
|
||||
observer::ObserverCommand,
|
||||
utils::Context,
|
||||
|
||||
@@ -9,11 +9,11 @@ use crate::storage::{
|
||||
confirm_entries_in_stacks_blocks, draft_entries_in_stacks_blocks, open_readwrite_stacks_db_conn,
|
||||
};
|
||||
|
||||
use chainhook_event_observer::chainhooks::types::{ChainhookConfig, ChainhookFullSpecification};
|
||||
use chainhook_sdk::chainhooks::types::{ChainhookConfig, ChainhookFullSpecification};
|
||||
|
||||
use chainhook_event_observer::chainhooks::types::ChainhookSpecification;
|
||||
use chainhook_event_observer::observer::{start_event_observer, ObserverEvent};
|
||||
use chainhook_event_observer::utils::Context;
|
||||
use chainhook_sdk::chainhooks::types::ChainhookSpecification;
|
||||
use chainhook_sdk::observer::{start_event_observer, ObserverEvent};
|
||||
use chainhook_sdk::utils::Context;
|
||||
use chainhook_types::{BitcoinBlockSignaling, StacksChainEvent};
|
||||
use redis::{Commands, Connection};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::mpsc::Sender;
|
||||
|
||||
use chainhook_event_observer::{
|
||||
use chainhook_sdk::{
|
||||
chainhooks::types::{
|
||||
BitcoinChainhookSpecification, ChainhookSpecification, StacksChainhookSpecification,
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use chainhook_event_observer::{rocksdb::Options, rocksdb::DB, utils::Context};
|
||||
use chainhook_sdk::{rocksdb::Options, rocksdb::DB, utils::Context};
|
||||
use chainhook_types::{BlockIdentifier, StacksBlockData, StacksBlockUpdate};
|
||||
|
||||
fn get_db_default_options() -> Options {
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
normalization_enabled = true
|
||||
bitcoin_rpc_proxy_enabled = false
|
||||
grpc_server_enabled = true
|
||||
hooks_enabled = true
|
||||
webhooks = []
|
||||
control_port = 20446
|
||||
ingestion_port = 20445
|
||||
bitcoind_rpc_username = "devnet"
|
||||
bitcoind_rpc_password = "devnet"
|
||||
bitcoind_rpc_host = "localhost"
|
||||
bitcoind_rpc_port = 18443
|
||||
stacks_node_rpc_host = "localhost"
|
||||
stacks_node_rpc_port = 20443
|
||||
operators = ["74738ff5-5367-5958-9aee-98fffdcd1876"]
|
||||
@@ -365,7 +365,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "chainhook-event-observer"
|
||||
name = "chainhook-sdk"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"base58",
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "chainhook-event-observer"
|
||||
version = "1.0.7"
|
||||
name = "chainhook-sdk"
|
||||
version = "0.1.0"
|
||||
description = "Stateless Transaction Indexing Engine for Stacks and Bitcoin"
|
||||
license = "GPL-3.0"
|
||||
edition = "2021"
|
||||
@@ -48,7 +48,7 @@ threadpool = "1.8.1"
|
||||
rand = "0.8.5"
|
||||
hex-simd = "0.8.0"
|
||||
serde_cbor = "0.11.2"
|
||||
zeromq = { version = "*", default-features = false, features = ["tokio-runtime", "tcp-transport"], optional = true }
|
||||
zeromq = { version = "0.3.3", default-features = false, features = ["tokio-runtime", "tcp-transport"], optional = true }
|
||||
dashmap = "5.4.0"
|
||||
fxhash = "0.2.1"
|
||||
|
||||
@@ -677,6 +677,7 @@ pub async fn fetch_and_cache_blocks_in_hord_db(
|
||||
};
|
||||
let _ = block_data_tx.send(res);
|
||||
});
|
||||
// TODO: remove this join?
|
||||
if block_height >= ordinal_computing_height {
|
||||
let _ = retrieve_block_data_pool.join();
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
FROM rust:bullseye as build
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
RUN apt update && apt install -y ca-certificates pkg-config libssl-dev libclang-11-dev
|
||||
|
||||
RUN rustup update 1.67.0 && rustup default 1.67.0
|
||||
|
||||
COPY ./components/chainhook-types-rs /src/components/chainhook-types-rs
|
||||
|
||||
COPY ./components/chainhook-event-observer /src/components/chainhook-event-observer
|
||||
|
||||
WORKDIR /src/components/chainhook-event-observer
|
||||
|
||||
RUN mkdir /out
|
||||
|
||||
RUN cargo build --release
|
||||
|
||||
RUN cp target/release/chainhook-event-observer /out
|
||||
|
||||
FROM debian:bullseye-slim
|
||||
|
||||
RUN apt update && apt install -y ca-certificates libssl-dev
|
||||
|
||||
COPY --from=build /out/ /bin/
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
ENTRYPOINT ["chainhook-event-observer"]
|
||||
@@ -10,7 +10,7 @@ COPY ./components/chainhook-cli /src/components/chainhook-cli
|
||||
|
||||
COPY ./components/chainhook-types-rs /src/components/chainhook-types-rs
|
||||
|
||||
COPY ./components/chainhook-event-observer /src/components/chainhook-event-observer
|
||||
COPY ./components/chainhook-sdk /src/components/chainhook-sdk
|
||||
|
||||
WORKDIR /src/components/chainhook-cli
|
||||
|
||||
|
||||
Reference in New Issue
Block a user