[blockchain] add Error::OfflineClient
This commit is contained in:
parent
75a9c30c9a
commit
45aa001e10
@ -84,7 +84,7 @@ impl<T: Read + Write> OnlineBlockchain for ElectrumBlockchain<T> {
|
|||||||
let call_result = self
|
let call_result = self
|
||||||
.0
|
.0
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.ok_or(Error::OfflineClient)?
|
||||||
.batch_script_get_history(chunk.iter())?;
|
.batch_script_get_history(chunk.iter())?;
|
||||||
|
|
||||||
for (script, history) in chunk.into_iter().zip(call_result.into_iter()) {
|
for (script, history) in chunk.into_iter().zip(call_result.into_iter()) {
|
||||||
@ -127,7 +127,7 @@ impl<T: Read + Write> OnlineBlockchain for ElectrumBlockchain<T> {
|
|||||||
let call_result = self
|
let call_result = self
|
||||||
.0
|
.0
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.ok_or(Error::OfflineClient)?
|
||||||
.batch_script_list_unspent(scripts)?;
|
.batch_script_list_unspent(scripts)?;
|
||||||
|
|
||||||
// check which utxos are actually still unspent
|
// check which utxos are actually still unspent
|
||||||
@ -175,7 +175,7 @@ impl<T: Read + Write> OnlineBlockchain for ElectrumBlockchain<T> {
|
|||||||
Ok(self
|
Ok(self
|
||||||
.0
|
.0
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.ok_or(Error::OfflineClient)?
|
||||||
.transaction_get(txid)
|
.transaction_get(txid)
|
||||||
.map(Option::Some)?)
|
.map(Option::Some)?)
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ impl<T: Read + Write> OnlineBlockchain for ElectrumBlockchain<T> {
|
|||||||
Ok(self
|
Ok(self
|
||||||
.0
|
.0
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.ok_or(Error::OfflineClient)?
|
||||||
.transaction_broadcast(tx)
|
.transaction_broadcast(tx)
|
||||||
.map(|_| ())?)
|
.map(|_| ())?)
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ impl<T: Read + Write> OnlineBlockchain for ElectrumBlockchain<T> {
|
|||||||
Ok(self
|
Ok(self
|
||||||
.0
|
.0
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.ok_or(Error::OfflineClient)?
|
||||||
.block_headers_subscribe()
|
.block_headers_subscribe()
|
||||||
.map(|data| data.height)?)
|
.map(|data| data.height)?)
|
||||||
}
|
}
|
||||||
@ -232,7 +232,11 @@ impl<T: Read + Write> ElectrumBlockchain<T> {
|
|||||||
// went wrong
|
// went wrong
|
||||||
saved_tx.transaction.unwrap()
|
saved_tx.transaction.unwrap()
|
||||||
}
|
}
|
||||||
None => self.0.as_mut().unwrap().transaction_get(&txid)?,
|
None => self
|
||||||
|
.0
|
||||||
|
.as_mut()
|
||||||
|
.ok_or(Error::OfflineClient)?
|
||||||
|
.transaction_get(&txid)?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut incoming: u64 = 0;
|
let mut incoming: u64 = 0;
|
||||||
|
@ -29,6 +29,7 @@ pub enum Error {
|
|||||||
|
|
||||||
// Blockchain interface errors
|
// Blockchain interface errors
|
||||||
Uncapable(crate::blockchain::Capability),
|
Uncapable(crate::blockchain::Capability),
|
||||||
|
OfflineClient,
|
||||||
InvalidProgressValue(f32),
|
InvalidProgressValue(f32),
|
||||||
ProgressUpdateError,
|
ProgressUpdateError,
|
||||||
MissingCachedAddresses,
|
MissingCachedAddresses,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user