duration_ns: u64 -> duration: Duration (#8457)
* duration_ns: u64 -> duration: Duration
* format on millis {:.2} -> {}
This commit is contained in:
committed by
Afri Schoedon
parent
01d399ad66
commit
e36c4ecc98
@@ -17,6 +17,7 @@
|
||||
use bytes::Bytes;
|
||||
use ethereum_types::H256;
|
||||
use transaction::UnverifiedTransaction;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Messages to broadcast via chain
|
||||
pub enum ChainMessageType {
|
||||
@@ -40,7 +41,7 @@ pub trait ChainNotify : Send + Sync {
|
||||
_sealed: Vec<H256>,
|
||||
// Block bytes.
|
||||
_proposed: Vec<Bytes>,
|
||||
_duration: u64,
|
||||
_duration: Duration,
|
||||
) {
|
||||
// does nothing by default
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ use std::collections::{HashSet, HashMap, BTreeMap, VecDeque};
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Arc, Weak};
|
||||
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering};
|
||||
use std::time::{Instant};
|
||||
use std::time::{Instant, Duration};
|
||||
use itertools::Itertools;
|
||||
|
||||
// util
|
||||
@@ -32,7 +32,7 @@ use util_error::UtilError;
|
||||
// other
|
||||
use ethereum_types::{H256, Address, U256};
|
||||
use block::{IsBlock, LockedBlock, Drain, ClosedBlock, OpenBlock, enact_verified, SealedBlock};
|
||||
use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute, TransactionAddress};
|
||||
use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute, TransactionAddress};
|
||||
use client::ancient_import::AncientVerifier;
|
||||
use client::Error as ClientError;
|
||||
use client::{
|
||||
@@ -120,7 +120,7 @@ impl<'a> ::std::ops::Sub<&'a ClientReport> for ClientReport {
|
||||
self.blocks_imported -= other.blocks_imported;
|
||||
self.transactions_applied -= other.transactions_applied;
|
||||
self.gas_processed = self.gas_processed - other.gas_processed;
|
||||
self.state_db_mem = higher_mem - lower_mem;
|
||||
self.state_db_mem = higher_mem - lower_mem;
|
||||
|
||||
self
|
||||
}
|
||||
@@ -331,11 +331,7 @@ impl Importer {
|
||||
self.block_queue.mark_as_bad(&invalid_blocks);
|
||||
}
|
||||
let is_empty = self.block_queue.mark_as_good(&imported_blocks);
|
||||
let duration_ns = {
|
||||
let elapsed = start.elapsed();
|
||||
elapsed.as_secs() * 1_000_000_000 + elapsed.subsec_nanos() as u64
|
||||
};
|
||||
(imported_blocks, import_results, invalid_blocks, imported, proposed_blocks, duration_ns, is_empty)
|
||||
(imported_blocks, import_results, invalid_blocks, imported, proposed_blocks, start.elapsed(), is_empty)
|
||||
};
|
||||
|
||||
{
|
||||
@@ -1434,7 +1430,7 @@ impl ImportBlock for Client {
|
||||
bail!(BlockImportErrorKind::Import(ImportErrorKind::AlreadyInChain));
|
||||
}
|
||||
let status = self.block_status(BlockId::Hash(header.parent_hash()));
|
||||
if status == BlockStatus::Unknown || status == BlockStatus::Pending {
|
||||
if status == BlockStatus::Unknown || status == BlockStatus::Pending {
|
||||
bail!(BlockImportErrorKind::Block(BlockError::UnknownParent(header.parent_hash())));
|
||||
}
|
||||
}
|
||||
@@ -1497,7 +1493,7 @@ impl Call for Client {
|
||||
}
|
||||
|
||||
fn estimate_gas(&self, t: &SignedTransaction, state: &Self::State, header: &Header) -> Result<U256, CallError> {
|
||||
let (mut upper, max_upper, env_info) = {
|
||||
let (mut upper, max_upper, env_info) = {
|
||||
let init = *header.gas_limit();
|
||||
let max = init * U256::from(10);
|
||||
|
||||
@@ -2096,10 +2092,7 @@ impl ImportSealedBlock for Client {
|
||||
retracted.clone(),
|
||||
vec![h.clone()],
|
||||
vec![],
|
||||
{
|
||||
let elapsed = start.elapsed();
|
||||
elapsed.as_secs() * 1_000_000_000 + elapsed.subsec_nanos() as u64
|
||||
},
|
||||
start.elapsed(),
|
||||
);
|
||||
});
|
||||
self.db.read().flush().expect("DB flush failed.");
|
||||
@@ -2109,6 +2102,7 @@ impl ImportSealedBlock for Client {
|
||||
|
||||
impl BroadcastProposalBlock for Client {
|
||||
fn broadcast_proposal_block(&self, block: SealedBlock) {
|
||||
const DURATION_ZERO: Duration = Duration::from_millis(0);
|
||||
self.notify(|notify| {
|
||||
notify.new_blocks(
|
||||
vec![],
|
||||
@@ -2117,7 +2111,7 @@ impl BroadcastProposalBlock for Client {
|
||||
vec![],
|
||||
vec![],
|
||||
vec![block.rlp_bytes()],
|
||||
0,
|
||||
DURATION_ZERO,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user