Add an is_finished boolean to the grandpa warp sync response (#8203)

This commit is contained in:
Ashley
2021-02-25 13:39:30 +01:00
committed by GitHub
parent 5232e8ad5c
commit 241302d0e4
@@ -46,6 +46,7 @@ pub struct AuthoritySetChangeProof<Block: BlockT> {
#[derive(Decode, Encode)]
pub struct WarpSyncProof<Block: BlockT> {
proofs: Vec<AuthoritySetChangeProof<Block>>,
is_finished: bool,
}
impl<Block: BlockT> WarpSyncProof<Block> {
@@ -86,8 +87,11 @@ impl<Block: BlockT> WarpSyncProof<Block> {
let mut proofs = Vec::new();
let mut proof_limit_reached = false;
for (_, last_block) in set_changes.iter_from(begin_number) {
if proofs.len() >= MAX_CHANGES_PER_WARP_SYNC_PROOF {
proof_limit_reached = true;
break;
}
@@ -118,7 +122,10 @@ impl<Block: BlockT> WarpSyncProof<Block> {
});
}
Ok(WarpSyncProof { proofs })
Ok(WarpSyncProof {
proofs,
is_finished: !proof_limit_reached,
})
}
/// Verifies the warp sync proof starting at the given set id and with the given authorities.