Skip to content

Commit

Permalink
add an error type for enclave not initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Feb 18, 2022
1 parent d2a58f6 commit aed2e61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions consensus/enclave/api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ pub enum Error {

/// Invalid fee configuration: {0}
FeeMap(FeeMapError),

/// Enclave not initialized
NotInited,
}

impl From<MessageCipherError> for Error {
Expand Down
8 changes: 4 additions & 4 deletions consensus/enclave/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl ConsensusEnclave for SgxConsensusEnclave {
.blockchain_config
.lock()?
.as_ref()
.expect("enclave was not initialized")
.ok_or(Error::NotInited)?
.get_config()
.fee_map
.get_fee_for_token(token_id))
Expand Down Expand Up @@ -265,7 +265,7 @@ impl ConsensusEnclave for SgxConsensusEnclave {
.blockchain_config
.lock()?
.as_ref()
.expect("enclave was not initialized")
.ok_or(Error::NotInited)?
.responder_id(peer_id);

Ok(self.ake.peer_init(&peer_id)?)
Expand All @@ -285,7 +285,7 @@ impl ConsensusEnclave for SgxConsensusEnclave {
.blockchain_config
.lock()?
.as_ref()
.expect("enclave was not initialized")
.ok_or(Error::NotInited)?
.responder_id(peer_id);

Ok(self.ake.peer_connect(&peer_id, msg)?)
Expand Down Expand Up @@ -367,7 +367,7 @@ impl ConsensusEnclave for SgxConsensusEnclave {
let blockchain_config = self.blockchain_config.lock()?;
let config = blockchain_config
.as_ref()
.expect("enclave was not initialized")
.ok_or(Error::NotInited)?
.get_config();

// Enforce that all membership proofs provided by the untrusted system for
Expand Down

0 comments on commit aed2e61

Please sign in to comment.