mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Only check if the cosign is stale if it isn't faulty
If it is faulty, we want to archive it regardless.
This commit is contained in:
@@ -324,14 +324,16 @@ impl<D: Db> Cosigning<D> {
|
|||||||
let Some(our_block_hash) = SubstrateBlocks::get(&self.db, cosign.block_number) else {
|
let Some(our_block_hash) = SubstrateBlocks::get(&self.db, cosign.block_number) else {
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
};
|
};
|
||||||
let faulty = our_block_hash == cosign.block_hash;
|
let faulty = cosign.block_hash != our_block_hash;
|
||||||
|
|
||||||
// Check this isn't a dated cosign within its global session (as it would be if rebroadcasted)
|
// Check this isn't a dated cosign within its global session (as it would be if rebroadcasted)
|
||||||
if let Some(existing) =
|
if !faulty {
|
||||||
NetworksLatestCosignedBlock::get(&self.db, cosign.global_session, network)
|
if let Some(existing) =
|
||||||
{
|
NetworksLatestCosignedBlock::get(&self.db, cosign.global_session, network)
|
||||||
if existing.cosign.block_number >= cosign.block_number {
|
{
|
||||||
return Ok(true);
|
if existing.cosign.block_number >= cosign.block_number {
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +373,7 @@ impl<D: Db> Cosigning<D> {
|
|||||||
|
|
||||||
let mut txn = self.db.txn();
|
let mut txn = self.db.txn();
|
||||||
|
|
||||||
if our_block_hash == cosign.block_hash {
|
if !faulty {
|
||||||
// If this is for a future global session, we don't acknowledge this cosign at this time
|
// If this is for a future global session, we don't acknowledge this cosign at this time
|
||||||
let latest_cosigned_block_number = LatestCosignedBlockNumber::get(&txn).unwrap_or(0);
|
let latest_cosigned_block_number = LatestCosignedBlockNumber::get(&txn).unwrap_or(0);
|
||||||
// This global session starts the block *after* its declaration, so we want to check if the
|
// This global session starts the block *after* its declaration, so we want to check if the
|
||||||
@@ -381,6 +383,7 @@ impl<D: Db> Cosigning<D> {
|
|||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is safe as it's in-range and newer, as prior checked since it isn't faulty
|
||||||
NetworksLatestCosignedBlock::set(&mut txn, cosign.global_session, network, signed_cosign);
|
NetworksLatestCosignedBlock::set(&mut txn, cosign.global_session, network, signed_cosign);
|
||||||
} else {
|
} else {
|
||||||
let mut faults = Faults::get(&txn, cosign.global_session).unwrap_or(vec![]);
|
let mut faults = Faults::get(&txn, cosign.global_session).unwrap_or(vec![]);
|
||||||
|
|||||||
Reference in New Issue
Block a user