Skip to content

Commit bba8a70

Browse files
committed
fix: save rescanning progress
1 parent e6b5f20 commit bba8a70

File tree

8 files changed

+424
-51
lines changed

8 files changed

+424
-51
lines changed

Cargo.lock

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub trait Service<Config, InnerError> {
3333
monitoring_config: MonitoringConfig,
3434
shutdown: ShutdownSender,
3535
constructor: Box<dyn Fn(VaultId) -> Result<DynBitcoinCoreApi, BitcoinError> + Send + Sync>,
36+
keyname: String,
3637
) -> Self;
3738
async fn start(&self) -> Result<(), Error<InnerError>>;
3839
}
@@ -46,6 +47,7 @@ pub struct ConnectionManager<Config: Clone, F: Fn()> {
4647
monitoring_config: MonitoringConfig,
4748
config: Config,
4849
increment_restart_counter: F,
50+
db_path: String,
4951
}
5052

5153
impl<Config: Clone + Send + 'static, F: Fn()> ConnectionManager<Config, F> {
@@ -59,6 +61,7 @@ impl<Config: Clone + Send + 'static, F: Fn()> ConnectionManager<Config, F> {
5961
monitoring_config: MonitoringConfig,
6062
config: Config,
6163
increment_restart_counter: F,
64+
db_path: String,
6265
) -> Self {
6366
Self {
6467
signer,
@@ -69,6 +72,7 @@ impl<Config: Clone + Send + 'static, F: Fn()> ConnectionManager<Config, F> {
6972
monitoring_config,
7073
config,
7174
increment_restart_counter,
75+
db_path,
7276
}
7377
}
7478

@@ -122,6 +126,7 @@ impl<Config: Clone + Send + 'static, F: Fn()> ConnectionManager<Config, F> {
122126
self.monitoring_config.clone(),
123127
shutdown_tx.clone(),
124128
Box::new(constructor),
129+
self.db_path.clone(),
125130
);
126131
match service.start().await {
127132
Err(err @ Error::Abort(_)) => {

vault/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ lazy_static = "1.4"
3535
governor = "0.5.0"
3636
nonzero_ext = "0.3.0"
3737

38+
rocksdb = { version = "0.19.0", features = ["snappy"], default-features = false }
39+
3840
tracing = { version = "0.1", features = ["log"] }
3941
tracing-subscriber = { version = "0.2.12", features = ["registry", "env-filter", "fmt"] }
4042
tracing-futures = { version = "0.2.5" }

vault/src/error.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
use std::string::FromUtf8Error;
2+
13
use bitcoin::Error as BitcoinError;
24
use jsonrpc_core_client::RpcError;
35
use parity_scale_codec::Error as CodecError;
6+
use rocksdb::Error as RocksDbError;
47
use runtime::Error as RuntimeError;
8+
use serde_json::Error as SerdeJsonError;
59
use thiserror::Error;
610
use tokio_stream::wrappers::errors::BroadcastStreamRecvError;
711

@@ -32,6 +36,12 @@ pub enum Error {
3236
RuntimeError(#[from] RuntimeError),
3337
#[error("CodecError: {0}")]
3438
CodecError(#[from] CodecError),
39+
#[error("DatabaseError: {0}")]
40+
DatabaseError(#[from] RocksDbError),
41+
#[error("SerdeJsonError: {0}")]
42+
SerdeJsonError(#[from] SerdeJsonError),
43+
#[error("FromUtf8Error: {0}")]
44+
FromUtf8Error(#[from] FromUtf8Error),
3545
#[error("BroadcastStreamRecvError: {0}")]
3646
BroadcastStreamRecvError(#[from] BroadcastStreamRecvError),
3747
}

0 commit comments

Comments
 (0)