From 0af895f887486df2399adf0ca1c913c595e0d3a2 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Sat, 19 Feb 2022 11:23:50 -0700 Subject: [PATCH] resolve jcape comments --- consensus/enclave/api/src/error.rs | 5 ++++- consensus/enclave/impl/src/lib.rs | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/consensus/enclave/api/src/error.rs b/consensus/enclave/api/src/error.rs index f123ca0d55..55aff5005d 100644 --- a/consensus/enclave/api/src/error.rs +++ b/consensus/enclave/api/src/error.rs @@ -57,7 +57,10 @@ pub enum Error { FeeMap(FeeMapError), /// Enclave not initialized - NotInited, + NotInitialized, + + /// Block Version Error: {0} + BlockVersion(String), } impl From for Error { diff --git a/consensus/enclave/impl/src/lib.rs b/consensus/enclave/impl/src/lib.rs index 0be077e799..5c5a307285 100644 --- a/consensus/enclave/impl/src/lib.rs +++ b/consensus/enclave/impl/src/lib.rs @@ -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)) @@ -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)?) @@ -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)?) @@ -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 @@ -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),_>> into @@ -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" ), } }