Misc fixes (#11510)
* Misc fixes Did some code reading and made random changes as I went. * Update ethcore/src/client/client.rs Co-Authored-By: Andronik Ordian <write@reusable.software> Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
@@ -35,7 +35,7 @@ use std::{cmp, ops};
|
||||
use std::sync::Arc;
|
||||
|
||||
use bytes::Bytes;
|
||||
use ethereum_types::{H256, U256, Address, Bloom};
|
||||
use ethereum_types::{U256, Address, Bloom};
|
||||
|
||||
use engine::Engine;
|
||||
use trie_vm_factories::Factories;
|
||||
@@ -168,7 +168,7 @@ impl<'x> OpenBlock<'x> {
|
||||
/// Push a transaction into the block.
|
||||
///
|
||||
/// If valid, it will be executed, and archived together with the receipt.
|
||||
pub fn push_transaction(&mut self, t: SignedTransaction, h: Option<H256>) -> Result<&Receipt, Error> {
|
||||
pub fn push_transaction(&mut self, t: SignedTransaction) -> Result<&Receipt, Error> {
|
||||
if self.block.transactions_set.contains(&t.hash()) {
|
||||
return Err(TransactionError::AlreadyImported.into());
|
||||
}
|
||||
@@ -176,7 +176,7 @@ impl<'x> OpenBlock<'x> {
|
||||
let env_info = self.block.env_info();
|
||||
let outcome = self.block.state.apply(&env_info, self.engine.machine(), &t, self.block.traces.is_enabled())?;
|
||||
|
||||
self.block.transactions_set.insert(h.unwrap_or_else(||t.hash()));
|
||||
self.block.transactions_set.insert(t.hash());
|
||||
self.block.transactions.push(t.into());
|
||||
if let Tracing::Enabled(ref mut traces) = self.block.traces {
|
||||
traces.push(outcome.trace.into());
|
||||
@@ -189,7 +189,7 @@ impl<'x> OpenBlock<'x> {
|
||||
#[cfg(not(feature = "slow-blocks"))]
|
||||
fn push_transactions(&mut self, transactions: Vec<SignedTransaction>) -> Result<(), Error> {
|
||||
for t in transactions {
|
||||
self.push_transaction(t, None)?;
|
||||
self.push_transaction(t)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -203,7 +203,7 @@ impl<'x> OpenBlock<'x> {
|
||||
for t in transactions {
|
||||
let hash = t.hash();
|
||||
let start = time::Instant::now();
|
||||
self.push_transaction(t, None)?;
|
||||
self.push_transaction(t)?;
|
||||
let took = start.elapsed();
|
||||
let took_ms = took.as_secs() * 1000 + took.subsec_nanos() as u64 / 1000000;
|
||||
if took > time::Duration::from_millis(slow_tx) {
|
||||
|
||||
@@ -742,7 +742,7 @@ impl Client {
|
||||
let chain = Arc::new(BlockChain::new(config.blockchain.clone(), &gb, db.clone()));
|
||||
let tracedb = RwLock::new(TraceDB::new(config.tracing.clone(), db.clone(), chain.clone()));
|
||||
|
||||
trace!("Cleanup journal: DB Earliest = {:?}, Latest = {:?}", state_db.journal_db().earliest_era(), state_db.journal_db().latest_era());
|
||||
debug!(target: "client", "Cleanup journal: DB Earliest = {:?}, Latest = {:?}", state_db.journal_db().earliest_era(), state_db.journal_db().latest_era());
|
||||
|
||||
let history = if config.history < MIN_HISTORY_SIZE {
|
||||
info!(target: "client", "Ignoring pruning history parameter of {}\
|
||||
@@ -942,7 +942,6 @@ impl Client {
|
||||
let (result, items) = self.prove_transaction(tx, id)
|
||||
.ok_or_else(|| "Unable to make call. State unavailable?".to_string())?;
|
||||
|
||||
let items = items.into_iter().map(|x| x.to_vec()).collect();
|
||||
Ok((result, items))
|
||||
};
|
||||
|
||||
@@ -1070,6 +1069,7 @@ impl Client {
|
||||
|
||||
// early exit for pruned blocks
|
||||
if db.is_prunable() && self.pruning_info().earliest_state > block_number {
|
||||
trace!(target: "client", "State for block #{} is pruned. Earliest state: {:?}", block_number, self.pruning_info().earliest_state);
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ pub struct ClientConfig {
|
||||
pub spec_name: String,
|
||||
/// Type of block verifier used by client.
|
||||
pub verifier_type: VerifierType,
|
||||
/// State db cache-size.
|
||||
/// State db cache-size. Default: 25Mb.
|
||||
pub state_cache_size: usize,
|
||||
/// EVM jump-tables cache size.
|
||||
pub jump_table_size: usize,
|
||||
|
||||
@@ -535,7 +535,7 @@ impl Miner {
|
||||
let result = client.verify_for_pending_block(&transaction, &open_block.header)
|
||||
.map_err(|e| e.into())
|
||||
.and_then(|_| {
|
||||
open_block.push_transaction(transaction, None)
|
||||
open_block.push_transaction(transaction)
|
||||
});
|
||||
|
||||
let took = start.elapsed();
|
||||
|
||||
@@ -190,7 +190,7 @@ pub fn generate_dummy_client_with_spec_and_data<F>(
|
||||
action: Action::Create,
|
||||
data: vec![],
|
||||
value: U256::zero(),
|
||||
}.sign(kp.secret(), Some(test_spec.chain_id())), None).unwrap();
|
||||
}.sign(kp.secret(), Some(test_spec.chain_id()))).unwrap();
|
||||
n += 1;
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ pub fn push_block_with_transactions(client: &Arc<Client>, transactions: &[Signed
|
||||
b.set_timestamp(block_number * 10);
|
||||
|
||||
for t in transactions {
|
||||
b.push_transaction(t.clone(), None).unwrap();
|
||||
b.push_transaction(t.clone()).unwrap();
|
||||
}
|
||||
let b = b.close_and_lock().unwrap().seal(test_engine, vec![]).unwrap();
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ fn can_trace_block_and_uncle_reward() {
|
||||
action: Action::Create,
|
||||
data: vec![],
|
||||
value: U256::zero(),
|
||||
}.sign(kp.secret(), Some(spec.network_id())), None).unwrap();
|
||||
}.sign(kp.secret(), Some(spec.network_id()))).unwrap();
|
||||
n += 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user