database: get and set last poll timestamp
This commit is contained in:
parent
a2b79f1b07
commit
e9fdcde995
@ -81,6 +81,14 @@ pub trait DatabaseConnection {
|
||||
/// Mark the rescan as complete.
|
||||
fn complete_rescan(&mut self);
|
||||
|
||||
/// Get the timestamp at which the last poll of the blockchain completed, if any,
|
||||
/// as the number of seconds since the UNIX epoch.
|
||||
fn last_poll_timestamp(&mut self) -> Option<u32>;
|
||||
|
||||
/// Set the timestamp at which the last poll of the blockchain completed,
|
||||
/// where `timestamp` should be given as the number of seconds since the UNIX epoch.
|
||||
fn set_last_poll(&mut self, timestamp: u32);
|
||||
|
||||
/// Get the derivation index for this address, as well as whether this address is change.
|
||||
fn derivation_index_by_address(
|
||||
&mut self,
|
||||
@ -220,6 +228,15 @@ impl DatabaseConnection for SqliteConn {
|
||||
self.complete_wallet_rescan()
|
||||
}
|
||||
|
||||
fn last_poll_timestamp(&mut self) -> Option<u32> {
|
||||
self.db_wallet().last_poll_timestamp
|
||||
}
|
||||
|
||||
fn set_last_poll(&mut self, timestamp: u32) {
|
||||
self.set_wallet_last_poll_timestamp(timestamp)
|
||||
.expect("database must be available")
|
||||
}
|
||||
|
||||
fn coins(
|
||||
&mut self,
|
||||
statuses: &[CoinStatus],
|
||||
|
||||
@ -149,6 +149,7 @@ struct DummyDbState {
|
||||
txs: HashMap<bitcoin::Txid, bitcoin::Transaction>,
|
||||
spend_txs: HashMap<bitcoin::Txid, (Psbt, Option<u32>)>,
|
||||
timestamp: u32,
|
||||
last_poll_timestamp: Option<u32>,
|
||||
}
|
||||
|
||||
pub struct DummyDatabase {
|
||||
@ -181,6 +182,7 @@ impl DummyDatabase {
|
||||
txs: HashMap::new(),
|
||||
spend_txs: HashMap::new(),
|
||||
timestamp: now,
|
||||
last_poll_timestamp: None,
|
||||
})),
|
||||
}
|
||||
}
|
||||
@ -411,6 +413,14 @@ impl DatabaseConnection for DummyDatabase {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn last_poll_timestamp(&mut self) -> Option<u32> {
|
||||
self.db.read().unwrap().last_poll_timestamp
|
||||
}
|
||||
|
||||
fn set_last_poll(&mut self, timestamp: u32) {
|
||||
self.db.write().unwrap().last_poll_timestamp = Some(timestamp);
|
||||
}
|
||||
|
||||
fn update_labels(&mut self, _items: &HashMap<LabelItem, Option<String>>) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user