diff --git a/components/chainhook-cli/src/scan/bitcoin.rs b/components/chainhook-cli/src/scan/bitcoin.rs index fef4e507e..3427ef60b 100644 --- a/components/chainhook-cli/src/scan/bitcoin.rs +++ b/components/chainhook-cli/src/scan/bitcoin.rs @@ -290,7 +290,7 @@ pub async fn execute_predicates_action<'a>( gather_proofs(&trigger, &mut proofs, config, ctx); } let predicate_uuid = &trigger.chainhook.uuid; - match handle_bitcoin_hook_action(trigger, &proofs, &config.predicates_config) { + match handle_bitcoin_hook_action(trigger, &proofs, &config) { Err(e) => { warn!( ctx.expect_logger(), diff --git a/components/chainhook-cli/src/scan/stacks.rs b/components/chainhook-cli/src/scan/stacks.rs index 279775b74..1e3b100e5 100644 --- a/components/chainhook-cli/src/scan/stacks.rs +++ b/components/chainhook-cli/src/scan/stacks.rs @@ -343,7 +343,7 @@ pub async fn scan_stacks_chainstate_via_rocksdb_using_predicate( let res = match handle_stacks_hook_action( trigger, &proofs, - &config.get_event_observer_config().predicates_config, + &config.get_event_observer_config(), ctx, ) { Err(e) => { @@ -534,12 +534,8 @@ pub async fn scan_stacks_chainstate_via_csv_using_predicate( apply: hits_per_blocks, rollback: vec![], }; - match handle_stacks_hook_action( - trigger, - &proofs, - &config.get_event_observer_config().predicates_config, - ctx, - ) { + match handle_stacks_hook_action(trigger, &proofs, &config.get_event_observer_config(), ctx) + { Err(e) => { error!(ctx.expect_logger(), "unable to handle action {}", e); } diff --git a/components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs b/components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs index 17959b04d..e239521c2 100644 --- a/components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs +++ b/components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs @@ -2,7 +2,7 @@ use super::types::{ append_error_context, validate_txid, ChainhookInstance, ExactMatchingRule, HookAction, MatchingRule, PoxConfig, TxinPredicate, }; -use crate::{observer::PredicatesConfig, utils::{Context, MAX_BLOCK_HEIGHTS_ENTRIES}}; +use crate::{observer::EventObserverConfig, utils::{Context, MAX_BLOCK_HEIGHTS_ENTRIES}}; use bitcoincore_rpc_json::bitcoin::{address::Payload, Address}; use chainhook_types::{ @@ -760,12 +760,12 @@ pub fn serialize_bitcoin_transactions_to_json( pub fn handle_bitcoin_hook_action<'a>( trigger: BitcoinTriggerChainhook<'a>, proofs: &HashMap<&'a TransactionIdentifier, String>, - config: &PredicatesConfig, + config: &EventObserverConfig, ) -> Result { match &trigger.chainhook.action { HookAction::HttpPost(http) => { let mut client_builder = Client::builder(); - if let Some(timeout) = config.payload_http_request_timeout_ms { + if let Some(timeout) = config.predicates_config.payload_http_request_timeout_ms { client_builder = client_builder.timeout(Duration::from_millis(timeout)); } let client = client_builder diff --git a/components/chainhook-sdk/src/chainhooks/stacks/mod.rs b/components/chainhook-sdk/src/chainhooks/stacks/mod.rs index 9de1e757d..1b8e5bfa9 100644 --- a/components/chainhook-sdk/src/chainhooks/stacks/mod.rs +++ b/components/chainhook-sdk/src/chainhooks/stacks/mod.rs @@ -1,4 +1,4 @@ -use crate::observer::PredicatesConfig; +use crate::observer::EventObserverConfig; use crate::utils::{AbstractStacksBlock, Context, MAX_BLOCK_HEIGHTS_ENTRIES}; use super::types::{ @@ -1327,13 +1327,13 @@ pub fn serialize_stacks_payload_to_json<'a>( pub fn handle_stacks_hook_action<'a>( trigger: StacksTriggerChainhook<'a>, proofs: &HashMap<&'a TransactionIdentifier, String>, - config: &PredicatesConfig, + config: &EventObserverConfig, ctx: &Context, ) -> Result { match &trigger.chainhook.action { HookAction::HttpPost(http) => { let mut client_builder = Client::builder(); - if let Some(timeout) = config.payload_http_request_timeout_ms { + if let Some(timeout) = config.predicates_config.payload_http_request_timeout_ms { client_builder = client_builder.timeout(Duration::from_millis(timeout)); } let client = client_builder diff --git a/components/chainhook-sdk/src/chainhooks/tests/mod.rs b/components/chainhook-sdk/src/chainhooks/tests/mod.rs index cd3399ab8..9c5ee7625 100644 --- a/components/chainhook-sdk/src/chainhooks/tests/mod.rs +++ b/components/chainhook-sdk/src/chainhooks/tests/mod.rs @@ -13,7 +13,8 @@ use super::{ types::{ExactMatchingRule, FileHook}, }; use crate::{ - chainhooks::stacks::serialize_stacks_payload_to_json, observer::PredicatesConfig, + chainhooks::stacks::serialize_stacks_payload_to_json, + observer::EventObserverConfig, utils::Context, }; use crate::{ @@ -739,7 +740,7 @@ fn test_stacks_hook_action_noop() { tracer: false, }; let occurrence = - handle_stacks_hook_action(trigger, &proofs, &PredicatesConfig::default(), &ctx).unwrap(); + handle_stacks_hook_action(trigger, &proofs, &EventObserverConfig::default(), &ctx).unwrap(); if let StacksChainhookOccurrence::Data(data) = occurrence { assert_eq!(data.apply.len(), 1); assert_eq!( @@ -817,7 +818,7 @@ fn test_stacks_hook_action_file_append() { tracer: false, }; let occurrence = - handle_stacks_hook_action(trigger, &proofs, &PredicatesConfig::default(), &ctx).unwrap(); + handle_stacks_hook_action(trigger, &proofs, &EventObserverConfig::default(), &ctx).unwrap(); if let StacksChainhookOccurrence::File(path, bytes) = occurrence { assert_eq!(path, "./".to_string()); let json: JsonValue = serde_json::from_slice(&bytes).unwrap(); diff --git a/components/chainhook-sdk/src/observer/mod.rs b/components/chainhook-sdk/src/observer/mod.rs index 25d705d3d..776e2e781 100644 --- a/components/chainhook-sdk/src/observer/mod.rs +++ b/components/chainhook-sdk/src/observer/mod.rs @@ -1507,11 +1507,7 @@ pub async fn start_observer_commands_handler( } for chainhook_to_trigger in chainhooks_to_trigger.into_iter() { let predicate_uuid = &chainhook_to_trigger.chainhook.uuid; - match handle_bitcoin_hook_action( - chainhook_to_trigger, - &proofs, - &config.predicates_config, - ) { + match handle_bitcoin_hook_action(chainhook_to_trigger, &proofs, &config) { Err(e) => { // todo: we may want to set predicates that reach this branch as interrupted, // but for now we will error to see if this problem occurs. @@ -1700,12 +1696,7 @@ pub async fn start_observer_commands_handler( let proofs = HashMap::new(); for chainhook_to_trigger in chainhooks_to_trigger.into_iter() { let predicate_uuid = &chainhook_to_trigger.chainhook.uuid; - match handle_stacks_hook_action( - chainhook_to_trigger, - &proofs, - &config.predicates_config, - &ctx, - ) { + match handle_stacks_hook_action(chainhook_to_trigger, &proofs, &config, &ctx) { Err(e) => { ctx.try_log(|logger| { // todo: we may want to set predicates that reach this branch as interrupted,