Merge branch 'master' into clippy

Conflicts:
	util/src/lib.rs
This commit is contained in:
Tomusdrw
2016-01-19 12:45:06 +01:00
19 changed files with 573 additions and 183 deletions

View File

@@ -236,7 +236,7 @@ mod tests {
#[test]
fn storage_at() {
let mut db = OverlayDB::new_temp();
let mut db = MemoryDB::new();
let rlp = {
let mut a = Account::new_contract(U256::from(69u8));
a.set_storage(H256::from(&U256::from(0x00u64)), H256::from(&U256::from(0x1234u64)));
@@ -254,7 +254,7 @@ mod tests {
#[test]
fn note_code() {
let mut db = OverlayDB::new_temp();
let mut db = MemoryDB::new();
let rlp = {
let mut a = Account::new_contract(U256::from(69u8));
@@ -273,7 +273,7 @@ mod tests {
#[test]
fn commit_storage() {
let mut a = Account::new_contract(U256::from(69u8));
let mut db = OverlayDB::new_temp();
let mut db = MemoryDB::new();
a.set_storage(x!(0), x!(0x1234));
assert_eq!(a.storage_root(), None);
a.commit_storage(&mut db);
@@ -283,7 +283,7 @@ mod tests {
#[test]
fn commit_remove_commit_storage() {
let mut a = Account::new_contract(U256::from(69u8));
let mut db = OverlayDB::new_temp();
let mut db = MemoryDB::new();
a.set_storage(x!(0), x!(0x1234));
a.commit_storage(&mut db);
a.set_storage(x!(1), x!(0x1234));
@@ -296,7 +296,7 @@ mod tests {
#[test]
fn commit_code() {
let mut a = Account::new_contract(U256::from(69u8));
let mut db = OverlayDB::new_temp();
let mut db = MemoryDB::new();
a.init_code(vec![0x55, 0x44, 0xffu8]);
assert_eq!(a.code_hash(), SHA3_EMPTY);
a.commit_code(&mut db);

View File

@@ -12,6 +12,7 @@ use util::*;
use ethcore::client::*;
use ethcore::service::ClientService;
use ethcore::ethereum;
use ethcore::blockchain::CacheSize;
use ethcore::sync::*;
fn setup_log() {
@@ -29,7 +30,7 @@ fn main() {
setup_log();
let spec = ethereum::new_frontier();
let mut service = ClientService::start(spec).unwrap();
let io_handler = Box::new(ClientIoHandler { client: service.client(), timer: 0 });
let io_handler = Box::new(ClientIoHandler { client: service.client(), timer: 0, info: Default::default() });
service.io().register_handler(io_handler).expect("Error registering IO handler");
loop {
let mut cmd = String::new();
@@ -40,10 +41,47 @@ fn main() {
}
}
#[derive(Default, Debug)]
struct Informant {
chain_info: Option<BlockChainInfo>,
cache_info: Option<CacheSize>,
report: Option<ClientReport>,
}
impl Informant {
pub fn tick(&mut self, client: &Client) {
// 5 seconds betwen calls. TODO: calculate this properly.
let dur = 5usize;
let chain_info = client.chain_info();
let cache_info = client.cache_info();
let report = client.report();
if let (_, &Some(ref last_cache_info), &Some(ref last_report)) = (&self.chain_info, &self.cache_info, &self.report) {
println!("[ {} {} ]---[ {} blk/s | {} tx/s | {} gas/s //···{}···// {} ({}) bl {} ({}) ex ]",
chain_info.best_block_number,
chain_info.best_block_hash,
(report.blocks_imported - last_report.blocks_imported) / dur,
(report.transactions_applied - last_report.transactions_applied) / dur,
(report.gas_processed - last_report.gas_processed) / From::from(dur),
0, // TODO: peers
cache_info.blocks,
cache_info.blocks as isize - last_cache_info.blocks as isize,
cache_info.block_details,
cache_info.block_details as isize - last_cache_info.block_details as isize
);
}
self.chain_info = Some(chain_info);
self.cache_info = Some(cache_info);
self.report = Some(report);
}
}
struct ClientIoHandler {
client: Arc<RwLock<Client>>,
timer: TimerToken,
info: Informant,
}
impl IoHandler<NetSyncMessage> for ClientIoHandler {
@@ -53,7 +91,9 @@ impl IoHandler<NetSyncMessage> for ClientIoHandler {
fn timeout<'s>(&'s mut self, _io: &mut IoContext<'s, NetSyncMessage>, timer: TimerToken) {
if self.timer == timer {
println!("Chain info: {:?}", self.client.read().unwrap().deref().chain_info());
let client = self.client.read().unwrap();
client.tick();
self.info.tick(client.deref());
}
}
}

View File

@@ -106,7 +106,7 @@ pub struct SealedBlock {
impl<'x, 'y> OpenBlock<'x, 'y> {
/// Create a new OpenBlock ready for transaction pushing.
pub fn new<'a, 'b>(engine: &'a Engine, db: OverlayDB, parent: &Header, last_hashes: &'b LastHashes, author: Address, extra_data: Bytes) -> OpenBlock<'a, 'b> {
pub fn new<'a, 'b>(engine: &'a Engine, db: JournalDB, parent: &Header, last_hashes: &'b LastHashes, author: Address, extra_data: Bytes) -> OpenBlock<'a, 'b> {
let mut r = OpenBlock {
block: Block::new(State::from_existing(db, parent.state_root().clone(), engine.account_start_nonce())),
engine: engine,
@@ -244,7 +244,7 @@ impl<'x, 'y> ClosedBlock<'x, 'y> {
pub fn reopen(self) -> OpenBlock<'x, 'y> { self.open_block }
/// Drop this object and return the underlieing database.
pub fn drain(self) -> OverlayDB { self.open_block.block.state.drop().1 }
pub fn drain(self) -> JournalDB { self.open_block.block.state.drop().1 }
}
impl SealedBlock {
@@ -259,7 +259,7 @@ impl SealedBlock {
}
/// Drop this object and return the underlieing database.
pub fn drain(self) -> OverlayDB { self.block.state.drop().1 }
pub fn drain(self) -> JournalDB { self.block.state.drop().1 }
}
impl IsBlock for SealedBlock {
@@ -267,7 +267,7 @@ impl IsBlock for SealedBlock {
}
/// Enact the block given by block header, transactions and uncles
pub fn enact<'x, 'y>(header: &Header, transactions: &[Transaction], uncles: &[Header], engine: &'x Engine, db: OverlayDB, parent: &Header, last_hashes: &'y LastHashes) -> Result<ClosedBlock<'x, 'y>, Error> {
pub fn enact<'x, 'y>(header: &Header, transactions: &[Transaction], uncles: &[Header], engine: &'x Engine, db: JournalDB, parent: &Header, last_hashes: &'y LastHashes) -> Result<ClosedBlock<'x, 'y>, Error> {
{
let s = State::from_existing(db.clone(), parent.state_root().clone(), engine.account_start_nonce());
trace!("enact(): root={}, author={}, author_balance={}\n", s.root(), header.author(), s.balance(&header.author()));
@@ -283,20 +283,20 @@ pub fn enact<'x, 'y>(header: &Header, transactions: &[Transaction], uncles: &[He
}
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
pub fn enact_bytes<'x, 'y>(block_bytes: &[u8], engine: &'x Engine, db: OverlayDB, parent: &Header, last_hashes: &'y LastHashes) -> Result<ClosedBlock<'x, 'y>, Error> {
pub fn enact_bytes<'x, 'y>(block_bytes: &[u8], engine: &'x Engine, db: JournalDB, parent: &Header, last_hashes: &'y LastHashes) -> Result<ClosedBlock<'x, 'y>, Error> {
let block = BlockView::new(block_bytes);
let header = block.header();
enact(&header, &block.transactions(), &block.uncles(), engine, db, parent, last_hashes)
}
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
pub fn enact_verified<'x, 'y>(block: &PreVerifiedBlock, engine: &'x Engine, db: OverlayDB, parent: &Header, last_hashes: &'y LastHashes) -> Result<ClosedBlock<'x, 'y>, Error> {
pub fn enact_verified<'x, 'y>(block: &PreVerifiedBlock, engine: &'x Engine, db: JournalDB, parent: &Header, last_hashes: &'y LastHashes) -> Result<ClosedBlock<'x, 'y>, Error> {
let view = BlockView::new(&block.bytes);
enact(&block.header, &block.transactions, &view.uncles(), engine, db, parent, last_hashes)
}
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header. Seal the block aferwards
pub fn enact_and_seal(block_bytes: &[u8], engine: &Engine, db: OverlayDB, parent: &Header, last_hashes: &LastHashes) -> Result<SealedBlock, Error> {
pub fn enact_and_seal(block_bytes: &[u8], engine: &Engine, db: JournalDB, parent: &Header, last_hashes: &LastHashes) -> Result<SealedBlock, Error> {
let header = BlockView::new(block_bytes).header_view();
Ok(try!(try!(enact_bytes(block_bytes, engine, db, parent, last_hashes)).seal(header.seal())))
}
@@ -306,7 +306,7 @@ fn open_block() {
use spec::*;
let engine = Spec::new_test().to_engine().unwrap();
let genesis_header = engine.spec().genesis_header();
let mut db = OverlayDB::new_temp();
let mut db = JournalDB::new_temp();
engine.spec().ensure_db_good(&mut db);
let last_hashes = vec![genesis_header.hash()];
let b = OpenBlock::new(engine.deref(), db, &genesis_header, &last_hashes, Address::zero(), vec![]);
@@ -320,13 +320,13 @@ fn enact_block() {
let engine = Spec::new_test().to_engine().unwrap();
let genesis_header = engine.spec().genesis_header();
let mut db = OverlayDB::new_temp();
let mut db = JournalDB::new_temp();
engine.spec().ensure_db_good(&mut db);
let b = OpenBlock::new(engine.deref(), db, &genesis_header, &vec![genesis_header.hash()], Address::zero(), vec![]).close().seal(vec![]).unwrap();
let orig_bytes = b.rlp_bytes();
let orig_db = b.drain();
let mut db = OverlayDB::new_temp();
let mut db = JournalDB::new_temp();
engine.spec().ensure_db_good(&mut db);
let e = enact_and_seal(&orig_bytes, engine.deref(), db, &genesis_header, &vec![genesis_header.hash()]).unwrap();

View File

@@ -30,6 +30,11 @@ pub struct CacheSize {
pub blocks_blooms: usize
}
impl CacheSize {
/// Total amount used by the cache.
fn total(&self) -> usize { self.blocks + self.block_details + self.transaction_addresses + self.block_logs + self.blocks_blooms }
}
/// Information about best block gathered together
struct BestBlock {
pub hash: H256,
@@ -96,6 +101,17 @@ pub trait BlockProvider {
}
}
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
enum CacheID {
Block(H256),
Extras(ExtrasIndex, H256),
}
struct CacheManager {
cache_usage: VecDeque<HashSet<CacheID>>,
in_use: HashSet<CacheID>,
}
/// Structure providing fast access to blockchain data.
///
/// **Does not do input data verification.**
@@ -113,7 +129,9 @@ pub struct BlockChain {
blocks_blooms: RwLock<HashMap<H256, BlocksBlooms>>,
extras_db: DB,
blocks_db: DB
blocks_db: DB,
cache_man: RwLock<CacheManager>,
}
impl BlockProvider for BlockChain {
@@ -135,6 +153,8 @@ impl BlockProvider for BlockChain {
let opt = self.blocks_db.get(hash)
.expect("Low level database error. Some issue with disk?");
self.note_used(CacheID::Block(hash.clone()));
match opt {
Some(b) => {
let bytes: Bytes = b.to_vec();
@@ -157,6 +177,10 @@ impl BlockProvider for BlockChain {
}
}
const COLLECTION_QUEUE_SIZE: usize = 2;
const MIN_CACHE_SIZE: usize = 1;
const MAX_CACHE_SIZE: usize = 1024 * 1024 * 1;
impl BlockChain {
/// Create new instance of blockchain from given Genesis
///
@@ -196,6 +220,9 @@ impl BlockChain {
blocks_path.push("blocks");
let blocks_db = DB::open_default(blocks_path.to_str().unwrap()).unwrap();
let mut cache_man = CacheManager{cache_usage: VecDeque::new(), in_use: HashSet::new()};
(0..COLLECTION_QUEUE_SIZE).foreach(|_| cache_man.cache_usage.push_back(HashSet::new()));
let bc = BlockChain {
best_block: RwLock::new(BestBlock::new()),
blocks: RwLock::new(HashMap::new()),
@@ -205,7 +232,8 @@ impl BlockChain {
block_logs: RwLock::new(HashMap::new()),
blocks_blooms: RwLock::new(HashMap::new()),
extras_db: extras_db,
blocks_db: blocks_db
blocks_db: blocks_db,
cache_man: RwLock::new(cache_man),
};
// load best block
@@ -250,7 +278,7 @@ impl BlockChain {
/// Ensure that the best block does indeed have a state_root in the state DB.
/// If it doesn't, then rewind down until we find one that does and delete data to ensure that
/// later blocks will be reimported.
pub fn ensure_good(&mut self, _state: &OverlayDB) {
pub fn ensure_good(&mut self, _state: &JournalDB) {
unimplemented!();
}
@@ -495,6 +523,10 @@ impl BlockChain {
}
}
if let Some(h) = hash.as_h256() {
self.note_used(CacheID::Extras(T::extras_index(), h.clone()));
}
self.extras_db.get_extras(hash).map(| t: T | {
let mut write = cache.write().unwrap();
write.insert(hash.clone(), t.clone());
@@ -534,6 +566,56 @@ impl BlockChain {
self.block_logs.write().unwrap().squeeze(size.block_logs);
self.blocks_blooms.write().unwrap().squeeze(size.blocks_blooms);
}
/// Let the cache system know that a cacheable item has been used.
fn note_used(&self, id: CacheID) {
let mut cache_man = self.cache_man.write().unwrap();
if !cache_man.cache_usage[0].contains(&id) {
cache_man.cache_usage[0].insert(id.clone());
if cache_man.in_use.contains(&id) {
if let Some(c) = cache_man.cache_usage.iter_mut().skip(1).find(|e|e.contains(&id)) {
c.remove(&id);
}
} else {
cache_man.in_use.insert(id);
}
}
}
/// Ticks our cache system and throws out any old data.
pub fn collect_garbage(&self, force: bool) {
// TODO: check time.
let timeout = true;
let t = self.cache_size().total();
if t < MIN_CACHE_SIZE || (!timeout && (!force || t < MAX_CACHE_SIZE)) { return; }
let mut cache_man = self.cache_man.write().unwrap();
let mut blocks = self.blocks.write().unwrap();
let mut block_details = self.block_details.write().unwrap();
let mut block_hashes = self.block_hashes.write().unwrap();
let mut transaction_addresses = self.transaction_addresses.write().unwrap();
let mut block_logs = self.block_logs.write().unwrap();
let mut blocks_blooms = self.blocks_blooms.write().unwrap();
for id in cache_man.cache_usage.pop_back().unwrap().into_iter() {
cache_man.in_use.remove(&id);
match id {
CacheID::Block(h) => { blocks.remove(&h); },
CacheID::Extras(ExtrasIndex::BlockDetails, h) => { block_details.remove(&h); },
CacheID::Extras(ExtrasIndex::TransactionAddress, h) => { transaction_addresses.remove(&h); },
CacheID::Extras(ExtrasIndex::BlockLogBlooms, h) => { block_logs.remove(&h); },
CacheID::Extras(ExtrasIndex::BlocksBlooms, h) => { blocks_blooms.remove(&h); },
_ => panic!(),
}
}
cache_man.cache_usage.push_front(HashSet::new());
// TODO: handle block_hashes properly.
block_hashes.clear();
// TODO: m_lastCollection = chrono::system_clock::now();
}
}
#[cfg(test)]

View File

@@ -1,7 +1,6 @@
use util::*;
use rocksdb::{Options, DB};
use rocksdb::DBCompactionStyle::DBUniversalCompaction;
use blockchain::{BlockChain, BlockProvider};
use blockchain::{BlockChain, BlockProvider, CacheSize};
use views::BlockView;
use error::*;
use header::BlockNumber;
@@ -41,6 +40,12 @@ pub struct BlockChainInfo {
pub best_block_number: BlockNumber
}
impl fmt::Display for BlockChainInfo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "#{}.{}", self.best_block_number, self.best_block_hash)
}
}
/// Block queue status
#[derive(Debug)]
pub struct BlockQueueStatus {
@@ -100,14 +105,32 @@ pub trait BlockChainClient : Sync + Send {
fn chain_info(&self) -> BlockChainInfo;
}
#[derive(Default, Clone, Debug, Eq, PartialEq)]
pub struct ClientReport {
pub blocks_imported: usize,
pub transactions_applied: usize,
pub gas_processed: U256,
}
impl ClientReport {
pub fn accrue_block(&mut self, block: &PreVerifiedBlock) {
self.blocks_imported += 1;
self.transactions_applied += block.transactions.len();
self.gas_processed += block.header.gas_used;
}
}
/// Blockchain database client backed by a persistent database. Owns and manages a blockchain and a block queue.
pub struct Client {
chain: Arc<RwLock<BlockChain>>,
engine: Arc<Box<Engine>>,
state_db: OverlayDB,
state_db: JournalDB,
queue: BlockQueue,
report: ClientReport,
}
const HISTORY: u64 = 1000;
impl Client {
/// Create a new client with given spec and DB path.
pub fn new(spec: Spec, path: &Path, message_channel: IoChannel<NetSyncMessage> ) -> Result<Client, Error> {
@@ -115,7 +138,7 @@ impl Client {
let mut opts = Options::new();
opts.create_if_missing(true);
opts.set_max_open_files(256);
opts.set_use_fsync(false);
/*opts.set_use_fsync(false);
opts.set_bytes_per_sync(8388608);
opts.set_disable_data_sync(false);
opts.set_block_cache_size_mb(1024);
@@ -130,16 +153,17 @@ impl Client {
opts.set_max_background_compactions(4);
opts.set_max_background_flushes(4);
opts.set_filter_deletes(false);
opts.set_disable_auto_compactions(true);
opts.set_disable_auto_compactions(false);*/
let mut state_path = path.to_path_buf();
state_path.push("state");
let db = DB::open(&opts, state_path.to_str().unwrap()).unwrap();
let mut state_db = OverlayDB::new(db);
let mut state_db = JournalDB::new(db);
let engine = Arc::new(try!(spec.to_engine()));
engine.spec().ensure_db_good(&mut state_db);
state_db.commit().expect("Error commiting genesis state to state DB");
if engine.spec().ensure_db_good(&mut state_db) {
state_db.commit(0, &engine.spec().genesis_header().hash(), None).expect("Error commiting genesis state to state DB");
}
// chain.write().unwrap().ensure_good(&state_db);
@@ -148,6 +172,7 @@ impl Client {
engine: engine.clone(),
state_db: state_db,
queue: BlockQueue::new(engine, message_channel),
report: Default::default(),
})
}
@@ -212,16 +237,34 @@ impl Client {
}
self.chain.write().unwrap().insert_block(&block.bytes); //TODO: err here?
match result.drain().commit() {
let ancient = if header.number() >= HISTORY { Some(header.number() - HISTORY) } else { None };
match result.drain().commit(header.number(), &header.hash(), ancient.map(|n|(n, self.chain.read().unwrap().block_hash(n).unwrap()))) {
Ok(_) => (),
Err(e) => {
warn!(target: "client", "State DB commit failed: {:?}", e);
return;
}
}
info!(target: "client", "Imported #{} ({})", header.number(), header.hash());
self.report.accrue_block(&block);
trace!(target: "client", "Imported #{} ({})", header.number(), header.hash());
}
}
/// Get info on the cache.
pub fn cache_info(&self) -> CacheSize {
self.chain.read().unwrap().cache_size()
}
/// Get the report.
pub fn report(&self) -> ClientReport {
self.report.clone()
}
/// Tick the client.
pub fn tick(&self) {
self.chain.read().unwrap().collect_garbage(false);
}
}
impl BlockChainClient for Client {

View File

@@ -216,7 +216,7 @@ fn on_close_block() {
use super::*;
let engine = new_morden().to_engine().unwrap();
let genesis_header = engine.spec().genesis_header();
let mut db = OverlayDB::new_temp();
let mut db = JournalDB::new_temp();
engine.spec().ensure_db_good(&mut db);
let last_hashes = vec![genesis_header.hash()];
let b = OpenBlock::new(engine.deref(), db, &genesis_header, &last_hashes, Address::zero(), vec![]);
@@ -229,7 +229,7 @@ fn on_close_block_with_uncle() {
use super::*;
let engine = new_morden().to_engine().unwrap();
let genesis_header = engine.spec().genesis_header();
let mut db = OverlayDB::new_temp();
let mut db = JournalDB::new_temp();
engine.spec().ensure_db_good(&mut db);
let last_hashes = vec![genesis_header.hash()];
let mut b = OpenBlock::new(engine.deref(), db, &genesis_header, &last_hashes, Address::zero(), vec![]);

View File

@@ -40,7 +40,7 @@ mod tests {
fn ensure_db_good() {
let engine = new_morden().to_engine().unwrap();
let genesis_header = engine.spec().genesis_header();
let mut db = OverlayDB::new_temp();
let mut db = JournalDB::new_temp();
engine.spec().ensure_db_good(&mut db);
let s = State::from_existing(db.clone(), genesis_header.state_root.clone(), engine.account_start_nonce());
assert_eq!(s.balance(&address_from_hex("0000000000000000000000000000000000000001")), U256::from(1u64));

View File

@@ -4,7 +4,6 @@ use common::*;
use evm;
use super::instructions as instructions;
use super::instructions::Instruction;
use std::num::wrapping::OverflowingOps;
use std::marker::Copy;
use evm::{MessageCallResult, ContractCreateResult};

View File

@@ -3,7 +3,7 @@ use header::BlockNumber;
use rocksdb::{DB, Writable};
/// Represents index of extra data in database
#[derive(Copy, Clone)]
#[derive(Copy, Debug, Hash, Eq, PartialEq, Clone)]
pub enum ExtrasIndex {
BlockDetails = 0,
BlockHash = 1,
@@ -59,6 +59,7 @@ impl ExtrasReadable for DB {
/// Implementations should convert arbitrary type to database key slice
pub trait ExtrasSliceConvertable {
fn to_extras_slice(&self, i: ExtrasIndex) -> H264;
fn as_h256(&self) -> Option<&H256> { None }
}
impl ExtrasSliceConvertable for H256 {
@@ -67,6 +68,7 @@ impl ExtrasSliceConvertable for H256 {
slice[32] = i as u8;
slice
}
fn as_h256(&self) -> Option<&H256> { Some(self) }
}
impl ExtrasSliceConvertable for U256 {

View File

@@ -1,9 +1,8 @@
#![feature(cell_extras)]
#![feature(augmented_assignments)]
#![feature(wrapping)]
//#![feature(plugin)]
//#![plugin(interpolate_idents)]
#![allow(match_bool, needless_range_loop, match_ref_pats)]
#![allow(match_bool, needless_range_loop)]
//! Ethcore's ethereum implementation
//!

View File

@@ -221,7 +221,7 @@ impl FromJson for Spec {
impl Spec {
/// Ensure that the given state DB has the trie nodes in for the genesis state.
pub fn ensure_db_good(&self, db: &mut HashDB) {
pub fn ensure_db_good(&self, db: &mut HashDB) -> bool {
if !db.contains(&self.state_root()) {
info!("Populating genesis state...");
let mut root = H256::new();
@@ -233,7 +233,8 @@ impl Spec {
}
assert!(db.contains(&self.state_root()));
info!("Genesis state is ready");
}
true
} else { false }
}
/// Create a new Spec from a JSON UTF-8 data resource `data`.

View File

@@ -10,7 +10,7 @@ pub type ApplyResult = Result<Receipt, Error>;
/// Representation of the entire state of all accounts in the system.
#[derive(Clone)]
pub struct State {
db: OverlayDB,
db: JournalDB,
root: H256,
cache: RefCell<HashMap<Address, Option<Account>>>,
@@ -19,7 +19,7 @@ pub struct State {
impl State {
/// Creates new state with empty state root
pub fn new(mut db: OverlayDB, account_start_nonce: U256) -> State {
pub fn new(mut db: JournalDB, account_start_nonce: U256) -> State {
let mut root = H256::new();
{
// init trie and reset root too null
@@ -35,7 +35,7 @@ impl State {
}
/// Creates new state with existing state root
pub fn from_existing(db: OverlayDB, root: H256, account_start_nonce: U256) -> State {
pub fn from_existing(db: JournalDB, root: H256, account_start_nonce: U256) -> State {
{
// trie should panic! if root does not exist
let _ = SecTrieDB::new(&db, &root);
@@ -51,11 +51,11 @@ impl State {
/// Create temporary state object
pub fn new_temp() -> State {
Self::new(OverlayDB::new_temp(), U256::from(0u8))
Self::new(JournalDB::new_temp(), U256::from(0u8))
}
/// Destroy the current object and return root and database.
pub fn drop(self) -> (H256, OverlayDB) {
pub fn drop(self) -> (H256, JournalDB) {
(self.root, self.db)
}
@@ -65,7 +65,7 @@ impl State {
}
/// Expose the underlying database; good to use for calling `state.db().commit()`.
pub fn db(&mut self) -> &mut OverlayDB {
pub fn db(&mut self) -> &mut JournalDB {
&mut self.db
}

View File

@@ -472,7 +472,7 @@ impl ChainSync {
pub fn on_peer_aborting(&mut self, io: &mut SyncIo, peer: PeerId) {
trace!(target: "sync", "== Disconnecting {}", peer);
if self.peers.contains_key(&peer) {
info!(target: "sync", "Disconneced {}:{}", peer, io.peer_info(peer));
info!(target: "sync", "Disconnected {}:{}", peer, io.peer_info(peer));
self.clear_peer_download(peer);
self.peers.remove(&peer);
self.continue_sync(io);