Skip to content

Commit

Permalink
CRC: fix documentation on define_u8_enum types in messages.rs
Browse files Browse the repository at this point in the history
Signed-off-by: Jacinta Ferrant <[email protected]>
  • Loading branch information
jferrant committed May 14, 2024
1 parent 7af348d commit 65859b7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 11 deletions.
18 changes: 15 additions & 3 deletions libsigner/src/v0/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ MessageSlotID {
BlockResponse = 1
});

define_u8_enum!(SignerMessageTypePrefix {
define_u8_enum!(
/// Enum representing the SignerMessage type prefix
SignerMessageTypePrefix {
/// Block Proposal message from miners
BlockProposal = 0,
/// Block Response message from signers
BlockResponse = 1
});

Expand Down Expand Up @@ -185,8 +189,12 @@ pub trait StacksMessageCodecExtensions: Sized {
fn inner_consensus_deserialize<R: Read>(fd: &mut R) -> Result<Self, CodecError>;
}

define_u8_enum!(RejectCodeTypePrefix{
define_u8_enum!(
/// Enum representing the reject code type prefix
RejectCodeTypePrefix{
/// The block was rejected due to validation issues
ValidationFailed = 0,
/// The block was rejected due to connectivity issues with the signer
ConnectivityIssues = 1
});

Expand Down Expand Up @@ -217,8 +225,12 @@ pub enum RejectCode {
ConnectivityIssues,
}

define_u8_enum!(BlockResponseTypePrefix{
define_u8_enum!(
/// Enum representing the BlockResponse type prefix
BlockResponseTypePrefix{
/// An accepted block response
Accepted = 0,
/// A rejected block response
Rejected = 1
});

Expand Down
55 changes: 49 additions & 6 deletions libsigner/src/v1/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,18 @@ MessageSlotID {
EncryptedSignerState = 13
});

define_u8_enum!(SignerMessageTypePrefix {
define_u8_enum!(
/// Enum representing the signer message type prefix
SignerMessageTypePrefix {
/// A block response message
BlockResponse = 0,
/// A wsts packet message
Packet = 1,
/// A list of transactions that a signer cares about
Transactions = 2,
/// The results of a successful DKG
DkgResults = 3,
/// The encrypted state of the signer to be persisted
EncryptedSignerState = 4
});

Expand Down Expand Up @@ -153,16 +160,28 @@ impl From<&SignerMessage> for SignerMessageTypePrefix {
}
}

define_u8_enum!(MessageTypePrefix {
define_u8_enum!(
/// Enum representing the message type prefix
MessageTypePrefix {
/// DkgBegin message
DkgBegin = 0,
/// DkgPrivateBegin message
DkgPrivateBegin = 1,
/// DkgEndBegin message
DkgEndBegin = 2,
/// DkgEnd message
DkgEnd = 3,
/// DkgPublicShares message
DkgPublicShares = 4,
/// DkgPrivateShares message
DkgPrivateShares = 5,
/// NonceRequest message
NonceRequest = 6,
/// NonceResponse message
NonceResponse = 7,
/// SignatureShareRequest message
SignatureShareRequest = 8,
/// SignatureShareResponse message
SignatureShareResponse = 9
});

Expand Down Expand Up @@ -192,13 +211,22 @@ impl TryFrom<u8> for MessageTypePrefix {
}
}

define_u8_enum!(RejectCodeTypePrefix{
define_u8_enum!(
/// Enum representing the reject code type prefix
RejectCodeTypePrefix{
/// Validation failed
ValidationFailed = 0,
/// Signed rejection
SignedRejection = 1,
/// Insufficient signers
InsufficientSigners = 2,
/// Missing transactions
MissingTransactions = 3,
/// Connectivity issues
ConnectivityIssues = 4,
/// Nonce timeout
NonceTimeout = 5,
/// Aggregator error
AggregatorError = 6
});

Expand Down Expand Up @@ -540,11 +568,18 @@ impl StacksMessageCodecExtensions for HashSet<u32> {
}
}

define_u8_enum!(DkgFailureTypePrefix{
define_u8_enum!(
/// Enum representing the DKG failure type prefix
DkgFailureTypePrefix{
/// Bad state
BadState = 0,
/// Missing public shares
MissingPublicShares = 1,
/// Bad public shares
BadPublicShares = 2,
/// Missing private shares
MissingPrivateShares = 3,
/// Bad private shares
BadPrivateShares = 4
});

Expand Down Expand Up @@ -674,8 +709,12 @@ impl StacksMessageCodecExtensions for DkgEndBegin {
}
}

define_u8_enum!(DkgStatusTypePrefix{
define_u8_enum!(
/// Enum representing the DKG status type prefix
DkgStatusTypePrefix{
/// Success
Success = 0,
/// Failure
Failure = 1
});

Expand Down Expand Up @@ -1084,8 +1123,12 @@ impl StacksMessageCodecExtensions for Packet {
}
}

define_u8_enum!(BlockResponseTypePrefix{
define_u8_enum!(
/// Enum representing the block response type prefix
BlockResponseTypePrefix{
/// Accepted
Accepted = 0,
/// Rejected
Rejected = 1
});

Expand Down
2 changes: 0 additions & 2 deletions stacks-common/src/util/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,8 @@ macro_rules! define_u8_enum {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
#[repr(u8)]
$(#[$outer])*
/// A u8 Named Enum
pub enum $Name {
$( $(#[$inner])*
/// $Variant
$Variant = $Val),*,
}
impl $Name {
Expand Down

0 comments on commit 65859b7

Please sign in to comment.