Skip to content

Commit

Permalink
make it compile
Browse files Browse the repository at this point in the history
  • Loading branch information
ordian committed Jul 31, 2018
1 parent 294c313 commit 3d3991e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
10 changes: 4 additions & 6 deletions ethcore/light/src/client/snapshot/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ use client::header_chain::PendingChanges;
use ethcore::engines::EpochTransition;
use ethcore::ids::BlockId;
use ethcore::header::{Header, BlockNumber};
use ethcore::encoded;
use ethcore::snapshot::RestorationTargetChain;
use ethereum_types::{H256, U256};
use parking_lot::RwLock;
use kvdb::DBTransaction;
use ethcore::receipt::Receipt;
use ethcore::views::BlockView;

/// Wrapper for `HeaderChain` along with pending changes.
pub struct LightChain {
Expand Down Expand Up @@ -95,16 +95,14 @@ impl RestorationTargetChain for LightChain {
fn insert_unordered_block(
&self,
batch: &mut DBTransaction,
bytes: &[u8],
block: encoded::Block,
_receipts: Vec<Receipt>,
parent_td: Option<U256>,
_is_best: bool,
_is_ancient: bool,
) -> bool {
let block = view!(BlockView, bytes);
let header = block.header();
let td = parent_td.map(|pd| pd + *header.difficulty());
let result = self.chain.insert_inner(batch, header, td, None, true);
let td = parent_td.map(|pd| pd + block.header().difficulty());
let result = self.chain.insert_inner(batch, block.decode_header(), td, None, true);
let pending = result.expect("we either supply the total difficulty, or the parent is present; qed");
*self.pending.write() = Some(pending);
parent_td.is_some()
Expand Down
1 change: 0 additions & 1 deletion ethcore/light/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ extern crate ethcore_network as network;
extern crate parity_bytes as bytes;
extern crate ethcore_transaction as transaction;
extern crate ethereum_types;
#[macro_use]
extern crate ethcore;
extern crate hashdb;
extern crate heapsize;
Expand Down
29 changes: 21 additions & 8 deletions ethcore/src/snapshot/consensus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ use std::sync::atomic::AtomicBool;
use std::sync::Arc;

use types::{BlockNumber, receipt::Receipt};
use header::Header;
use blockchain::{BlockChain, BlockChainDB, BlockProvider};
use encoded;
use engines::{EthEngine, EpochTransition};
use header::Header;
use snapshot::{Error, ManifestData};

use ethereum_types::{H256, U256};
Expand Down Expand Up @@ -82,8 +83,10 @@ pub trait RestorationTargetChain: Send {
///
/// The block the transition occurred at should have already been inserted into the chain.
fn insert_epoch_transition(
&self, batch: &mut DBTransaction,
header: Header, transition: EpochTransition
&self,
batch: &mut DBTransaction,
header: Header,
transition: EpochTransition,
);

/// Inserts a verified, known block from the canonical chain.
Expand All @@ -96,8 +99,13 @@ pub trait RestorationTargetChain: Send {
/// Supply a dummy parent total difficulty when the parent block may not be in the chain.
/// Returns true if the block is disconnected.
fn insert_unordered_block(
&self, batch: &mut DBTransaction, bytes: &[u8], receipts: Vec<Receipt>,
parent_td: Option<U256>, is_best: bool, is_ancient: bool
&self,
batch: &mut DBTransaction,
block: encoded::Block,
receipts: Vec<Receipt>,
parent_td: Option<U256>,
is_best: bool,
is_ancient: bool,
) -> bool;

/// Apply pending insertion updates.
Expand Down Expand Up @@ -177,10 +185,15 @@ impl RestorationTargetChain for BlockChain {
}

fn insert_unordered_block(
&self, batch: &mut DBTransaction, bytes: &[u8], receipts: Vec<Receipt>,
parent_td: Option<U256>, is_best: bool, is_ancient: bool
&self,
batch: &mut DBTransaction,
block: encoded::Block,
receipts: Vec<Receipt>,
parent_td: Option<U256>,
is_best: bool,
is_ancient: bool,
) -> bool {
BlockChain::insert_unordered_block(self, batch, bytes, receipts, parent_td, is_best, is_ancient)
BlockChain::insert_unordered_block(self, batch, block, receipts, parent_td, is_best, is_ancient)
}

fn commit(&self) {
Expand Down

0 comments on commit 3d3991e

Please sign in to comment.