Unverified Commit 0d56b2ec authored by Roman Zeyde's avatar Roman Zeyde
Browse files

Use one error_chain definition

parent a30f492d
......@@ -11,7 +11,7 @@ use std::time::Duration;
use daemon::Network;
use {daemon, index, query, rpc, store};
error_chain!{}
use errors::*;
#[derive(Debug)]
struct Config {
......@@ -83,7 +83,7 @@ impl App {
&self.daemon
}
fn update_index(&self, mut tip: Sha256dHash) -> Result<Sha256dHash> {
if tip != self.daemon.getbestblockhash().chain_err(|| "daemon error")? {
if tip != self.daemon.getbestblockhash()? {
tip = self.index.update(&self.store, &self.daemon);
}
Ok(tip)
......@@ -92,7 +92,7 @@ impl App {
fn run_server(config: &Config) -> Result<()> {
let index = index::Index::new();
let daemon = daemon::Daemon::new(config.network_type).chain_err(|| "cannot connect to daemon")?;
let daemon = daemon::Daemon::new(config.network_type)?;
let store = store::DBStore::open(
config.db_path,
......@@ -117,9 +117,7 @@ fn run_server(config: &Config) -> Result<()> {
rpc::start(&config.rpc_addr, query.clone());
loop {
thread::sleep(poll_delay);
query
.update_mempool()
.chain_err(|| "mempool update failed")?;
query.update_mempool()?;
tip = app.update_index(tip)?;
}
}
......
......@@ -13,7 +13,7 @@ use std::net::TcpStream;
use util::{HeaderList, HeaderMap};
error_chain!{}
use errors::*;
#[derive(Debug, Copy, Clone)]
pub enum Network {
......
error_chain!{
types {
Error, ErrorKind, ResultExt, Result;
}
}
......@@ -27,6 +27,7 @@ extern crate serde_json;
pub mod app;
mod daemon;
mod errors;
mod index;
mod mempool;
mod query;
......
......@@ -12,7 +12,7 @@ use index::index_transaction;
use store::{ReadStore, Row};
use util::Bytes;
error_chain!{}
use errors::*;
const VSIZE_BIN_WIDTH: u32 = 100_000; // in vbytes
......
......@@ -13,7 +13,7 @@ use mempool::Tracker;
use store::ReadStore;
use util::{FullHash, HashPrefix, HeaderEntry};
error_chain!{}
use errors::*;
struct FundingOutput {
txn_id: Sha256dHash,
......@@ -308,11 +308,7 @@ impl Query {
}
pub fn update_mempool(&self) -> Result<()> {
self.tracker
.write()
.unwrap()
.update(self.app.daemon())
.chain_err(|| "failed to update mempool")
self.tracker.write().unwrap().update(self.app.daemon())
}
/// Returns [vsize, fee_rate] pairs (measured in vbytes and satoshis).
......
......@@ -16,7 +16,7 @@ use std::time::Duration;
use query::Query;
use util::HeaderEntry;
error_chain!{}
use errors::*;
// TODO: Sha256dHash should be a generic hash-container (since script hash is single SHA256)
fn hash_from_value(val: Option<&Value>) -> Result<Sha256dHash> {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment