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,21 +107,26 @@ where
self.last_block_height = height;
// The only valid block without a coinbase height is the genesis block,
// which omitted it by mistake. So for the purposes of routing requests,
// we can interpret a missing coinbase height as 0; the checkpoint verifier
// will reject it.
if height.unwrap_or(block::Height(0)) < self.max_checkpoint_height {
self.checkpoint
.call(block)
.map_err(VerifyChainError::Checkpoint)
.boxed()
} else {
self.block
.call(block)
.map_err(VerifyChainError::Block)
.boxed()
if let Some(height) = height {
if height <= self.max_checkpoint_height {
return self
.checkpoint
.call(block)
.map_err(VerifyChainError::Checkpoint)
.boxed();
}
}
// 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
.call(block)
.map_err(VerifyChainError::Block)
.boxed()
}
}