Line data Source code
1 : #ifndef HEADER_fd_src_choreo_votor_ag_vote_serde_h 2 : #define HEADER_fd_src_choreo_votor_ag_vote_serde_h 3 : 4 : #include "ag_vote.h" 5 : 6 0 : #define AG_VOTE_DE_SUCCESS ( 0) 7 0 : #define AG_VOTE_DE_ERR_SZ (-1) /* Io(ReadSizeLimit), PreallocationSizeLimit, LengthEncodingOverflow */ 8 0 : #define AG_VOTE_DE_ERR_INVAL (-2) /* InvalidTagEncoding, InvalidValue */ 9 0 : #define AG_VOTE_DE_ERR_SIG (-3) /* BLS verification failed, identity is never a valid vote signature */ 10 : 11 0 : #define AG_VOTE_SERDE_TAG_NOTAR (1) /* WireConsensusMessageKind::NotarVote #[wincode(tag = 1)] */ 12 0 : #define AG_VOTE_SERDE_TAG_FINAL (2) /* WireConsensusMessageKind::FinalizeVote #[wincode(tag = 2)] */ 13 0 : #define AG_VOTE_SERDE_TAG_SKIP (3) /* WireConsensusMessageKind::SkipVote #[wincode(tag = 3)] */ 14 0 : #define AG_VOTE_SERDE_TAG_NOTAR_FALLBACK (4) /* WireConsensusMessageKind::NotarFallbackVote #[wincode(tag = 4)] */ 15 0 : #define AG_VOTE_SERDE_TAG_SKIP_FALLBACK (5) /* WireConsensusMessageKind::SkipFallbackVote #[wincode(tag = 5)] */ 16 : 17 : FD_STATIC_ASSERT( AG_VOTE_KIND_NOTAR +1==AG_VOTE_SERDE_TAG_NOTAR, ag_vote_serde ); 18 : FD_STATIC_ASSERT( AG_VOTE_KIND_FINAL +1==AG_VOTE_SERDE_TAG_FINAL, ag_vote_serde ); 19 : FD_STATIC_ASSERT( AG_VOTE_KIND_SKIP +1==AG_VOTE_SERDE_TAG_SKIP, ag_vote_serde ); 20 : FD_STATIC_ASSERT( AG_VOTE_KIND_NOTAR_FALLBACK+1==AG_VOTE_SERDE_TAG_NOTAR_FALLBACK, ag_vote_serde ); 21 : FD_STATIC_ASSERT( AG_VOTE_KIND_SKIP_FALLBACK +1==AG_VOTE_SERDE_TAG_SKIP_FALLBACK, ag_vote_serde ); 22 : 23 : struct ag_vote_serde { 24 : uchar version; /* VersionedWireConsensusMessage::V1 (u8 tag) */ 25 : uchar tag; /* WireConsensusMessageKind (u8 tag) */ 26 : ulong slot; /* WireSlotVoteMessage::slot (Slot) */ 27 : uchar const * block_id; /* Block::block_id (Hash) */ 28 : uchar const * signature; /* WireVoteSignature::signature (BLSSignature) */ 29 : ushort shred_version; /* WireConsensusMessageV1::shred_version (u16) */ 30 : }; 31 : typedef struct ag_vote_serde ag_vote_serde_t; 32 : 33 : #define AG_VOTE_SIGNING_SER_MAX ( sizeof(uchar) /* kind */ + \ 34 : sizeof(ulong) /* slot */ + \ 35 : sizeof(ag_block_hash_t) /* block_id */ + \ 36 : sizeof(ushort) /* shred_version */ ) 37 : 38 : #define AG_VOTE_SER_SZ( has_block_id ) ( sizeof(uchar) /* version */ + \ 39 : sizeof(uchar) /* kind */ + \ 40 : sizeof(ulong) /* slot */ + \ 41 : ( (has_block_id) ? sizeof(ag_block_hash_t) : 0UL ) /* block_id */ + \ 42 : FD_BLS_SIG_SZ /* signature */ + \ 43 : sizeof(ushort) /* shred_version */ ) 44 : 45 : #define AG_VOTE_SER_MAX AG_VOTE_SER_SZ( 1 ) 46 : 47 : FD_PROTOTYPES_BEGIN 48 : 49 : ulong 50 : ag_vote_ser( ag_vote_t const * self, 51 : uchar buf[ static AG_VOTE_SER_MAX ] ); 52 : 53 : int 54 : ag_vote_de( ag_vote_t * self, 55 : uchar const * buf, 56 : ulong buf_sz ); 57 : 58 : ulong 59 : ag_vote_signing_ser( uint kind, 60 : ulong slot, 61 : uchar const * block_hash, 62 : ushort shred_version, 63 : uchar buf[ static AG_VOTE_SIGNING_SER_MAX ] ); 64 : 65 : FD_PROTOTYPES_END 66 : 67 : #endif /* HEADER_fd_src_choreo_votor_ag_vote_serde_h */