Line data Source code
1 : #include "fd_hfork.h" 2 : 3 : struct bank_hash { 4 : fd_hash_t bank_hash; 5 : ulong next; 6 : }; 7 : typedef struct bank_hash bank_hash_t; 8 : 9 : #define POOL_NAME bank_hash_pool 10 6 : #define POOL_T bank_hash_t 11 : #include "../../util/tmpl/fd_pool.c" 12 : 13 : struct blk { 14 : fd_hash_t block_id; 15 : uint hash; 16 : int forked; /* whether this block id has hard forked (multiple candidate bank hashes) */ 17 : int replayed; /* whether we've replayed */ 18 : int dead; /* whether we marked the block as dead during replay (must ignore our_bank_hash) */ 19 : fd_hash_t our_bank_hash; /* our bank hash for this block_id after replay */ 20 : bank_hash_t * bank_hashes; 21 : }; 22 : typedef struct blk blk_t; 23 : 24 : #define MAP_NAME blk_map 25 123 : #define MAP_T blk_t 26 396 : #define MAP_KEY block_id 27 315 : #define MAP_KEY_T fd_hash_t 28 81 : #define MAP_KEY_NULL hash_null 29 : #define MAP_KEY_EQUAL_IS_SLOW 1 30 315 : #define MAP_KEY_INVAL(k) MAP_KEY_EQUAL((k),MAP_KEY_NULL) 31 579 : #define MAP_KEY_EQUAL(k0,k1) (!memcmp( (k0).key, (k1).key, 32UL )) 32 117 : #define MAP_KEY_HASH(key,seed) ((MAP_HASH_T)( (key).ul[1] )) /* FIXME: use seed? */ 33 : #include "../../util/tmpl/fd_map_dynamic.c" 34 : 35 : struct vote { 36 : fd_hash_t block_id; 37 : fd_hash_t bank_hash; 38 : ulong slot; 39 : ulong stake; 40 : }; 41 : typedef struct vote vote_t; 42 : 43 : #define DEQUE_NAME votes 44 24 : #define DEQUE_T vote_t 45 : #include "../../util/tmpl/fd_deque_dynamic.c" 46 : 47 : struct vtr { 48 : fd_pubkey_t vote_acc; 49 : uint hash; 50 : vote_t * votes; 51 : }; 52 : typedef struct vtr vtr_t; 53 : 54 : #define MAP_NAME vtr_map 55 90 : #define MAP_T vtr_t 56 159 : #define MAP_KEY vote_acc 57 135 : #define MAP_KEY_T fd_pubkey_t 58 24 : #define MAP_KEY_NULL pubkey_null 59 : #define MAP_KEY_EQUAL_IS_SLOW 1 60 135 : #define MAP_KEY_INVAL(k) MAP_KEY_EQUAL((k),MAP_KEY_NULL) 61 258 : #define MAP_KEY_EQUAL(k0,k1) (!memcmp( (k0).key, (k1).key, 32UL )) 62 60 : #define MAP_KEY_HASH(key,seed) ((MAP_HASH_T)( (key).ul[1] )) /* FIXME: use seed? */ 63 : #include "../../util/tmpl/fd_map_dynamic.c" 64 : 65 : struct candidate_key { 66 : fd_pubkey_t block_id; 67 : fd_pubkey_t bank_hash; 68 : }; 69 : typedef struct candidate_key candidate_key_t; 70 : 71 : struct candidate { 72 : candidate_key_t key; 73 : uint hash; 74 : ulong slot; 75 : ulong stake; 76 : ulong cnt; 77 : int checked; 78 : }; 79 : typedef struct candidate candidate_t; 80 : 81 : static const candidate_key_t candidate_key_null = { 0 }; 82 : 83 : #define MAP_NAME candidate_map 84 423 : #define MAP_KEY key 85 123 : #define MAP_T candidate_t 86 324 : #define MAP_KEY_T candidate_key_t 87 99 : #define MAP_KEY_NULL candidate_key_null 88 324 : #define MAP_KEY_INVAL(k) MAP_KEY_EQUAL((k),MAP_KEY_NULL) 89 510 : #define MAP_KEY_EQUAL(k0,k1) (fd_pubkey_eq( &((k0).block_id), &((k1).block_id ) ) &\ 90 510 : fd_pubkey_eq( &((k0).bank_hash), &((k1).bank_hash) ) ) 91 : #define MAP_KEY_EQUAL_IS_SLOW 1 92 117 : #define MAP_KEY_HASH(key,seed) (fd_uint_load_4( (key).block_id.uc ) ^ fd_uint_load_4( (key).bank_hash.uc ) ) /* FIXME: use seed? */ 93 : #include "../../util/tmpl/fd_map_dynamic.c" 94 : 95 : struct __attribute__((aligned(128UL))) fd_hfork { 96 : blk_t * blk_map; 97 : vtr_t * vtr_map; 98 : candidate_t * candidate_map; 99 : bank_hash_t * bank_hash_pool; 100 : int fatal; 101 : }; 102 : typedef struct fd_hfork fd_hfork_t;