Fix import for bcMultiChainTest.

Fixes #223
This commit is contained in:
Gav Wood
2016-01-27 13:28:15 +01:00
parent e904d2145f
commit fe0363e230
6 changed files with 39 additions and 27 deletions

View File

@@ -415,7 +415,7 @@ impl ChainSync {
Err(ImportError::AlreadyQueued) => {
trace!(target: "sync", "New block already queued {:?}", h);
},
Ok(()) => {
Ok(_) => {
trace!(target: "sync", "New block queued {:?}", h);
},
Err(e) => {
@@ -680,7 +680,7 @@ impl ChainSync {
self.last_imported_block = headers.0 + i as BlockNumber;
self.last_imported_hash = h.clone();
},
Ok(()) => {
Ok(_) => {
trace!(target: "sync", "Block queued {:?}", h);
self.last_imported_block = headers.0 + i as BlockNumber;
self.last_imported_hash = h.clone();

View File

@@ -114,6 +114,7 @@ impl BlockChainClient for TestBlockChainClient {
fn import_block(&self, b: Bytes) -> ImportResult {
let header = Rlp::new(&b).val_at::<BlockHeader>(0);
let h = header.hash();
let number: usize = header.number as usize;
if number > self.blocks.read().unwrap().len() {
panic!("Unexpected block number. Expected {}, got {}", self.blocks.read().unwrap().len(), number);
@@ -134,9 +135,9 @@ impl BlockChainClient for TestBlockChainClient {
let len = self.numbers.read().unwrap().len();
if number == len {
*self.difficulty.write().unwrap().deref_mut() += header.difficulty;
mem::replace(self.last_hash.write().unwrap().deref_mut(), header.hash());
self.blocks.write().unwrap().insert(header.hash(), b);
self.numbers.write().unwrap().insert(number, header.hash());
mem::replace(self.last_hash.write().unwrap().deref_mut(), h.clone());
self.blocks.write().unwrap().insert(h.clone(), b);
self.numbers.write().unwrap().insert(number, h.clone());
let mut parent_hash = header.parent_hash;
if number > 0 {
let mut n = number - 1;
@@ -148,9 +149,9 @@ impl BlockChainClient for TestBlockChainClient {
}
}
else {
self.blocks.write().unwrap().insert(header.hash(), b.to_vec());
self.blocks.write().unwrap().insert(h.clone(), b.to_vec());
}
Ok(())
Ok(h)
}
fn queue_info(&self) -> BlockQueueInfo {