Merge branch 'consistent-id' into check-updates

This commit is contained in:
Gav Wood
2016-12-09 23:12:36 +01:00
18 changed files with 317 additions and 107 deletions

View File

@@ -283,6 +283,11 @@ impl Client {
self.notify.write().push(Arc::downgrade(&target));
}
/// Returns engine reference.
pub fn engine(&self) -> &Engine {
&*self.engine
}
fn notify<F>(&self, f: F) where F: Fn(&ChainNotify) {
for np in self.notify.read().iter() {
if let Some(n) = np.upgrade() {
@@ -596,6 +601,11 @@ impl Client {
results.len()
}
/// Get shared miner reference.
pub fn miner(&self) -> Arc<Miner> {
self.miner.clone()
}
/// Used by PoA to try sealing on period change.
pub fn update_sealing(&self) {
self.miner.update_sealing(self)
@@ -748,7 +758,7 @@ impl Client {
self.updater.lock()
}
/// Look up the block number for the given block Id.
/// Look up the block number for the given block ID.
pub fn block_number(&self, id: BlockId) -> Option<BlockNumber> {
match id {
BlockId::Number(number) => Some(number),
@@ -759,7 +769,7 @@ impl Client {
}
/// Take a snapshot at the given block.
/// If the Id given is "latest", this will default to 1000 blocks behind.
/// If the ID given is "latest", this will default to 1000 blocks behind.
pub fn take_snapshot<W: snapshot_io::SnapshotWriter + Send>(&self, writer: W, at: BlockId, p: &snapshot::Progress) -> Result<(), EthcoreError> {
let db = self.state_db.lock().journal_db().boxed_clone();
let best_block_number = self.chain_info().best_block_number;
@@ -1507,4 +1517,4 @@ mod tests {
assert!(client.tree_route(&genesis, &new_hash).is_none());
}
}
}

View File

@@ -255,7 +255,7 @@ impl TestBlockChainClient {
}
/// Make a bad block by setting invalid extra data.
pub fn corrupt_block(&mut self, n: BlockNumber) {
pub fn corrupt_block(&self, n: BlockNumber) {
let hash = self.block_hash(BlockId::Number(n)).unwrap();
let mut header: BlockHeader = decode(&self.block_header(BlockId::Number(n)).unwrap());
header.set_extra_data(b"This extra data is way too long to be considered valid".to_vec());
@@ -267,7 +267,7 @@ impl TestBlockChainClient {
}
/// Make a bad block by setting invalid parent hash.
pub fn corrupt_block_parent(&mut self, n: BlockNumber) {
pub fn corrupt_block_parent(&self, n: BlockNumber) {
let hash = self.block_hash(BlockId::Number(n)).unwrap();
let mut header: BlockHeader = decode(&self.block_header(BlockId::Number(n)).unwrap());
header.set_parent_hash(H256::from(42));