Skip to content

Commit

Permalink
resolve jcape comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Feb 19, 2022
1 parent 00c8aab commit 0af895f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion consensus/enclave/api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ pub enum Error {
FeeMap(FeeMapError),

/// Enclave not initialized
NotInited,
NotInitialized,

/// Block Version Error: {0}
BlockVersion(String),
}

impl From<MessageCipherError> for Error {
Expand Down
16 changes: 8 additions & 8 deletions consensus/enclave/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl ConsensusEnclave for SgxConsensusEnclave {
Ok(self
.blockchain_config
.get()
.ok_or(Error::NotInited)?
.ok_or(Error::NotInitialized)?
.get_config()
.fee_map
.get_fee_for_token(token_id))
Expand Down Expand Up @@ -268,7 +268,7 @@ impl ConsensusEnclave for SgxConsensusEnclave {
let peer_id = self
.blockchain_config
.get()
.ok_or(Error::NotInited)?
.ok_or(Error::NotInitialized)?
.responder_id(peer_id);

Ok(self.ake.peer_init(&peer_id)?)
Expand All @@ -287,7 +287,7 @@ impl ConsensusEnclave for SgxConsensusEnclave {
let peer_id = self
.blockchain_config
.get()
.ok_or(Error::NotInited)?
.ok_or(Error::NotInitialized)?
.responder_id(peer_id);

Ok(self.ake.peer_connect(&peer_id, msg)?)
Expand Down Expand Up @@ -369,7 +369,7 @@ impl ConsensusEnclave for SgxConsensusEnclave {
let config = self
.blockchain_config
.get()
.ok_or(Error::NotInited)?
.ok_or(Error::NotInitialized)?
.get_config();

// Enforce that all membership proofs provided by the untrusted system for
Expand Down Expand Up @@ -458,11 +458,11 @@ impl ConsensusEnclave for SgxConsensusEnclave {
let config = self
.blockchain_config
.get()
.ok_or(Error::NotInited)?
.ok_or(Error::NotInitialized)?
.get_config();

if parent_block.version > *config.block_version {
return Err(Error::FormBlock(format!("Block version cannot decrease: parent_block.version = {}, config.block_version = {}", parent_block.version, config.block_version)));
return Err(Error::BlockVersion(format!("Block version cannot decrease: parent_block.version = {}, config.block_version = {}", parent_block.version, config.block_version)));
}

// This implicitly converts Vec<Result<(Tx Vec<TxOutMembershipProof>),_>> into
Expand Down Expand Up @@ -1536,9 +1536,9 @@ mod tests {

// Check if we get a form block error as expected
match form_block_result {
Err(Error::FormBlock(_)) => {}
Err(Error::BlockVersion(_)) => {}
_ => panic!(
"Expected a FormBlock error due to config.block_version being less than parent"
"Expected a BlockVersion error due to config.block_version being less than parent"
),
}
}
Expand Down

0 comments on commit 0af895f

Please sign in to comment.