@@ -59,6 +59,8 @@ typedef union pc_pub_key
5959 uint64_t k8_ [PC_PUBKEY_SIZE_64 ];
6060} pc_pub_key_t ;
6161
62+ static_assert ( sizeof ( pc_pub_key_t ) == 32 , "" );
63+
6264// account header information
6365typedef struct pc_acc
6466{
@@ -68,6 +70,8 @@ typedef struct pc_acc
6870 uint32_t size_ ; // size of populated region of account
6971} pc_acc_t ;
7072
73+ static_assert ( sizeof ( pc_acc_t ) == 16 , "" );
74+
7175// hash table of symbol to price account mappings
7276typedef struct pc_map_table
7377{
@@ -81,13 +85,17 @@ typedef struct pc_map_table
8185 pc_pub_key_t prod_ [PC_MAP_TABLE_SIZE ]; // product accounts
8286} pc_map_table_t ;
8387
88+ static_assert ( sizeof ( pc_map_table_t ) == 20536 , "" );
89+
8490// variable length string
8591typedef struct pc_str
8692{
8793 uint8_t len_ ;
8894 char data_ [];
8995} pc_str_t ;
9096
97+ static_assert ( sizeof ( pc_str_t ) == 1 , "" );
98+
9199// product reference data
92100typedef struct pc_prod
93101{
@@ -100,6 +108,8 @@ typedef struct pc_prod
100108 // stored as strings (pc_str_t)
101109} pc_prod_t ;
102110
111+ static_assert ( sizeof ( pc_prod_t ) == 48 , "" );
112+
103113// price et al. for some component or aggregate
104114typedef struct pc_price_info
105115{
@@ -110,6 +120,8 @@ typedef struct pc_price_info
110120 uint64_t pub_slot_ ; // publish slot of price
111121} pc_price_info_t ;
112122
123+ static_assert ( sizeof ( pc_price_info_t ) == 32 , "" );
124+
113125// published component price for contributing provider
114126typedef struct pc_price_comp
115127{
@@ -118,6 +130,8 @@ typedef struct pc_price_comp
118130 pc_price_info_t latest_ ; // latest contributed prices
119131} pc_price_comp_t ;
120132
133+ static_assert ( sizeof ( pc_price_comp_t ) == 96 , "" );
134+
121135// time-weighted exponential moving average
122136typedef struct pc_ema
123137{
@@ -126,6 +140,8 @@ typedef struct pc_ema
126140 int64_t denom_ ; // denominator at full precision
127141} pc_ema_t ;
128142
143+ static_assert ( sizeof ( pc_ema_t ) == 24 , "" );
144+
129145// price account containing aggregate and all component prices
130146typedef struct pc_price
131147{
@@ -153,6 +169,8 @@ typedef struct pc_price
153169 pc_price_comp_t comp_ [PC_COMP_SIZE ];// component prices
154170} pc_price_t ;
155171
172+ static_assert ( sizeof ( pc_price_t ) == 3312 , "" );
173+
156174// command enumeration
157175typedef enum {
158176
@@ -229,19 +247,25 @@ typedef struct cmd_hdr
229247 int32_t cmd_ ;
230248} cmd_hdr_t ;
231249
250+ static_assert ( sizeof ( cmd_hdr_t ) == 8 , "" );
251+
232252typedef struct cmd_add_product
233253{
234254 uint32_t ver_ ;
235255 int32_t cmd_ ;
236256} cmd_add_product_t ;
237257
258+ static_assert ( sizeof ( cmd_add_product_t ) == 8 , "" );
259+
238260typedef struct cmd_upd_product
239261{
240262 uint32_t ver_ ;
241263 int32_t cmd_ ;
242264 // set of key-value pairs
243265} cmd_upd_product_t ;
244266
267+ static_assert ( sizeof ( cmd_upd_product_t ) == 8 , "" );
268+
245269typedef struct cmd_add_price
246270{
247271 uint32_t ver_ ;
@@ -250,6 +274,8 @@ typedef struct cmd_add_price
250274 uint32_t ptype_ ;
251275} cmd_add_price_t ;
252276
277+ static_assert ( sizeof ( cmd_add_price_t ) == 16 , "" );
278+
253279typedef struct cmd_init_price
254280{
255281 uint32_t ver_ ;
@@ -258,20 +284,26 @@ typedef struct cmd_init_price
258284 uint32_t ptype_ ;
259285} cmd_init_price_t ;
260286
287+ static_assert ( sizeof ( cmd_init_price_t ) == 16 , "" );
288+
261289typedef struct cmd_add_publisher
262290{
263291 uint32_t ver_ ;
264292 int32_t cmd_ ;
265293 pc_pub_key_t pub_ ;
266294} cmd_add_publisher_t ;
267295
296+ static_assert ( sizeof ( cmd_add_publisher_t ) == 40 , "" );
297+
268298typedef struct cmd_del_publisher
269299{
270300 uint32_t ver_ ;
271301 int32_t cmd_ ;
272302 pc_pub_key_t pub_ ;
273303} cmd_del_publisher_t ;
274304
305+ static_assert ( sizeof ( cmd_del_publisher_t ) == 40 , "" );
306+
275307typedef struct cmd_upd_price
276308{
277309 uint32_t ver_ ;
@@ -283,6 +315,8 @@ typedef struct cmd_upd_price
283315 uint64_t pub_slot_ ;
284316} cmd_upd_price_t ;
285317
318+ static_assert ( sizeof ( cmd_upd_price_t ) == 40 , "" );
319+
286320typedef struct cmd_upd_test
287321{
288322 uint32_t ver_ ;
@@ -294,6 +328,8 @@ typedef struct cmd_upd_test
294328 uint64_t conf_ [PC_COMP_SIZE ];
295329} cmd_upd_test_t ;
296330
331+ static_assert ( sizeof ( cmd_upd_test_t ) == 560 , "" );
332+
297333// structure of clock sysvar account
298334typedef struct sysvar_clock
299335{
@@ -304,6 +340,8 @@ typedef struct sysvar_clock
304340 int64_t unix_timestamp_ ;
305341} sysvar_clock_t ;
306342
343+ static_assert ( sizeof ( sysvar_clock_t ) == 40 , "" );
344+
307345// compare if two pub_keys (accounts) are the same
308346inline bool pc_pub_key_equal ( pc_pub_key_t * p1 , pc_pub_key_t * p2 )
309347{
0 commit comments