Send the final checkpoint block to the checkpoint verifier (#1111)

* Send the final checkpoint block to the checkpoint verifier

Also:
  * route blocks with no height to the block verifier
  * update an incorrect comment

* Add missing {

* rustfmt
This commit is contained in:
teor 2020-10-01 05:53:31 +10:00 committed by GitHub
parent 41b985ee0b
commit 2db97ba6e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 14 deletions

View File

@ -107,22 +107,27 @@ where
self.last_block_height = height; self.last_block_height = height;
// The only valid block without a coinbase height is the genesis block, if let Some(height) = height {
// which omitted it by mistake. So for the purposes of routing requests, if height <= self.max_checkpoint_height {
// we can interpret a missing coinbase height as 0; the checkpoint verifier return self
// will reject it. .checkpoint
if height.unwrap_or(block::Height(0)) < self.max_checkpoint_height {
self.checkpoint
.call(block) .call(block)
.map_err(VerifyChainError::Checkpoint) .map_err(VerifyChainError::Checkpoint)
.boxed() .boxed();
} else { }
}
// For the purposes of routing requests, we can send blocks
// with no height to the block verifier, which will reject them.
//
// We choose the block verifier because it doesn't have any
// internal state, so it will always return the same error for a
// block with no height.
self.block self.block
.call(block) .call(block)
.map_err(VerifyChainError::Block) .map_err(VerifyChainError::Block)
.boxed() .boxed()
} }
}
} }
/// Return a block verification service, using `config`, `network` and /// Return a block verification service, using `config`, `network` and