1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

Let query module return errors

This commit is contained in:
Roman Zeyde 2018-05-17 12:35:13 +03:00
parent 4b0f3d470d
commit b6d664c580
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
2 changed files with 6 additions and 8 deletions

View File

@ -89,12 +89,8 @@ fn run_server(config: &Config) {
scope.spawn(|| rpc::serve(config.rpc_addr(), &query, chan));
loop {
thread::sleep(poll_delay);
query.update_mempool();
let current_tip = daemon
.getbestblockhash()
.expect("failed to get latest blockhash");
if tip == current_tip {
query.update_mempool().unwrap();
if tip == daemon.getbestblockhash().unwrap() {
continue;
}
tip = index.update(&store, &daemon);

View File

@ -11,6 +11,8 @@ use mempool::Tracker;
use store::Store;
use types::HashPrefix;
error_chain!{}
pub struct FundingOutput {
pub txn_id: Sha256dHash,
pub height: i32,
@ -207,11 +209,11 @@ impl<'a> Query<'a> {
Some((merkle, pos))
}
pub fn update_mempool(&self) {
pub fn update_mempool(&self) -> Result<()> {
self.tracker
.write()
.unwrap()
.update(self.daemon)
.expect("failed to update mempool")
.chain_err(|| "failed to update mempool")
}
}