Skip to content

Commit

Permalink
fix: chainhook not being registered
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludo Galabru committed Aug 26, 2023
1 parent ea33553 commit 5a809c6
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions components/chainhook-sdk/src/observer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@ impl EventObserverConfig {
bitcoin_config
}

pub fn get_chainhook_store(&self) -> ChainhookStore {
let mut chainhook_store = ChainhookStore::new();
// If authorization not required, we create a default ChainhookConfig
if let Some(ref chainhook_config) = self.chainhook_config {
let mut chainhook_config = chainhook_config.clone();
chainhook_store
.predicates
.stacks_chainhooks
.append(&mut chainhook_config.stacks_chainhooks);
chainhook_store
.predicates
.bitcoin_chainhooks
.append(&mut chainhook_config.bitcoin_chainhooks);
}
chainhook_store
}

pub fn get_stacks_node_config(&self) -> &StacksNodeConfig {
match self.bitcoin_block_signaling {
BitcoinBlockSignaling::Stacks(ref config) => config,
Expand Down Expand Up @@ -474,7 +491,7 @@ pub async fn start_bitcoin_event_observer(
observer_sidecar: Option<ObserverSidecar>,
ctx: Context,
) -> Result<(), Box<dyn Error>> {
let chainhook_store = ChainhookStore::new();
let chainhook_store = config.get_chainhook_store();

let observer_metrics = ObserverMetrics {
bitcoin: ChainMetrics {
Expand Down Expand Up @@ -505,7 +522,7 @@ pub async fn start_bitcoin_event_observer(
}

pub async fn start_stacks_event_observer(
mut config: EventObserverConfig,
config: EventObserverConfig,
observer_commands_tx: Sender<ObserverCommand>,
observer_commands_rx: Receiver<ObserverCommand>,
observer_events_tx: Option<crossbeam_channel::Sender<ObserverEvent>>,
Expand Down Expand Up @@ -537,18 +554,7 @@ pub async fn start_stacks_event_observer(
let bitcoin_rpc_proxy_enabled = config.bitcoin_rpc_proxy_enabled;
let bitcoin_config = config.get_bitcoin_config();

let mut chainhook_store = ChainhookStore::new();
// If authorization not required, we create a default ChainhookConfig
if let Some(ref mut initial_chainhook_config) = config.chainhook_config {
chainhook_store
.predicates
.stacks_chainhooks
.append(&mut initial_chainhook_config.stacks_chainhooks);
chainhook_store
.predicates
.bitcoin_chainhooks
.append(&mut initial_chainhook_config.bitcoin_chainhooks);
}
let chainhook_store = config.get_chainhook_store();

let indexer_rw_lock = Arc::new(RwLock::new(indexer));

Expand Down

0 comments on commit 5a809c6

Please sign in to comment.