Skip to content

Commit

Permalink
fix: save rescanning progress
Browse files Browse the repository at this point in the history
  • Loading branch information
sander2 committed May 23, 2023
1 parent 15fc8d6 commit d1402d6
Show file tree
Hide file tree
Showing 8 changed files with 416 additions and 43 deletions.
11 changes: 6 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub trait Service<Config, InnerError> {
monitoring_config: MonitoringConfig,
shutdown: ShutdownSender,
constructor: Box<dyn Fn(VaultId) -> Result<DynBitcoinCoreApi, BitcoinError> + Send + Sync>,
keyname: String,
) -> Self;
async fn start(&self) -> Result<(), Error<InnerError>>;
}
Expand All @@ -46,6 +47,7 @@ pub struct ConnectionManager<Config: Clone, F: Fn()> {
monitoring_config: MonitoringConfig,
config: Config,
increment_restart_counter: F,
db_path: String,
}

impl<Config: Clone + Send + 'static, F: Fn()> ConnectionManager<Config, F> {
Expand All @@ -59,6 +61,7 @@ impl<Config: Clone + Send + 'static, F: Fn()> ConnectionManager<Config, F> {
monitoring_config: MonitoringConfig,
config: Config,
increment_restart_counter: F,
db_path: String,
) -> Self {
Self {
signer,
Expand All @@ -69,6 +72,7 @@ impl<Config: Clone + Send + 'static, F: Fn()> ConnectionManager<Config, F> {
monitoring_config,
config,
increment_restart_counter,
db_path,
}
}

Expand Down Expand Up @@ -122,6 +126,7 @@ impl<Config: Clone + Send + 'static, F: Fn()> ConnectionManager<Config, F> {
self.monitoring_config.clone(),
shutdown_tx.clone(),
Box::new(constructor),
self.db_path.clone(),
);
match service.start().await {
Err(err @ Error::Abort(_)) => {
Expand Down
2 changes: 2 additions & 0 deletions vault/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ lazy_static = "1.4"
governor = "0.5.0"
nonzero_ext = "0.3.0"

rocksdb = { version = "0.19.0", features = ["snappy"], default-features = false }

tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.2.12", features = ["registry", "env-filter", "fmt"] }
tracing-futures = { version = "0.2.5" }
Expand Down
10 changes: 10 additions & 0 deletions vault/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use std::string::FromUtf8Error;

use bitcoin::Error as BitcoinError;
use jsonrpc_core_client::RpcError;
use parity_scale_codec::Error as CodecError;
use rocksdb::Error as RocksDbError;
use runtime::Error as RuntimeError;
use serde_json::Error as SerdeJsonError;
use thiserror::Error;
use tokio_stream::wrappers::errors::BroadcastStreamRecvError;

Expand Down Expand Up @@ -32,6 +36,12 @@ pub enum Error {
RuntimeError(#[from] RuntimeError),
#[error("CodecError: {0}")]
CodecError(#[from] CodecError),
#[error("DatabaseError: {0}")]
DatabaseError(#[from] RocksDbError),
#[error("SerdeJsonError: {0}")]
SerdeJsonError(#[from] SerdeJsonError),
#[error("FromUtf8Error: {0}")]
FromUtf8Error(#[from] FromUtf8Error),
#[error("BroadcastStreamRecvError: {0}")]
BroadcastStreamRecvError(#[from] BroadcastStreamRecvError),
}
Expand Down
Loading

0 comments on commit d1402d6

Please sign in to comment.