Skip to content

Commit

Permalink
rename ChainhookConfig -> ChainhookStore
Browse files Browse the repository at this point in the history
remove unnecessary wrapper around ChainhookStore
  • Loading branch information
MicaiahReid committed Jun 24, 2024
1 parent 4debc28 commit c54b6e7
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 110 deletions.
3 changes: 2 additions & 1 deletion components/chainhook-cli/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod file;
pub mod generator;

use chainhook_sdk::chainhooks::types::ChainhookStore;
pub use chainhook_sdk::indexer::IndexerConfig;
use chainhook_sdk::observer::EventObserverConfig;
use chainhook_sdk::types::{
Expand Down Expand Up @@ -114,7 +115,7 @@ impl Config {
pub fn get_event_observer_config(&self) -> EventObserverConfig {
EventObserverConfig {
bitcoin_rpc_proxy_enabled: true,
chainhook_config: None,
registered_chainhooks: ChainhookStore::new(),
bitcoind_rpc_username: self.network.bitcoind_rpc_username.clone(),
bitcoind_rpc_password: self.network.bitcoind_rpc_password.clone(),
bitcoind_rpc_url: self.network.bitcoind_rpc_url.clone(),
Expand Down
10 changes: 5 additions & 5 deletions components/chainhook-cli/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::storage::{
open_readwrite_stacks_db_conn,
};

use chainhook_sdk::chainhooks::types::{ChainhookConfig, ChainhookSpecificationNetworkMap};
use chainhook_sdk::chainhooks::types::{ChainhookSpecificationNetworkMap, ChainhookStore};

use chainhook_sdk::chainhooks::types::ChainhookInstance;
use chainhook_sdk::observer::{
Expand Down Expand Up @@ -42,7 +42,7 @@ impl Service {
predicates_from_startup: Vec<ChainhookSpecificationNetworkMap>,
observer_commands_tx_rx: Option<(Sender<ObserverCommand>, Receiver<ObserverCommand>)>,
) -> Result<(), String> {
let mut chainhook_config = ChainhookConfig::new();
let mut chainhook_store = ChainhookStore::new();

// store all predicates from Redis that were in the process of scanning when
// chainhook was shutdown - we need to resume where we left off
Expand Down Expand Up @@ -87,7 +87,7 @@ impl Service {
continue;
}
}
match chainhook_config.register_instance(predicate) {
match chainhook_store.register_instance(predicate) {
Ok(_) => {
debug!(
self.ctx.expect_logger(),
Expand Down Expand Up @@ -128,7 +128,7 @@ impl Service {
}
};
}
match chainhook_config.register_instance_from_network_map(
match chainhook_store.register_instance_from_network_map(
(
&self.config.network.bitcoin_network,
&self.config.network.stacks_network,
Expand Down Expand Up @@ -159,7 +159,7 @@ impl Service {
// let (ordinal_indexer_command_tx, ordinal_indexer_command_rx) = channel();

let mut event_observer_config = self.config.get_event_observer_config();
event_observer_config.chainhook_config = Some(chainhook_config);
event_observer_config.registered_chainhooks = chainhook_store;

// Download and ingest a Stacks dump
if self.config.rely_on_remote_stacks_tsv() {
Expand Down
3 changes: 2 additions & 1 deletion components/chainhook-cli/src/service/tests/observer_tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{sync::mpsc::channel, thread::sleep, time::Duration};

use chainhook_sdk::{
chainhooks::types::ChainhookStore,
observer::{start_event_observer, EventObserverConfig},
types::{BitcoinNetwork, StacksNodeConfig},
utils::Context,
Expand Down Expand Up @@ -188,7 +189,7 @@ async fn it_responds_200_for_unimplemented_endpoints(
panic!("test failed with error: {e}");
});
let config = EventObserverConfig {
chainhook_config: None,
registered_chainhooks: ChainhookStore::new(),
bitcoin_rpc_proxy_enabled: false,
bitcoind_rpc_username: format!(""),
bitcoind_rpc_password: format!(""),
Expand Down
10 changes: 5 additions & 5 deletions components/chainhook-sdk/src/chainhooks/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ use crate::chainhooks::stacks::StacksChainhookInstance;
use crate::chainhooks::stacks::StacksChainhookSpecificationNetworkMap;

#[derive(Deserialize, Debug, Clone)]
pub struct ChainhookConfig {
pub struct ChainhookStore {
pub stacks_chainhooks: Vec<StacksChainhookInstance>,
pub bitcoin_chainhooks: Vec<BitcoinChainhookInstance>,
}

impl ChainhookConfig {
pub fn new() -> ChainhookConfig {
ChainhookConfig {
impl ChainhookStore {
pub fn new() -> ChainhookStore {
ChainhookStore {
stacks_chainhooks: vec![],
bitcoin_chainhooks: vec![],
}
Expand Down Expand Up @@ -137,7 +137,7 @@ impl ChainhookConfig {
}
}

impl Serialize for ChainhookConfig {
impl Serialize for ChainhookStore {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
Loading

0 comments on commit c54b6e7

Please sign in to comment.