pub(crate) fn block_to_commit<K: KVStore>(
justify: &PhaseCertificate,
block_tree: &BlockTreeSingleton<K>,
) -> Result<Option<CryptoHash>, BlockTreeError>
Expand description
Get the Block
in block_tree
(if any) that, along with all of its uncommitted predecessors,
should be committed after the replica sees justify
.
§Preconditions
The Block
or Nudge
containing justify
must satisfy safe_block
or safe_nudge
respectively.
§block_to_commit
logic
block_to_commit
’s return value depends on justify
’s phase and whether or not it is the Genesis
PC. What block_to_commit
returns in every case is summarized in the below table:
justify.phase is a | Block to commit if it satisfies the consecutive views rule and is not already committed yet |
---|---|
Generic PC | justify.block.justify.block.justify.block |
Prepare PC | None |
Precommit PC | None |
Commit PC | justify.block |
Decide PC | justify.block |
§Rationale
The rationale behind block_to_commit
’s logic is explained in the
“Committing” section of safety
’s module-level docs.