Fixed consensus error. Added a delay before signing.
This commit is contained in:
@@ -212,6 +212,12 @@ impl Chain {
|
|||||||
trace!("Block {} has enough signing blocks", block.index);
|
trace!("Block {} has enough signing blocks", block.index);
|
||||||
return None;
|
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 keystore = keystore.clone().unwrap().clone();
|
||||||
let signers: HashSet<Bytes> = self.get_block_signers(&block).into_iter().collect();
|
let signers: HashSet<Bytes> = self.get_block_signers(&block).into_iter().collect();
|
||||||
if signers.contains(&keystore.get_public()) {
|
if signers.contains(&keystore.get_public()) {
|
||||||
@@ -645,6 +651,10 @@ impl Chain {
|
|||||||
warn!("Ignoring block from the future:\n{:?}", &block);
|
warn!("Ignoring block from the future:\n{:?}", &block);
|
||||||
return Bad;
|
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) {
|
if !check_public_key_strength(&block.pub_key, KEYSTORE_DIFFICULTY) {
|
||||||
warn!("Ignoring block with weak public key:\n{:?}", &block);
|
warn!("Ignoring block with weak public key:\n{:?}", &block);
|
||||||
return Bad;
|
return Bad;
|
||||||
@@ -675,6 +685,12 @@ impl Chain {
|
|||||||
warn!("Block {:?} has wrong signature! Ignoring!", &block);
|
warn!("Block {:?} has wrong signature! Ignoring!", &block);
|
||||||
return Bad;
|
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![
|
let faulty_blocks = vec![
|
||||||
"0000133B790B61460D757E1F1F2D04480C8340D28CA73AE5AF27DBBF60548D00",
|
"0000133B790B61460D757E1F1F2D04480C8340D28CA73AE5AF27DBBF60548D00",
|
||||||
|
|||||||
@@ -276,6 +276,10 @@ fn find_hash(context: Arc<Mutex<Context>>, mut block: Block, running: Arc<Atomic
|
|||||||
if block.index > 1 {
|
if block.index > 1 {
|
||||||
if let Ok(context) = context.lock() {
|
if let Ok(context) = context.lock() {
|
||||||
if context.chain.height() >= block.index {
|
if context.chain.height() >= block.index {
|
||||||
|
if !full {
|
||||||
|
info!("Blockchain changed while mining signing block, dropping work");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user