[wallet] Add an option to change the assumed current height

This commit is contained in:
Alekos Filini
2020-05-06 17:17:14 +02:00
parent 45aa001e10
commit e32559a06a
4 changed files with 61 additions and 12 deletions

View File

@@ -29,6 +29,10 @@ impl<T: Read + Write> Blockchain for ElectrumBlockchain<T> {
fn offline() -> Self {
ElectrumBlockchain(None)
}
fn is_online(&self) -> bool {
self.0.is_some()
}
}
impl<T: Read + Write> OnlineBlockchain for ElectrumBlockchain<T> {
@@ -190,6 +194,8 @@ impl<T: Read + Write> OnlineBlockchain for ElectrumBlockchain<T> {
}
fn get_height(&mut self) -> Result<usize, Error> {
// TODO: unsubscribe when added to the client, or is there a better call to use here?
Ok(self
.0
.as_mut()

View File

@@ -18,6 +18,8 @@ pub enum Capability {
}
pub trait Blockchain {
fn is_online(&self) -> bool;
fn offline() -> Self;
}
@@ -26,6 +28,10 @@ impl Blockchain for OfflineBlockchain {
fn offline() -> Self {
OfflineBlockchain
}
fn is_online(&self) -> bool {
false
}
}
pub trait OnlineBlockchain: Blockchain {