[db] Add the last_sync_time database entry

This will be used to store the height and timestamp after every sync.
This commit is contained in:
Alekos Filini
2021-10-23 14:51:42 +02:00
parent aa075f0b2f
commit 2892edf94b
5 changed files with 159 additions and 0 deletions

View File

@@ -144,6 +144,9 @@ impl BatchOperations for AnyDatabase {
fn set_last_index(&mut self, keychain: KeychainKind, value: u32) -> Result<(), Error> {
impl_inner_method!(AnyDatabase, self, set_last_index, keychain, value)
}
fn set_last_sync_time(&mut self, last_sync_time: ConfirmationTime) -> Result<(), Error> {
impl_inner_method!(AnyDatabase, self, set_last_sync_time, last_sync_time)
}
fn del_script_pubkey_from_path(
&mut self,
@@ -180,6 +183,9 @@ impl BatchOperations for AnyDatabase {
fn del_last_index(&mut self, keychain: KeychainKind) -> Result<Option<u32>, Error> {
impl_inner_method!(AnyDatabase, self, del_last_index, keychain)
}
fn del_last_sync_time(&mut self) -> Result<Option<ConfirmationTime>, Error> {
impl_inner_method!(AnyDatabase, self, del_last_sync_time)
}
}
impl Database for AnyDatabase {
@@ -241,6 +247,9 @@ impl Database for AnyDatabase {
fn get_last_index(&self, keychain: KeychainKind) -> Result<Option<u32>, Error> {
impl_inner_method!(AnyDatabase, self, get_last_index, keychain)
}
fn get_last_sync_time(&self) -> Result<Option<ConfirmationTime>, Error> {
impl_inner_method!(AnyDatabase, self, get_last_sync_time)
}
fn increment_last_index(&mut self, keychain: KeychainKind) -> Result<u32, Error> {
impl_inner_method!(AnyDatabase, self, increment_last_index, keychain)
@@ -272,6 +281,9 @@ impl BatchOperations for AnyBatch {
fn set_last_index(&mut self, keychain: KeychainKind, value: u32) -> Result<(), Error> {
impl_inner_method!(AnyBatch, self, set_last_index, keychain, value)
}
fn set_last_sync_time(&mut self, last_sync_time: ConfirmationTime) -> Result<(), Error> {
impl_inner_method!(AnyBatch, self, set_last_sync_time, last_sync_time)
}
fn del_script_pubkey_from_path(
&mut self,
@@ -302,6 +314,9 @@ impl BatchOperations for AnyBatch {
fn del_last_index(&mut self, keychain: KeychainKind) -> Result<Option<u32>, Error> {
impl_inner_method!(AnyBatch, self, del_last_index, keychain)
}
fn del_last_sync_time(&mut self) -> Result<Option<ConfirmationTime>, Error> {
impl_inner_method!(AnyBatch, self, del_last_sync_time)
}
}
impl BatchDatabase for AnyDatabase {