From 50595ab8e4dad5f05976c5997c1173f7c3022b1b Mon Sep 17 00:00:00 2001 From: Ludo Galabru <4290054+vabanaerytk@users.noreply.github.com> Date: Wed, 23 Aug 2023 10:00:54 +0200 Subject: [PATCH] fix: use crossbeam channels --- Cargo.lock | 6 +++--- components/chainhook-cli/Cargo.toml | 2 +- components/chainhook-sdk/Cargo.toml | 4 ++-- components/chainhook-sdk/src/observer/mod.rs | 9 +++++---- components/chainhook-sdk/src/observer/tests/mod.rs | 4 ++-- components/chainhook-types-rs/Cargo.toml | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f87fc1..a44e40a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -457,13 +457,13 @@ dependencies = [ [[package]] name = "chainhook-sdk" -version = "0.8.2" +version = "0.8.4" dependencies = [ "base58 0.2.0", "base64", "bitcoincore-rpc", "bitcoincore-rpc-json", - "chainhook-types 1.0.11", + "chainhook-types 1.0.12", "clarinet-utils", "crossbeam-channel 0.5.8", "dashmap 5.4.0", @@ -505,7 +505,7 @@ dependencies = [ [[package]] name = "chainhook-types" -version = "1.0.11" +version = "1.0.12" dependencies = [ "hex", "schemars 0.8.12", diff --git a/components/chainhook-cli/Cargo.toml b/components/chainhook-cli/Cargo.toml index 77fb2c5..1e0e88d 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.2", default-features = false, features = ["zeromq"], path = "../chainhook-sdk" } +chainhook-sdk = { version = "0.8.4", 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 9239463..2436414 100644 --- a/components/chainhook-sdk/Cargo.toml +++ b/components/chainhook-sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chainhook-sdk" -version = "0.8.2" +version = "0.8.4" description = "Stateless Transaction Indexing Engine for Stacks and Bitcoin" license = "GPL-3.0" edition = "2021" @@ -18,7 +18,7 @@ hiro-system-kit = "0.1.0" # stacks-rpc-client = { version = "1", path = "../../../clarinet/components/stacks-rpc-client" } # clarinet-utils = { version = "1", path = "../../../clarinet/components/clarinet-utils" } # hiro-system-kit = { version = "0.1.0", path = "../../../clarinet/components/hiro-system-kit" } -chainhook-types = { version = "1.0.11", path = "../chainhook-types-rs" } +chainhook-types = { version = "1.0.12", path = "../chainhook-types-rs" } rocket = { version = "=0.5.0-rc.3", features = ["json"] } bitcoincore-rpc = "0.16.0" bitcoincore-rpc-json = "0.16.0" diff --git a/components/chainhook-sdk/src/observer/mod.rs b/components/chainhook-sdk/src/observer/mod.rs index 6f73470..80a2968 100644 --- a/components/chainhook-sdk/src/observer/mod.rs +++ b/components/chainhook-sdk/src/observer/mod.rs @@ -32,7 +32,7 @@ use rocket::config::{self, Config, LogLevel}; use rocket::data::{Limits, ToByteUnit}; use rocket::serde::Deserialize; use rocket::Shutdown; -use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque}; +use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::error::Error; use std::net::{IpAddr, Ipv4Addr}; use std::path::PathBuf; @@ -344,10 +344,10 @@ pub struct BitcoinBlockDataCached { pub struct ObserverSidecar { pub bitcoin_blocks_mutator: Option<( - Sender<(Vec, Vec)>, - Receiver>, + crossbeam_channel::Sender<(Vec, Vec)>, + crossbeam_channel::Receiver>, )>, - pub bitcoin_chain_event_notifier: Option>, + pub bitcoin_chain_event_notifier: Option>, } impl ObserverSidecar { @@ -662,6 +662,7 @@ pub fn start_zeromq_runloop( #[cfg(feature = "zeromq")] { use crate::indexer::fork_scratch_pad::ForkScratchPad; + use std::collections::VecDeque; if let BitcoinBlockSignaling::ZeroMQ(ref bitcoind_zmq_url) = config.bitcoin_block_signaling { diff --git a/components/chainhook-sdk/src/observer/tests/mod.rs b/components/chainhook-sdk/src/observer/tests/mod.rs index f14e7d3..b3eea71 100644 --- a/components/chainhook-sdk/src/observer/tests/mod.rs +++ b/components/chainhook-sdk/src/observer/tests/mod.rs @@ -1224,8 +1224,8 @@ fn test_bitcoin_chainhook_auto_deregister() { #[test] fn test_bitcoin_chainhook_through_reorg() { let (observer_commands_tx, observer_commands_rx) = channel(); - let (block_pre_processor_in_tx, block_pre_processor_in_rx) = channel(); - let (block_pre_processor_out_tx, block_pre_processor_out_rx) = channel(); + let (block_pre_processor_in_tx, block_pre_processor_in_rx) = crossbeam_channel::unbounded(); + let (block_pre_processor_out_tx, block_pre_processor_out_rx) = crossbeam_channel::unbounded(); let (observer_events_tx, observer_events_rx) = crossbeam_channel::unbounded(); let observer_metrics_rw_lock = Arc::new(RwLock::new(ObserverMetrics::default())); diff --git a/components/chainhook-types-rs/Cargo.toml b/components/chainhook-types-rs/Cargo.toml index d4c97de..de2f326 100644 --- a/components/chainhook-types-rs/Cargo.toml +++ b/components/chainhook-types-rs/Cargo.toml @@ -2,7 +2,7 @@ name = "chainhook-types" description = "Bitcoin and Stacks data schemas, based on the Rosetta specification" license = "MIT" -version = "1.0.11" +version = "1.0.12" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html