Remove unwrap() and add tx. pool error member to Error enum (#1839)

This commit is contained in:
eupn 2018-10-25 17:00:39 +03:00 committed by hashmap
parent 711fad6c24
commit 58e68a867e
2 changed files with 9 additions and 2 deletions

View file

@ -44,6 +44,8 @@ pub enum Error {
Wallet(wallet::Error), Wallet(wallet::Error),
/// Error originating from the cuckoo miner /// Error originating from the cuckoo miner
Cuckoo(pow::Error), Cuckoo(pow::Error),
/// Error originating from the transaction pool.
Pool(pool::PoolError),
} }
impl From<core::block::Error> for Error { impl From<core::block::Error> for Error {
@ -87,6 +89,12 @@ impl From<wallet::Error> for Error {
} }
} }
impl From<pool::PoolError> for Error {
fn from(e: pool::PoolError) -> Error {
Error::Pool(e)
}
}
/// Type of seeding the server will use to find other peers on the network. /// Type of seeding the server will use to find other peers on the network.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum ChainValidationMode { pub enum ChainValidationMode {

View file

@ -108,8 +108,7 @@ fn build_block(
let difficulty = consensus::next_difficulty(head.height + 1, chain.difficulty_iter()); let difficulty = consensus::next_difficulty(head.height + 1, chain.difficulty_iter());
// extract current transaction from the pool // extract current transaction from the pool
// TODO - we have a lot of unwrap() going on in this fn... let txs = tx_pool.read().prepare_mineable_transactions()?;
let txs = tx_pool.read().prepare_mineable_transactions().unwrap();
// build the coinbase and the block itself // build the coinbase and the block itself
let fees = txs.iter().map(|tx| tx.fee()).sum(); let fees = txs.iter().map(|tx| tx.fee()).sum();