zebra_consensus/block/request.rs
1//! Block verifier request type.
2
3use std::sync::Arc;
4
5use zebra_chain::block::Block;
6
7#[derive(Debug, Clone, PartialEq, Eq)]
8/// A request to the chain or block verifier
9pub enum Request {
10 /// Performs semantic validation, then asks the state to perform contextual validation and commit the block
11 Commit(Arc<Block>),
12 /// Performs semantic validation but skips checking proof of work,
13 /// then asks the state to perform contextual validation.
14 /// Does not commit the block to the state.
15 CheckProposal(Arc<Block>),
16}
17
18impl Request {
19 /// Returns inner block
20 pub fn block(&self) -> Arc<Block> {
21 Arc::clone(match self {
22 Request::Commit(block) => block,
23 Request::CheckProposal(block) => block,
24 })
25 }
26
27 /// Returns `true` if the request is a proposal
28 pub fn is_proposal(&self) -> bool {
29 match self {
30 Request::Commit(_) => false,
31 Request::CheckProposal(_) => true,
32 }
33 }
34}