Fixed signers calculation.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "alfis"
|
name = "alfis"
|
||||||
version = "0.4.13"
|
version = "0.4.14"
|
||||||
authors = ["Revertron <alfis@revertron.com>"]
|
authors = ["Revertron <alfis@revertron.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|||||||
+11
-4
@@ -676,12 +676,19 @@ impl Chain {
|
|||||||
return Bad;
|
return Bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
let faulty_block_hash = "0000133B790B61460D757E1F1F2D04480C8340D28CA73AE5AF27DBBF60548D00";
|
let faulty_blocks = vec![
|
||||||
let bytes = Bytes::from_bytes(&from_hex(faulty_block_hash).unwrap());
|
"0000133B790B61460D757E1F1F2D04480C8340D28CA73AE5AF27DBBF60548D00",
|
||||||
|
"8564E56AB50AE8473C3A26D7F5FF768A0238D463FAAE4A2049B2A6052F140000",
|
||||||
|
"0000FD8442CE01D9F25A4F53BE21A8552E83182184F2FF75E2A77718CF87483E",
|
||||||
|
"000CF01FA8E538A5AEA1E0E7B5FAB14914A4407B1CBE93CBB0F2129782661160",
|
||||||
|
];
|
||||||
|
for hash in faulty_blocks {
|
||||||
|
let bytes = Bytes::from_bytes(&from_hex(hash).unwrap());
|
||||||
if block.hash == bytes {
|
if block.hash == bytes {
|
||||||
warn!("Block {:?} is faulty! Ignoring!", &block);
|
warn!("Block {:?} is faulty! Ignoring!", &block);
|
||||||
return Bad;
|
return Bad;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(transaction) = &block.transaction {
|
if let Some(transaction) = &block.transaction {
|
||||||
// TODO check for zone transaction
|
// TODO check for zone transaction
|
||||||
@@ -864,13 +871,13 @@ impl Chain {
|
|||||||
/// block - last full block
|
/// block - last full block
|
||||||
pub fn get_block_signers(&self, block: &Block) -> Vec<Bytes> {
|
pub fn get_block_signers(&self, block: &Block) -> Vec<Bytes> {
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
if block.index < BLOCK_SIGNERS_START {
|
if block.index < BLOCK_SIGNERS_START || self.height() < block.index {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
let mut set = HashSet::new();
|
let mut set = HashSet::new();
|
||||||
let tail = block.signature.get_tail_u64();
|
let tail = block.signature.get_tail_u64();
|
||||||
let mut count = 1;
|
let mut count = 1;
|
||||||
let window = self.height() - 1; // Without the last block
|
let window = block.index - 1; // Without the last block
|
||||||
while set.len() < BLOCK_SIGNERS_ALL as usize {
|
while set.len() < BLOCK_SIGNERS_ALL as usize {
|
||||||
let index = ((tail * count) % window) + 1; // We want it to start from 1
|
let index = ((tail * count) % window) + 1; // We want it to start from 1
|
||||||
if let Some(b) = self.get_block(index) {
|
if let Some(b) = self.get_block(index) {
|
||||||
|
|||||||
Reference in New Issue
Block a user