@@ -2248,139 +2248,6 @@ ulong fd_account_keys_size_global( fd_account_keys_global_t const * self ) {
2248
2248
return size;
2249
2249
}
2250
2250
2251
- int fd_stake_weight_encode( fd_stake_weight_t const * self, fd_bincode_encode_ctx_t * ctx ) {
2252
- int err;
2253
- err = fd_pubkey_encode( &self->key, ctx );
2254
- if( FD_UNLIKELY( err ) ) return err;
2255
- err = fd_bincode_uint64_encode( self->stake, ctx );
2256
- if( FD_UNLIKELY( err ) ) return err;
2257
- return FD_BINCODE_SUCCESS;
2258
- }
2259
- static inline int fd_stake_weight_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx, ulong * total_sz ) {
2260
- if( (ulong)ctx->data + 40UL > (ulong)ctx->dataend ) { return FD_BINCODE_ERR_OVERFLOW; };
2261
- ctx->data = (void *)( (ulong)ctx->data + 40UL );
2262
- return 0;
2263
- }
2264
- static void fd_stake_weight_decode_inner( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx ) {
2265
- fd_stake_weight_t * self = (fd_stake_weight_t *)struct_mem;
2266
- fd_pubkey_decode_inner( &self->key, alloc_mem, ctx );
2267
- fd_bincode_uint64_decode_unsafe( &self->stake, ctx );
2268
- }
2269
- void * fd_stake_weight_decode( void * mem, fd_bincode_decode_ctx_t * ctx ) {
2270
- fd_stake_weight_t * self = (fd_stake_weight_t *)mem;
2271
- fd_stake_weight_new( self );
2272
- void * alloc_region = (uchar *)mem + sizeof(fd_stake_weight_t);
2273
- void * * alloc_mem = &alloc_region;
2274
- fd_stake_weight_decode_inner( mem, alloc_mem, ctx );
2275
- return self;
2276
- }
2277
- void fd_stake_weight_walk( void * w, fd_stake_weight_t const * self, fd_types_walk_fn_t fun, const char *name, uint level, uint varint ) {
2278
- (void) varint;
2279
- fun( w, self, name, FD_FLAMENCO_TYPE_MAP, "fd_stake_weight", level++, 0 );
2280
- fd_pubkey_walk( w, &self->key, fun, "key", level, 0 );
2281
- fun( w, &self->stake, "stake", FD_FLAMENCO_TYPE_ULONG, "ulong", level, 0 );
2282
- fun( w, self, name, FD_FLAMENCO_TYPE_MAP_END, "fd_stake_weight", level--, 0 );
2283
- }
2284
- ulong fd_stake_weight_size( fd_stake_weight_t const * self ) {
2285
- ulong size = 0;
2286
- size += fd_pubkey_size( &self->key );
2287
- size += sizeof(ulong);
2288
- return size;
2289
- }
2290
-
2291
- int fd_stake_weights_encode( fd_stake_weights_t const * self, fd_bincode_encode_ctx_t * ctx ) {
2292
- int err;
2293
- if( self->stake_weights_root ) {
2294
- ulong stake_weights_len = fd_stake_weight_t_map_size( self->stake_weights_pool, self->stake_weights_root );
2295
- err = fd_bincode_uint64_encode( stake_weights_len, ctx );
2296
- if( FD_UNLIKELY( err ) ) return err;
2297
- for( fd_stake_weight_t_mapnode_t * n = fd_stake_weight_t_map_minimum( self->stake_weights_pool, self->stake_weights_root ); n; n = fd_stake_weight_t_map_successor( self->stake_weights_pool, n ) ) {
2298
- err = fd_stake_weight_encode( &n->elem, ctx );
2299
- if( FD_UNLIKELY( err ) ) return err;
2300
- }
2301
- } else {
2302
- ulong stake_weights_len = 0;
2303
- err = fd_bincode_uint64_encode( stake_weights_len, ctx );
2304
- if( FD_UNLIKELY( err ) ) return err;
2305
- }
2306
- return FD_BINCODE_SUCCESS;
2307
- }
2308
- static int fd_stake_weights_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx, ulong * total_sz ) {
2309
- if( ctx->data>=ctx->dataend ) { return FD_BINCODE_ERR_OVERFLOW; };
2310
- int err = 0;
2311
- ulong stake_weights_len = 0UL;
2312
- err = fd_bincode_uint64_decode( &stake_weights_len, ctx );
2313
- ulong stake_weights_cnt = !!stake_weights_len ? stake_weights_len : 1;
2314
- *total_sz += fd_stake_weight_t_map_align() + fd_stake_weight_t_map_footprint( stake_weights_cnt );
2315
- if( FD_UNLIKELY( err ) ) return err;
2316
- for( ulong i=0; i < stake_weights_len; i++ ) {
2317
- err = fd_stake_weight_decode_footprint_inner( ctx, total_sz );
2318
- if( FD_UNLIKELY( err ) ) return err;
2319
- }
2320
- return 0;
2321
- }
2322
- int fd_stake_weights_decode_footprint( fd_bincode_decode_ctx_t * ctx, ulong * total_sz ) {
2323
- *total_sz += sizeof(fd_stake_weights_t);
2324
- void const * start_data = ctx->data;
2325
- int err = fd_stake_weights_decode_footprint_inner( ctx, total_sz );
2326
- if( ctx->data>ctx->dataend ) { return FD_BINCODE_ERR_OVERFLOW; };
2327
- ctx->data = start_data;
2328
- return err;
2329
- }
2330
- static void fd_stake_weights_decode_inner( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx ) {
2331
- fd_stake_weights_t * self = (fd_stake_weights_t *)struct_mem;
2332
- ulong stake_weights_len;
2333
- fd_bincode_uint64_decode_unsafe( &stake_weights_len, ctx );
2334
- self->stake_weights_pool = fd_stake_weight_t_map_join_new( alloc_mem, stake_weights_len );
2335
- self->stake_weights_root = NULL;
2336
- for( ulong i=0; i < stake_weights_len; i++ ) {
2337
- fd_stake_weight_t_mapnode_t * node = fd_stake_weight_t_map_acquire( self->stake_weights_pool );
2338
- fd_stake_weight_new( &node->elem );
2339
- fd_stake_weight_decode_inner( &node->elem, alloc_mem, ctx );
2340
- fd_stake_weight_t_mapnode_t * out = NULL;;
2341
- fd_stake_weight_t_map_insert_or_replace( self->stake_weights_pool, &self->stake_weights_root, node, &out );
2342
- if( out != NULL ) {
2343
- // Unclear how to release the memory...
2344
- fd_stake_weight_t_map_release( self->stake_weights_pool, out );
2345
- }
2346
- }
2347
- }
2348
- void * fd_stake_weights_decode( void * mem, fd_bincode_decode_ctx_t * ctx ) {
2349
- fd_stake_weights_t * self = (fd_stake_weights_t *)mem;
2350
- fd_stake_weights_new( self );
2351
- void * alloc_region = (uchar *)mem + sizeof(fd_stake_weights_t);
2352
- void * * alloc_mem = &alloc_region;
2353
- fd_stake_weights_decode_inner( mem, alloc_mem, ctx );
2354
- return self;
2355
- }
2356
- void fd_stake_weights_new(fd_stake_weights_t * self) {
2357
- fd_memset( self, 0, sizeof(fd_stake_weights_t) );
2358
- }
2359
- void fd_stake_weights_walk( void * w, fd_stake_weights_t const * self, fd_types_walk_fn_t fun, const char *name, uint level, uint varint ) {
2360
- (void) varint;
2361
- fun( w, self, name, FD_FLAMENCO_TYPE_MAP, "fd_stake_weights", level++, 0 );
2362
- if( self->stake_weights_root ) {
2363
- for( fd_stake_weight_t_mapnode_t * n = fd_stake_weight_t_map_minimum(self->stake_weights_pool, self->stake_weights_root ); n; n = fd_stake_weight_t_map_successor( self->stake_weights_pool, n ) ) {
2364
- fd_stake_weight_walk(w, &n->elem, fun, "stake_weights", level, 0 );
2365
- }
2366
- }
2367
- fun( w, self, name, FD_FLAMENCO_TYPE_MAP_END, "fd_stake_weights", level--, 0 );
2368
- }
2369
- ulong fd_stake_weights_size( fd_stake_weights_t const * self ) {
2370
- ulong size = 0;
2371
- if( self->stake_weights_root ) {
2372
- size += sizeof(ulong);
2373
- ulong max = fd_stake_weight_t_map_max( self->stake_weights_pool );
2374
- size += fd_stake_weight_t_map_footprint( max );
2375
- for( fd_stake_weight_t_mapnode_t * n = fd_stake_weight_t_map_minimum( self->stake_weights_pool, self->stake_weights_root ); n; n = fd_stake_weight_t_map_successor( self->stake_weights_pool, n ) ) {
2376
- size += fd_stake_weight_size( &n->elem ) - sizeof(fd_stake_weight_t);
2377
- }
2378
- } else {
2379
- size += sizeof(ulong);
2380
- }
2381
- return size;
2382
- }
2383
-
2384
2251
int fd_delegation_encode( fd_delegation_t const * self, fd_bincode_encode_ctx_t * ctx ) {
2385
2252
int err;
2386
2253
err = fd_pubkey_encode( &self->voter_pubkey, ctx );
@@ -27074,13 +26941,6 @@ long fd_vote_accounts_pair_global_t_map_compare( fd_vote_accounts_pair_global_t_
27074
26941
long fd_account_keys_pair_t_map_compare( fd_account_keys_pair_t_mapnode_t * left, fd_account_keys_pair_t_mapnode_t * right ) {
27075
26942
return memcmp( left->elem.key.uc, right->elem.key.uc, sizeof(right->elem.key) );
27076
26943
}
27077
- #define REDBLK_T fd_stake_weight_t_mapnode_t
27078
- #define REDBLK_NAME fd_stake_weight_t_map
27079
- #define REDBLK_IMPL_STYLE 2
27080
- #include "../../util/tmpl/fd_redblack.c"
27081
- long fd_stake_weight_t_map_compare( fd_stake_weight_t_mapnode_t * left, fd_stake_weight_t_mapnode_t * right ) {
27082
- return memcmp( left->elem.key.uc, right->elem.key.uc, sizeof(right->elem.key) );
27083
- }
27084
26944
#define REDBLK_T fd_delegation_pair_t_mapnode_t
27085
26945
#define REDBLK_NAME fd_delegation_pair_t_map
27086
26946
#define REDBLK_IMPL_STYLE 2
0 commit comments