Remove unwrap() and add tx. pool error member to Error enum (#1839)
This commit is contained in:
@@ -44,6 +44,8 @@ pub enum Error {
|
||||
Wallet(wallet::Error),
|
||||
/// Error originating from the cuckoo miner
|
||||
Cuckoo(pow::Error),
|
||||
/// Error originating from the transaction pool.
|
||||
Pool(pool::PoolError),
|
||||
}
|
||||
|
||||
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.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub enum ChainValidationMode {
|
||||
|
||||
@@ -108,8 +108,7 @@ fn build_block(
|
||||
let difficulty = consensus::next_difficulty(head.height + 1, chain.difficulty_iter());
|
||||
|
||||
// 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().unwrap();
|
||||
let txs = tx_pool.read().prepare_mineable_transactions()?;
|
||||
|
||||
// build the coinbase and the block itself
|
||||
let fees = txs.iter().map(|tx| tx.fee()).sum();
|
||||
|
||||
Reference in New Issue
Block a user