Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

transaction count verifier tests #1196

Merged
merged 6 commits into from
Jun 1, 2016
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions miner/src/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use rayon::prelude::*;
use std::sync::atomic::AtomicBool;

use util::*;
use util::keys::store::{AccountService, AccountProvider};
use util::keys::store::AccountProvider;
use ethcore::views::{BlockView, HeaderView};
use ethcore::client::{BlockChainClient, BlockID};
use ethcore::block::{ClosedBlock, IsBlock};
use ethcore::error::*;
use ethcore::client::{Executive, Executed, EnvInfo, TransactOptions};
use ethcore::transaction::SignedTransaction;
use ethcore::receipt::{Receipt};
use ethcore::receipt::Receipt;
use ethcore::spec::Spec;
use ethcore::engine::Engine;
use super::{MinerService, MinerStatus, TransactionQueue, AccountDetails, TransactionImportResult, TransactionOrigin};
Expand All @@ -44,7 +44,7 @@ pub struct Miner {
extra_data: RwLock<Bytes>,
spec: Spec,

accounts: RwLock<Option<Arc<AccountService>>>, // TODO: this is horrible since AccountService already contains a single RwLock field. refactor.
accounts: Option<Arc<AccountProvider>>,
}

impl Default for Miner {
Expand All @@ -58,7 +58,7 @@ impl Default for Miner {
gas_floor_target: RwLock::new(U256::zero()),
author: RwLock::new(Address::default()),
extra_data: RwLock::new(Vec::new()),
accounts: RwLock::new(None),
accounts: None,
spec: Spec::new_test(),
}
}
Expand All @@ -76,13 +76,13 @@ impl Miner {
gas_floor_target: RwLock::new(U256::zero()),
author: RwLock::new(Address::default()),
extra_data: RwLock::new(Vec::new()),
accounts: RwLock::new(None),
accounts: None,
spec: spec,
})
}

/// Creates new instance of miner
pub fn with_accounts(force_sealing: bool, spec: Spec, accounts: Arc<AccountService>) -> Arc<Miner> {
pub fn with_accounts(force_sealing: bool, spec: Spec, accounts: Arc<AccountProvider>) -> Arc<Miner> {
Arc::new(Miner {
transaction_queue: Mutex::new(TransactionQueue::new()),
force_sealing: force_sealing,
Expand All @@ -92,7 +92,7 @@ impl Miner {
gas_floor_target: RwLock::new(U256::zero()),
author: RwLock::new(Address::default()),
extra_data: RwLock::new(Vec::new()),
accounts: RwLock::new(Some(accounts)),
accounts: Some(accounts),
spec: spec,
})
}
Expand Down Expand Up @@ -177,9 +177,8 @@ impl Miner {
if !block.transactions().is_empty() {
trace!(target: "miner", "prepare_sealing: block has transaction - attempting internal seal.");
// block with transactions - see if we can seal immediately.
let a = self.accounts.read().unwrap();
let s = self.engine().generate_seal(block.block(), match *a.deref() {
Some(ref x) => Some(x.deref() as &AccountProvider),
let s = self.engine().generate_seal(block.block(), match self.accounts {
Some(ref x) => Some(&**x),
None => None,
});
if let Some(seal) = s {
Expand Down
Loading