Fixed consensus error. Added a delay before signing.

pull/61/head
Revertron 3 years ago
parent 3f48919adf
commit 2680a7da70

@ -212,6 +212,12 @@ impl Chain {
trace!("Block {} has enough signing blocks", block.index);
return None;
}
if let Some(block) = &self.last_block {
if block.timestamp + 60 > Utc::now().timestamp() {
info!("Waiting for other blocks before signing.");
return None;
}
}
let keystore = keystore.clone().unwrap().clone();
let signers: HashSet<Bytes> = self.get_block_signers(&block).into_iter().collect();
if signers.contains(&keystore.get_public()) {
@ -645,6 +651,10 @@ impl Chain {
warn!("Ignoring block from the future:\n{:?}", &block);
return Bad;
}
if block.index > self.height() + 1 {
info!("Ignoring future block:\n{:?}", &block);
return Future;
}
if !check_public_key_strength(&block.pub_key, KEYSTORE_DIFFICULTY) {
warn!("Ignoring block with weak public key:\n{:?}", &block);
return Bad;
@ -675,6 +685,12 @@ impl Chain {
warn!("Block {:?} has wrong signature! Ignoring!", &block);
return Bad;
}
if let Some(prev_block) = self.get_block(block.index - 1) {
if block.prev_block_hash != prev_block.hash {
warn!("Ignoring block with wrong previous hash:\n{:?}", &block);
return Bad;
}
}
let faulty_blocks = vec![
"0000133B790B61460D757E1F1F2D04480C8340D28CA73AE5AF27DBBF60548D00",

@ -276,6 +276,10 @@ fn find_hash(context: Arc<Mutex<Context>>, mut block: Block, running: Arc<Atomic
if block.index > 1 {
if let Ok(context) = context.lock() {
if context.chain.height() >= block.index {
if !full {
info!("Blockchain changed while mining signing block, dropping work");
return None;
}
break;
}
}

Loading…
Cancel
Save