Accept a custom database interface when starting the daemon
This commit is contained in:
5 files changed
+53
-21
No files matched your search
@@ -8,6 +8,8 @@ use crate::{
|
||||
database::sqlite::{schema::DbTip, SqliteConn, SqliteDb},
|
||||
};
|
||||
|
||||
use std::sync;
|
||||
|
||||
use miniscript::bitcoin::util::bip32;
|
||||
|
||||
pub trait DatabaseInterface: Send {
|
||||
@@ -20,6 +22,13 @@ impl DatabaseInterface for SqliteDb {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: do we need to repeat the entire trait implemenation? Isn't there a nicer way?
|
||||
impl DatabaseInterface for sync::Arc<sync::Mutex<dyn DatabaseInterface>> {
|
||||
fn connection(&self) -> Box<dyn DatabaseConnection> {
|
||||
self.lock().unwrap().connection()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait DatabaseConnection {
|
||||
/// Get the tip of the best chain we've seen.
|
||||
fn chain_tip(&mut self) -> Option<BlockChainTip>;
|
||||
|
||||
Reference in new issue
Block a user