Line data Source code
1 : #ifndef HEADER_fd_src_choreo_fd_choreo_base_h 2 : #define HEADER_fd_src_choreo_fd_choreo_base_h 3 : 4 : /* Choreo consensus library: 5 : 6 : - eqvoc: Block and vote equivocation. 7 : 8 : - forks: Frontier of banks. 9 : 10 : - ghost: Fork choice rule. 11 : 12 : - tower: TowerBFT algorithm. 13 : 14 : - voter: Voter tracking. 15 : 16 : */ 17 : 18 : #include "../flamenco/fd_flamenco.h" 19 : #include "../flamenco/types/fd_types.h" 20 : #include "../tango/fd_tango.h" 21 : 22 : /* clang-format off */ 23 0 : #define FD_BLOCK_MAX (1UL << 14UL) /* the maximum # of blocks we support holding at once. must be >=512. */ 24 0 : #define FD_VOTER_MAX (1UL << 12UL) /* the maximum # of unique voters ie. node pubkeys. */ 25 : #define FD_EQVOCSAFE_PCT (0.52) 26 : #define FD_CONFIRMED_PCT (2.0 / 3.0) 27 : #define FD_FINALIZED_PCT FD_CONFIRMED_PCT 28 : #define FD_SLOT_HASH_CMP(k0,k1) (fd_int_if(((k0)->slot)<((k1)->slot),-1,fd_int_if(((k0)->slot)>((k1)->slot),1),memcmp((k0),(k1),sizeof(fd_slot_hash_t)))) 29 : #define FD_SLOT_HASH_EQ(k0,k1) ((((k0)->slot)==((k1)->slot)) & !(memcmp(((k0)->hash.uc),((k1)->hash.uc),sizeof(fd_hash_t)))) 30 : #define FD_SLOT_HASH_HASH(key,seed) fd_ulong_hash( ((key)->slot) ^ ((key)->hash.ul[0]) ^ (seed) ) 31 : #define FD_SLOT_PUBKEY_CMP(a,b) FD_SLOT_HASH_CMP(a,b) 32 : #define FD_SLOT_PUBKEY_EQ(k0,k1) FD_SLOT_HASH_EQ(k0,k1) 33 : #define FD_SLOT_PUBKEY_HASH(key,seed) FD_SLOT_HASH_HASH(key,seed) 34 : /* clang-format on */ 35 : 36 : typedef fd_slot_hash_t fd_slot_pubkey_t; 37 : 38 : static const fd_slot_hash_t FD_SLOT_HASH_NULL = { .slot = FD_SLOT_NULL, .hash = { { 0 } } }; 39 : 40 : #endif /* HEADER_fd_src_choreo_fd_choreo_base_h */