1
+ #ifndef HEADER_fd_src_flamenco_stakes_fd_vote_states_h
2
+ #define HEADER_fd_src_flamenco_stakes_fd_vote_states_h
3
+
4
+ #include "../fd_flamenco_base.h"
5
+ #include "../types/fd_types.h"
6
+
7
+ #define FD_VOTE_STATES_MAGIC (0x01231965UL)
8
+
9
+ struct fd_vote_state_ele {
10
+ fd_pubkey_t vote_account ;
11
+ ulong next_ ; /* Internal pool/map use */
12
+ /* TODO: fill in vote state ele fields*/
13
+ };
14
+ typedef struct fd_vote_state fd_vote_state_t ;
15
+
16
+ #define POOL_NAME fd_vote_state_pool
17
+ #define POOL_T fd_vote_state_ele_t
18
+ #define POOL_NEXT next_
19
+ #include "../../util/tmpl/fd_pool.c"
20
+
21
+ #define MAP_NAME fd_vote_state_map
22
+ #define MAP_KEY_T fd_pubkey_t
23
+ #define MAP_ELE_T fd_vote_state_ele_t
24
+ #define MAP_KEY vote_account
25
+ #define MAP_KEY_EQ (k0 ,k1 ) (!(memcmp(&(k0)->key,&(k1)->key,sizeof(fd_pubkey_t))))
26
+ #define MAP_KEY_HASH (key ,seed ) (fd_hash( seed, key, sizeof(fd_pubkey_t) ))
27
+ #define MAP_NEXT next_
28
+ #include "../../util/tmpl/fd_map_chain.c"
29
+
30
+ struct fd_vote_states {
31
+ ulong magic ;
32
+ ulong max_vote_accounts ;
33
+ };
34
+ typedef struct fd_vote_states fd_vote_states_t ;
35
+
36
+ FD_PROTOTYPES_BEGIN
37
+
38
+ /* fd_vote_states_get_pool returns the underlying pool that the
39
+ vote states uses to manage the vote states. */
40
+
41
+ fd_vote_state_ele_t *
42
+ fd_vote_states_get_pool ( fd_vote_states_t const * vote_states );
43
+
44
+ /* fd_vote_states_get_map returns the underlying map that the
45
+ vote states uses to manage the vote states. */
46
+
47
+ fd_vote_state_map_t *
48
+ fd_vote_states_get_map ( fd_vote_states_t const * vote_states );
49
+
50
+ /* fd_vote_states_align returns the minimum alignment required for a
51
+ vote states struct. */
52
+
53
+ ulong
54
+ fd_vote_states_align ( void );
55
+
56
+ /* fd_vote_states_footprint returns the footprint of the vote states
57
+ struct for a given amount of max vote accounts. */
58
+
59
+ ulong
60
+ fd_vote_states_footprint ( ulong max_vote_accounts );
61
+
62
+ /* fd_vote_states_new creates a new vote states struct
63
+ with a given amount of max vote accounts. It formats a memory region
64
+ which is sized based off of the number of vote accounts. */
65
+
66
+ void *
67
+ fd_vote_states_new ( void * mem , ulong max_vote_accounts );
68
+
69
+ /* fd_vote_states_join joins a vote states struct from a
70
+ memory region. There can be multiple valid joins for a given memory
71
+ region but the caller is responsible for accessing memory in a
72
+ thread-safe manner. */
73
+
74
+ fd_vote_states_t *
75
+ fd_vote_states_join ( void * mem );
76
+
77
+ /* fd_vote_states_leave returns the vote states struct from a memory
78
+ region. This function returns a pointer to the vote states struct
79
+ and does not take ownership of the memory region. */
80
+
81
+ void *
82
+ fd_vote_states_leave ( fd_vote_states_t * self );
83
+
84
+ /* fd_vote_states_delete unformats a memory region that was
85
+ formatted by fd_vote_states_new. */
86
+
87
+ void *
88
+ fd_vote_states_delete ( void * mem );
89
+
90
+
91
+ FD_PROTOTYPES_END
92
+
93
+ #endif /* HEADER_fd_src_flamenco_stakes_fd_vote_states_h */
0 commit comments