diff --git a/src/builder.rs b/src/builder.rs index a2c5363..ef26675 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -46,7 +46,6 @@ use std::{path::PathBuf, time::Duration}; -use bdk_wallet::chain::local_chain::MissingGenesisError; use bdk_wallet::Wallet; use kyoto::NodeBuilder; pub use kyoto::{ @@ -112,7 +111,7 @@ impl LightClientBuilder { } /// Build a light client node and a client to interact with the node. - pub fn build(self, wallet: &Wallet) -> Result { + pub fn build(self, wallet: &Wallet) -> Result { let network = wallet.network(); let mut node_builder = NodeBuilder::new(network); if let Some(whitelist) = self.peers { @@ -165,7 +164,7 @@ impl LightClientBuilder { wallet.local_chain().tip(), wallet.spk_index().clone(), event_rx, - )?; + ); Ok(LightClient { requester, log_subscriber: LogSubscriber::new(log_rx), @@ -181,42 +180,3 @@ impl Default for LightClientBuilder { Self::new() } } - -/// Errors thrown by the [`LightClientBuilder`]. -#[derive(Debug)] -pub enum BuilderError { - /// The `LocalChain` was not initialized with a genesis block. - Chain(MissingGenesisError), - /// The database encountered a fatal error. - Database(SqlInitializationError), -} - -impl std::fmt::Display for BuilderError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - BuilderError::Chain(e) => write!(f, "genesis block not found: {e}"), - BuilderError::Database(e) => write!(f, "fatal database error: {e}"), - } - } -} - -impl std::error::Error for BuilderError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match self { - BuilderError::Chain(e) => Some(e), - BuilderError::Database(e) => Some(e), - } - } -} - -impl From for BuilderError { - fn from(value: MissingGenesisError) -> Self { - BuilderError::Chain(value) - } -} - -impl From for BuilderError { - fn from(value: SqlInitializationError) -> Self { - BuilderError::Database(value) - } -} diff --git a/src/lib.rs b/src/lib.rs index f0d7ec8..83d827a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,7 +45,6 @@ use std::collections::HashSet; type FutureResult<'a, T, E> = Pin> + Send + 'a>>; -pub use bdk_wallet::chain::local_chain::MissingGenesisError; pub use bdk_wallet::Update; use bdk_wallet::chain::{ @@ -107,13 +106,13 @@ impl UpdateSubscriber { cp: CheckPoint, index: KeychainTxOutIndex, receiver: UnboundedReceiver, - ) -> Result { - Ok(Self { + ) -> Self { + Self { receiver, - chain: LocalChain::from_tip(cp)?, + chain: LocalChain::from_tip(cp).expect("chain was initialized with genesis"), graph: IndexedTxGraph::new(index.clone()), chain_changeset: BTreeMap::new(), - }) + } } /// Return the most recent update from the node once it has synced to the network's tip.