mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 01:43:29 +01:00
Let query module return errors
This commit is contained in:
parent
4b0f3d470d
commit
b6d664c580
@ -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);
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user