Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: teor <[email protected]>
  • Loading branch information
arya2 and teor2345 authored Dec 16, 2022
1 parent 9e0b8d1 commit 096dab3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
9 changes: 5 additions & 4 deletions zebra-consensus/src/block/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ use zebra_chain::block::Block;
#[derive(Debug, Clone, PartialEq, Eq)]
/// A request to the chain or block verifier
pub enum Request {
/// Performs semantic validation then calls state with CommitBlock request
/// Performs semantic validation, then asks the state to perform contextual validation and commit the block
Commit(Arc<Block>),

#[cfg(feature = "getblocktemplate-rpcs")]
/// Performs semantic validation but skips checking the solution,
/// then calls the state with CheckBlockValid request
/// Performs semantic validation but skips checking proof of work,
/// then asks the state to perform contextual validation, excluding proof of work.
/// Does not commit the block to the state.
CheckProposal(Arc<Block>),
}

Expand All @@ -27,7 +28,7 @@ impl Request {
})
}

/// Checks if request is a proposal
/// Returns `true` if the request is a proposal
pub fn is_proposal(&self) -> bool {
match self {
Request::Commit(_) => false,
Expand Down
10 changes: 4 additions & 6 deletions zebra-state/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,9 @@ pub enum Request {
CheckBestChainTipNullifiersAndAnchors(UnminedTx),

#[cfg(feature = "getblocktemplate-rpcs")]
/// Performs contextual validation of the given block.
/// Performs contextual validation of the given block, but does not commit it to the state.
///
/// It is the caller's responsibility to perform semantic validation.
///
/// Returns [`Response::ValidBlock`] with the hash of the block when successful, or an error if
/// the block fails contextual validation.
/// See `[ReadRequest::CheckBlockValidity]` for details.
CheckBlockValidity(PreparedBlock),
}

Expand Down Expand Up @@ -803,9 +800,10 @@ pub enum ReadRequest {
},

#[cfg(feature = "getblocktemplate-rpcs")]
/// Performs contextual validation of the given block.
/// Performs contextual validation of the given block, but does not commit it to the state.
///
/// It is the caller's responsibility to perform semantic validation.
/// (The caller does not need to check proof of work for block proposals.)
///
/// Returns [`Response::ValidBlock`] with the hash of the block when successful, or an error if
/// the block fails contextual validation.
Expand Down
4 changes: 2 additions & 2 deletions zebra-state/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1806,13 +1806,13 @@ impl Service<ReadRequest> for ReadStateService {
timer.finish(
module_path!(),
line!(),
"ReadRequest::CheckContextualValidity",
"ReadRequest::CheckBlockValidity",
);

Ok(ReadResponse::ValidBlock(prepared.hash))
})
})
.map(|join_result| join_result.expect("panic in ReadRequest::ChainInfo"))
.map(|join_result| join_result.expect("panic in ReadRequest::CheckBlockValidity"))
.boxed()
}
}
Expand Down

0 comments on commit 096dab3

Please sign in to comment.