From d6d1cf2e50f9a136538c6abaa239dcc482aad4de Mon Sep 17 00:00:00 2001 From: Ludo Galabru Date: Tue, 29 Aug 2023 10:29:30 -0400 Subject: [PATCH] chore: tweak chainhook-sdk --- Cargo.lock | 2 +- components/chainhook-cli/Cargo.toml | 2 +- components/chainhook-sdk/Cargo.toml | 2 +- components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs | 4 ++-- components/chainhook-sdk/src/observer/mod.rs | 10 ++++++++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e3978907..764fe81b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -439,7 +439,7 @@ dependencies = [ [[package]] name = "chainhook-sdk" -version = "0.8.6" +version = "0.9.0" dependencies = [ "base58 0.2.0", "base64", diff --git a/components/chainhook-cli/Cargo.toml b/components/chainhook-cli/Cargo.toml index 1e0e88dc2..596c9ec98 100644 --- a/components/chainhook-cli/Cargo.toml +++ b/components/chainhook-cli/Cargo.toml @@ -15,7 +15,7 @@ redis = "0.21.5" serde-redis = "0.12.0" hex = "0.4.3" rand = "0.8.5" -chainhook-sdk = { version = "0.8.4", default-features = false, features = ["zeromq"], path = "../chainhook-sdk" } +chainhook-sdk = { version = "0.9.0", default-features = false, features = ["zeromq"], path = "../chainhook-sdk" } clarinet-files = "1.0.1" hiro-system-kit = "0.1.0" # clarinet-files = { path = "../../../clarinet/components/clarinet-files" } diff --git a/components/chainhook-sdk/Cargo.toml b/components/chainhook-sdk/Cargo.toml index 3c2cc3d92..96dd054ed 100644 --- a/components/chainhook-sdk/Cargo.toml +++ b/components/chainhook-sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chainhook-sdk" -version = "0.8.7" +version = "0.9.0" description = "Stateless Transaction Indexing Engine for Stacks and Bitcoin" license = "GPL-3.0" edition = "2021" diff --git a/components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs b/components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs index 1e971bebd..39485d1f9 100644 --- a/components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs +++ b/components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs @@ -24,12 +24,12 @@ pub struct BitcoinTriggerChainhook<'a> { pub rollback: Vec<(Vec<&'a BitcoinTransactionData>, &'a BitcoinBlockData)>, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize)] pub struct BitcoinApplyTransactionPayload { pub block: BitcoinBlockData, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize)] pub struct BitcoinRollbackTransactionPayload { pub block: BitcoinBlockData, } diff --git a/components/chainhook-sdk/src/observer/mod.rs b/components/chainhook-sdk/src/observer/mod.rs index cfce3a6dc..33f031d26 100644 --- a/components/chainhook-sdk/src/observer/mod.rs +++ b/components/chainhook-sdk/src/observer/mod.rs @@ -60,6 +60,11 @@ pub enum Event { StacksChainEvent(StacksChainEvent), } +pub enum DataHandlerEvent { + Process(BitcoinChainhookOccurrencePayload), + Terminate, +} + #[derive(Debug, Clone)] pub struct EventObserverConfig { pub chainhook_config: Option, @@ -73,7 +78,7 @@ pub struct EventObserverConfig { pub cache_path: String, pub bitcoin_network: BitcoinNetwork, pub stacks_network: StacksNetwork, - pub data_handler_tx: Option>, + pub data_handler_tx: Option>, } #[derive(Deserialize, Debug, Clone)] @@ -512,7 +517,8 @@ pub async fn start_bitcoin_event_observer( let ctx_moved = ctx.clone(); let config_moved = config.clone(); let _ = hiro_system_kit::thread_named("ZMQ handler").spawn(move || { - let future = zmq::start_zeromq_runloop(&config_moved, _observer_commands_tx, &ctx_moved); + let future = + zmq::start_zeromq_runloop(&config_moved, _observer_commands_tx, &ctx_moved); let _ = hiro_system_kit::nestable_block_on(future); }); }