Skip to content

Commit

Permalink
Better out of capacity error (MystenLabs#1711)
Browse files Browse the repository at this point in the history
  • Loading branch information
asonnino authored May 3, 2022
1 parent 1a25e68 commit 300f32d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion sui_core/src/consensus_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ impl ConsensusListener {
match message {
// Keep track of this certificates so we can notify the user later.
ConsensusListenerMessage::New(transaction, replier) => {
let digest = Self::hash(&transaction);
if self.pending.len() < self.max_pending_transactions {
let digest = Self::hash(&transaction);
self.pending.entry(digest).or_insert_with(Vec::new).push(replier);
} else if replier.send(Err(SuiError::ListenerCapacityExceeded)).is_err() {
debug!("No replier to listen to consensus output {digest}");
}
},

Expand Down
6 changes: 4 additions & 2 deletions sui_core/tests/staged/sui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -729,12 +729,14 @@ SuiError:
SharedObjectLockingFailure:
NEWTYPE: STR
98:
ListenerCapacityExceeded: UNIT
99:
SignatureSeedInvalidLength:
NEWTYPE: U64
99:
100:
HkdfError:
NEWTYPE: STR
100:
101:
SignatureKeyGenError:
NEWTYPE: STR
TransactionData:
Expand Down
4 changes: 2 additions & 2 deletions sui_types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,12 @@ pub enum SuiError {
// Errors related to the authority-consensus interface.
#[error("Authority state can be modified by a single consensus client at the time")]
OnlyOneConsensusClientPermitted,

#[error("Failed to connect with consensus node: {0}")]
ConsensusConnectionBroken(String),

#[error("Failed to lock shared objects: {0}")]
SharedObjectLockingFailure(String),
#[error("Consensus listener is out of capacity")]
ListenerCapacityExceeded,

// Cryptography errors.
#[error("Signature seed invalid length, input byte size was: {0}")]
Expand Down

0 comments on commit 300f32d

Please sign in to comment.