Skip to content

Commit

Permalink
Merge pull request #398 from hirosystems/feat/support-ordhook-sdk
Browse files Browse the repository at this point in the history
chore: tweak chainhook-sdk
  • Loading branch information
Ludo Galabru authored Aug 29, 2023
2 parents db7e087 + d6d1cf2 commit 59040eb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion 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/chainhook-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion components/chainhook-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
10 changes: 8 additions & 2 deletions components/chainhook-sdk/src/observer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChainhookConfig>,
Expand All @@ -73,7 +78,7 @@ pub struct EventObserverConfig {
pub cache_path: String,
pub bitcoin_network: BitcoinNetwork,
pub stacks_network: StacksNetwork,
pub data_handler_tx: Option<crossbeam_channel::Sender<BitcoinChainhookOccurrencePayload>>,
pub data_handler_tx: Option<crossbeam_channel::Sender<DataHandlerEvent>>,
}

#[derive(Deserialize, Debug, Clone)]
Expand Down Expand Up @@ -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);
});
}
Expand Down

0 comments on commit 59040eb

Please sign in to comment.