refactoring to hold miner within the client

This commit is contained in:
Nikolay Volf
2016-05-31 19:01:37 +02:00
parent 0cd8644292
commit 4f732972bc
8 changed files with 42 additions and 47 deletions

View File

@@ -903,7 +903,7 @@ impl ChainSync {
nonce: chain.latest_nonce(a),
balance: chain.latest_balance(a),
};
let _ = self.miner.import_transactions(transactions, fetch_account);
let _ = io.chain().import_transactions(transactions, fetch_account);
Ok(())
}
@@ -1226,7 +1226,7 @@ impl ChainSync {
return 0;
}
let mut transactions = self.miner.all_transactions();
let mut transactions = io.chain().all_transactions();
if transactions.is_empty() {
return 0;
}
@@ -1275,24 +1275,6 @@ impl ChainSync {
pub fn maintain_sync(&mut self, io: &mut SyncIo) {
self.check_resume(io);
}
/// called when block is imported to chain, updates transactions queue and propagates the blocks
pub fn chain_new_blocks(&mut self, io: &mut SyncIo, imported: &[H256], invalid: &[H256], enacted: &[H256], retracted: &[H256]) {
if io.is_chain_queue_empty() {
// Notify miner
self.miner.chain_new_blocks(io.chain(), imported, invalid, enacted, retracted);
// Propagate latests blocks
self.propagate_latest_blocks(io);
}
if !invalid.is_empty() {
trace!(target: "sync", "Bad blocks in the queue, restarting");
self.restart_on_bad_block(io);
}
}
pub fn chain_new_head(&mut self, io: &mut SyncIo) {
self.miner.update_sealing(io.chain());
}
}
#[cfg(test)]