[blockchain] Add a trait to create Blockchains from a configuration

This is the first set of changes for #42
This commit is contained in:
Alekos Filini
2020-09-10 18:08:37 +02:00
parent 6094656a54
commit 5eee18bed2
5 changed files with 98 additions and 10 deletions

View File

@@ -340,6 +340,20 @@ struct EsploraListUnspent {
status: EsploraGetHistoryStatus,
}
/// Configuration for an [`EsploraBlockchain`]
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct EsploraBlockchainConfig {
pub base_url: String,
}
impl ConfigurableBlockchain for EsploraBlockchain {
type Config = EsploraBlockchainConfig;
fn from_config(config: &Self::Config) -> Result<Self, Error> {
Ok(EsploraBlockchain::new(config.base_url.as_str()))
}
}
/// Errors that can happen during a sync with [`EsploraBlockchain`]
#[derive(Debug)]
pub enum EsploraError {