LCOV - code coverage report
Current view: top level - discof/replay - fd_eslot_mgr.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 264 0.0 %
Date: 2025-09-19 04:41:14 Functions: 0 15 0.0 %

          Line data    Source code
       1             : #include "fd_eslot_mgr.h"
       2             : #include "../../flamenco/runtime/fd_runtime_const.h"
       3             : 
       4             : #define POOL_NAME fd_eslot_mgr_pool
       5           0 : #define POOL_T    fd_eslot_ele_t
       6           0 : #define POOL_NEXT next_
       7             : #include "../../util/tmpl/fd_pool.c"
       8             : 
       9             : #define MAP_NAME          fd_eslot_mgr_map_eslot
      10             : #define MAP_ELE_T         fd_eslot_ele_t
      11             : #define MAP_KEY_T         fd_eslot_t
      12           0 : #define MAP_KEY           eslot
      13           0 : #define MAP_NEXT          next_
      14           0 : #define MAP_KEY_EQ(k0,k1) (k0->id==k1->id)
      15           0 : #define MAP_KEY_HASH(k,s) (k->id ^ s)
      16             : #include "../../util/tmpl/fd_map_chain.c"
      17             : 
      18             : #define MAP_NAME          fd_eslot_mgr_map_merkle_root
      19             : #define MAP_ELE_T         fd_eslot_ele_t
      20             : #define MAP_KEY_T         fd_hash_t
      21           0 : #define MAP_KEY           merkle_root
      22           0 : #define MAP_NEXT          next_mr_
      23           0 : #define MAP_KEY_EQ(k0,k1) (fd_hash_eq( k0,k1 ))
      24           0 : #define MAP_KEY_HASH(k,s) (fd_hash( s, k, sizeof(fd_hash_t) ))
      25             : #include "../../util/tmpl/fd_map_chain.c"
      26             : 
      27             : 
      28             : struct fd_eslot_mgr {
      29             :   ulong magic;
      30             :   ulong eslot_cnt;
      31             :   ulong pool_offset;
      32             :   ulong map_eslot_offset;
      33             :   ulong map_merkle_root_offset;
      34             : };
      35             : typedef struct fd_eslot_mgr fd_eslot_mgr_t;
      36             : 
      37             : static inline fd_eslot_mgr_map_eslot_t *
      38           0 : fd_eslot_mgr_eslot_map_get( fd_eslot_mgr_t const * eslot_mgr ) {
      39           0 :   return fd_eslot_mgr_map_eslot_join( (uchar *)eslot_mgr + eslot_mgr->map_eslot_offset );
      40           0 : }
      41             : 
      42             : static inline fd_eslot_mgr_map_merkle_root_t *
      43           0 : fd_eslot_mgr_merkle_root_map_get( fd_eslot_mgr_t const * eslot_mgr ) {
      44           0 :   return fd_eslot_mgr_map_merkle_root_join( (uchar *)eslot_mgr + eslot_mgr->map_merkle_root_offset );
      45           0 : }
      46             : 
      47             : static inline fd_eslot_ele_t *
      48           0 : fd_eslot_mgr_pool_get( fd_eslot_mgr_t const * eslot_mgr ) {
      49           0 :   return fd_eslot_mgr_pool_join( (uchar *)eslot_mgr + eslot_mgr->pool_offset );
      50           0 : }
      51             : 
      52             : ulong
      53           0 : fd_eslot_mgr_align( void ) {
      54           0 :   return 128UL;
      55           0 : }
      56             : 
      57             : ulong
      58           0 : fd_eslot_mgr_footprint( ulong eslot_cnt ) {
      59           0 :   ulong map_eslot_chain_cnt       = fd_eslot_mgr_map_eslot_chain_cnt_est( eslot_cnt );
      60           0 :   ulong map_merkle_root_chain_cnt = fd_eslot_mgr_map_merkle_root_chain_cnt_est( eslot_cnt );
      61           0 :   ulong l = FD_LAYOUT_INIT;
      62           0 :   l = FD_LAYOUT_APPEND( l,  fd_eslot_mgr_align(),                 sizeof(fd_eslot_mgr_t) );
      63           0 :   l = FD_LAYOUT_APPEND( l,  fd_eslot_mgr_pool_align(),            fd_eslot_mgr_pool_footprint( eslot_cnt ) );
      64           0 :   l = FD_LAYOUT_APPEND( l,  fd_eslot_mgr_map_eslot_align(),       fd_eslot_mgr_map_eslot_footprint( map_eslot_chain_cnt ) );
      65           0 :   l = FD_LAYOUT_APPEND( l,  fd_eslot_mgr_map_merkle_root_align(), fd_eslot_mgr_map_merkle_root_footprint( map_merkle_root_chain_cnt ) );
      66           0 :   return FD_LAYOUT_FINI( l, fd_eslot_mgr_align() );
      67           0 : }
      68             : 
      69             : uchar *
      70             : fd_eslot_mgr_new( void * shmem,
      71             :                   ulong  eslot_cnt,
      72           0 :                   ulong  seed ) {
      73           0 :   if( FD_UNLIKELY( !shmem ) ) {
      74           0 :     FD_LOG_WARNING(( "NULL shmem" ));
      75           0 :     return NULL;
      76           0 :   }
      77             : 
      78           0 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)shmem, fd_eslot_mgr_align() ) ) ) {
      79           0 :     FD_LOG_WARNING(( "misaligned shmem" ));
      80           0 :     return NULL;
      81           0 :   }
      82             : 
      83           0 :   ulong map_eslot_chain_cnt       = fd_eslot_mgr_map_eslot_chain_cnt_est( eslot_cnt );
      84           0 :   ulong map_merkle_root_chain_cnt = fd_eslot_mgr_map_merkle_root_chain_cnt_est( eslot_cnt );
      85             : 
      86           0 :   FD_SCRATCH_ALLOC_INIT( l, shmem );
      87           0 :   fd_eslot_mgr_t * eslot_mgr           = FD_SCRATCH_ALLOC_APPEND( l, fd_eslot_mgr_align(),                 sizeof(fd_eslot_mgr_t) );
      88           0 :   void *           pool_mem            = FD_SCRATCH_ALLOC_APPEND( l, fd_eslot_mgr_pool_align(),            fd_eslot_mgr_pool_footprint( eslot_cnt ) );
      89           0 :   void *           map_eslot_mem       = FD_SCRATCH_ALLOC_APPEND( l, fd_eslot_mgr_map_eslot_align(),       fd_eslot_mgr_map_eslot_footprint( map_eslot_chain_cnt ) );
      90           0 :   void *           map_merkle_root_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_eslot_mgr_map_merkle_root_align(), fd_eslot_mgr_map_merkle_root_footprint( map_merkle_root_chain_cnt ) );
      91             : 
      92           0 :   if( FD_UNLIKELY( FD_SCRATCH_ALLOC_FINI( l, fd_eslot_mgr_align() )!=(ulong)shmem+fd_eslot_mgr_footprint( eslot_cnt ) ) ) {
      93           0 :     FD_LOG_WARNING(( "fd_eslot_mgr_new: bad layout" ));
      94           0 :     return NULL;
      95           0 :   }
      96             : 
      97           0 :   if( FD_UNLIKELY( !fd_eslot_mgr_pool_new( pool_mem, eslot_cnt ) ) ) {
      98           0 :     FD_LOG_WARNING(( "fd_eslot_mgr_new: bad pool" ));
      99           0 :     return NULL;
     100           0 :   }
     101             : 
     102           0 :   if( FD_UNLIKELY( !fd_eslot_mgr_map_eslot_new( map_eslot_mem, map_eslot_chain_cnt, seed ) ) ) {
     103           0 :     FD_LOG_WARNING(( "fd_eslot_mgr_new: bad map_eslot" ));
     104           0 :     return NULL;
     105           0 :   }
     106             : 
     107           0 :   if( FD_UNLIKELY( !fd_eslot_mgr_map_merkle_root_new( map_merkle_root_mem, map_merkle_root_chain_cnt, seed ) ) ) {
     108           0 :     FD_LOG_WARNING(( "fd_eslot_mgr_new: bad map_merkle_root" ));
     109           0 :     return NULL;
     110           0 :   }
     111             : 
     112           0 :   eslot_mgr->eslot_cnt              = eslot_cnt;
     113           0 :   eslot_mgr->pool_offset            = (ulong)pool_mem - (ulong)shmem;
     114           0 :   eslot_mgr->map_eslot_offset       = (ulong)map_eslot_mem - (ulong)shmem;
     115           0 :   eslot_mgr->map_merkle_root_offset = (ulong)map_merkle_root_mem - (ulong)shmem;
     116             : 
     117           0 :   FD_COMPILER_MFENCE();
     118           0 :   FD_VOLATILE( eslot_mgr->magic ) = FD_ESLOT_MGR_MAGIC;
     119           0 :   FD_COMPILER_MFENCE();
     120             : 
     121           0 :   return shmem;
     122           0 : }
     123             : 
     124             : fd_eslot_mgr_t *
     125           0 : fd_eslot_mgr_join( void * shmem ) {
     126           0 :   if( FD_UNLIKELY( !shmem ) ) {
     127           0 :     FD_LOG_WARNING(( "NULL shmem" ));
     128           0 :     return NULL;
     129           0 :   }
     130             : 
     131           0 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)shmem, fd_eslot_mgr_align() ) ) ) {
     132           0 :     FD_LOG_WARNING(( "misaligned shmem" ));
     133           0 :     return NULL;
     134           0 :   }
     135             : 
     136           0 :   fd_eslot_mgr_t * eslot_mgr = (fd_eslot_mgr_t *)shmem;
     137             : 
     138           0 :   if( FD_UNLIKELY( eslot_mgr->magic!=FD_ESLOT_MGR_MAGIC ) ) {
     139           0 :     FD_LOG_WARNING(( "Invalid eslot mgr magic: %lx", eslot_mgr->magic ));
     140           0 :     return NULL;
     141           0 :   }
     142             : 
     143           0 :   ulong map_eslot_chain_cnt       = fd_eslot_mgr_map_eslot_chain_cnt_est( eslot_mgr->eslot_cnt );
     144           0 :   ulong map_merkle_root_chain_cnt = fd_eslot_mgr_map_merkle_root_chain_cnt_est( eslot_mgr->eslot_cnt );
     145           0 :   FD_SCRATCH_ALLOC_INIT( l, eslot_mgr );
     146           0 :   eslot_mgr                  = FD_SCRATCH_ALLOC_APPEND( l, fd_eslot_mgr_align(),                 sizeof(fd_eslot_mgr_t) );
     147           0 :   void * pool_mem            = FD_SCRATCH_ALLOC_APPEND( l, fd_eslot_mgr_pool_align(),            fd_eslot_mgr_pool_footprint( eslot_mgr->eslot_cnt ) );
     148           0 :   void * map_eslot_mem       = FD_SCRATCH_ALLOC_APPEND( l, fd_eslot_mgr_map_eslot_align(),       fd_eslot_mgr_map_eslot_footprint( map_eslot_chain_cnt ) );
     149           0 :   void * map_merkle_root_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_eslot_mgr_map_merkle_root_align(), fd_eslot_mgr_map_merkle_root_footprint( map_merkle_root_chain_cnt ) );
     150             : 
     151           0 :   if( FD_UNLIKELY( FD_SCRATCH_ALLOC_FINI( l, fd_eslot_mgr_align() )!=(ulong)shmem+fd_eslot_mgr_footprint( eslot_mgr->eslot_cnt ) ) ) {
     152           0 :     FD_LOG_WARNING(( "fd_eslot_mgr_join: bad layout" ));
     153           0 :     return NULL;
     154           0 :   }
     155             : 
     156           0 :   if( FD_UNLIKELY( !fd_eslot_mgr_pool_join( pool_mem ) ) ) {
     157           0 :     FD_LOG_WARNING(( "Failed to join eslot mgr pool" ));
     158           0 :     return NULL;
     159           0 :   }
     160             : 
     161           0 :   if( FD_UNLIKELY( !fd_eslot_mgr_map_eslot_join( map_eslot_mem ) ) ) {
     162           0 :     FD_LOG_WARNING(( "Failed to join eslot mgr map_eslot" ));
     163           0 :     return NULL;
     164           0 :   }
     165             : 
     166           0 :   if( FD_UNLIKELY( !fd_eslot_mgr_map_merkle_root_join( map_merkle_root_mem ) ) ) {
     167           0 :     FD_LOG_WARNING(( "Failed to join eslot mgr map_merkle_root" ));
     168           0 :     return NULL;
     169           0 :   }
     170             : 
     171           0 :   return eslot_mgr;
     172           0 : }
     173             : 
     174             : fd_eslot_ele_t *
     175             : fd_eslot_mgr_ele_insert_fec( fd_eslot_mgr_t *  mgr,
     176             :                              ulong             slot,
     177             :                              fd_hash_t const * merkle_root,
     178             :                              fd_hash_t const * chained_merkle_root,
     179             :                              ulong             fec_set_idx,
     180           0 :                              int *             is_equiv_out ) {
     181             : 
     182           0 :   fd_eslot_ele_t *                 pool            = fd_eslot_mgr_pool_get( mgr );
     183           0 :   fd_eslot_mgr_map_eslot_t *       eslot_map       = fd_eslot_mgr_eslot_map_get( mgr );
     184           0 :   fd_eslot_mgr_map_merkle_root_t * merkle_root_map = fd_eslot_mgr_merkle_root_map_get( mgr );
     185             : 
     186           0 :   fd_eslot_ele_t * chained_ele = fd_eslot_mgr_map_merkle_root_ele_query( merkle_root_map, chained_merkle_root, NULL, pool );
     187           0 :   if( FD_LIKELY( chained_ele ) ) {
     188             :     /* This means that the chained merkle root already has an entry in
     189             :        the map.  Now, we either have to continue chaining off of this
     190             :        entry, or create a new entry if the slot numbers are different.
     191             :     */
     192             : 
     193           0 :     if( FD_LIKELY( chained_ele->eslot.slot==slot ) ) {
     194             :       /* This means that the slot numbers are the same.  We need to
     195             :          continue chaining off of this entry. */
     196           0 :       if( FD_UNLIKELY( fec_set_idx<=chained_ele->highest_fec_idx_observed ) ) {
     197           0 :         FD_LOG_ERR(( "FEC chaining is corrupted (fec_set_idx: %lu, highest_fec_idx_observed: %lu)", fec_set_idx, chained_ele->highest_fec_idx_observed ));
     198           0 :       }
     199             :       /* Update the merkle root to the new one.  This requires removing
     200             :          the old entry from the merkle root map, updating the hash, and
     201             :          then re-inserting the entry into the new merkle root map. */
     202           0 :       fd_eslot_mgr_map_merkle_root_ele_remove( merkle_root_map, &chained_ele->merkle_root, NULL, pool );
     203           0 :       chained_ele->merkle_root              = *merkle_root;
     204           0 :       chained_ele->highest_fec_idx_observed = fec_set_idx;
     205           0 :       fd_eslot_mgr_map_merkle_root_ele_insert( merkle_root_map, chained_ele, pool );
     206           0 :       if( is_equiv_out ) *is_equiv_out = 0;
     207           0 :       return chained_ele;
     208           0 :     } else {
     209             :       /* Search for the first free prime count for this slot. */
     210           0 :       ulong prime = 0UL;
     211           0 :       for( prime=0UL; prime<FD_ESLOT_EQVOC_PER_SLOT_CNT_MAX; prime++ ) {
     212           0 :         fd_eslot_t new_eslot = fd_eslot( slot, prime );
     213           0 :         fd_eslot_ele_t * slot_ele = fd_eslot_mgr_map_eslot_ele_query( eslot_map, &new_eslot, NULL, pool );
     214           0 :         if( FD_LIKELY( !slot_ele ) ) {
     215             :           /* This means that the prime count is not in use.  We need to
     216             :              create a new entry. */
     217           0 :           break;
     218           0 :         }
     219           0 :       }
     220             : 
     221           0 :       if( FD_UNLIKELY( prime==FD_ESLOT_EQVOC_PER_SLOT_CNT_MAX ) ) {
     222           0 :         FD_LOG_ERR(( "Failed to find free prime count for slot: %lu", slot ));
     223           0 :       }
     224             : 
     225           0 :       if( is_equiv_out ) *is_equiv_out = prime!=0UL;
     226             : 
     227             :       /* We succesfully found a prime count for the slot.  We need to
     228             :          create a new entry. */
     229           0 :       fd_eslot_ele_t * new_ele = fd_eslot_mgr_pool_ele_acquire( pool );
     230           0 :       if( FD_UNLIKELY( !new_ele ) ) {
     231           0 :         FD_LOG_ERR(( "Failed to acquire eslot ele" ));
     232           0 :       }
     233             : 
     234           0 :       fd_eslot_t new_eslot = fd_eslot( slot, prime );
     235           0 :       new_ele->eslot                    = new_eslot;
     236           0 :       new_ele->parent_eslot             = chained_ele->eslot;
     237           0 :       new_ele->highest_fec_idx_observed = fec_set_idx;
     238           0 :       new_ele->merkle_root              = *merkle_root;
     239           0 :       new_ele->is_leader                = 0;
     240             : 
     241           0 :       fd_eslot_mgr_map_eslot_ele_insert( eslot_map, new_ele, pool );
     242           0 :       fd_eslot_mgr_map_merkle_root_ele_insert( merkle_root_map, new_ele, pool );
     243             : 
     244           0 :       return new_ele;
     245           0 :     }
     246           0 :   } else {
     247             :     /* This means that there is no direct link to the merkle root.  This
     248             :        can mean one of two things:
     249             :        1. There has been an equiovcation mid-block.  This is recoverable
     250             :           by creating a new entry for the given slot.
     251             :        2. There is some corruption with linking FEC sets.  This is
     252             :           unrecoverable and will crash the program.
     253             :        FIXME: This doesn't correctly link to the correct parent in the
     254             :        case where we have multiple parents.  This is blocked on reasm
     255             :        fecs containing the parent block id. */
     256             : 
     257           0 :     ulong prime;
     258           0 :     for( prime=0UL; prime<FD_ESLOT_EQVOC_PER_SLOT_CNT_MAX; prime++ ) {
     259           0 :       fd_eslot_t eslot = fd_eslot( slot, prime );
     260           0 :       fd_eslot_ele_t * slot_ele = fd_eslot_mgr_map_eslot_ele_query( eslot_map, &eslot, NULL, pool );
     261           0 :       if( !!slot_ele && fec_set_idx<=slot_ele->highest_fec_idx_observed ) {
     262             :         /* We have an equivocation at this slot + prime combination.
     263             :            Try the next prime. */
     264           0 :         continue;
     265           0 :       } else {
     266           0 :         break;
     267           0 :       }
     268           0 :     }
     269             : 
     270           0 :     if( FD_UNLIKELY( prime==FD_ESLOT_EQVOC_PER_SLOT_CNT_MAX ) ) {
     271           0 :       FD_LOG_ERR(( "Failed to find free prime count for slot: %lu", slot ));
     272           0 :     } else if( FD_UNLIKELY( prime==0UL ) ) {
     273             :       /* This should not be possible. */
     274           0 :       FD_LOG_ERR(( "FEC chaining is corrupted" ));
     275           0 :     }
     276             : 
     277           0 :     if( is_equiv_out ) *is_equiv_out = 1;
     278             : 
     279           0 :     fd_eslot_ele_t * new_ele = fd_eslot_mgr_pool_ele_acquire( pool );
     280           0 :     if( FD_UNLIKELY( !new_ele ) ) {
     281           0 :       FD_LOG_ERR(( "Failed to acquire eslot ele" ));
     282           0 :     }
     283             : 
     284           0 :     fd_eslot_t new_eslot = fd_eslot( slot, prime );
     285           0 :     new_ele->eslot                    = new_eslot;
     286           0 :     new_ele->highest_fec_idx_observed = fec_set_idx;
     287           0 :     new_ele->merkle_root              = *merkle_root;
     288           0 :     new_ele->is_leader                = 0;
     289             : 
     290           0 :     fd_eslot_mgr_map_eslot_ele_insert( eslot_map, new_ele, pool );
     291           0 :     fd_eslot_mgr_map_merkle_root_ele_insert( merkle_root_map, new_ele, pool );
     292           0 :     return new_ele;
     293           0 :   }
     294           0 : }
     295             : 
     296             : fd_eslot_ele_t *
     297             : fd_eslot_mgr_ele_insert_leader( fd_eslot_mgr_t * mgr,
     298             :                                 ulong            slot,
     299           0 :                                 fd_eslot_t       parent_eslot ) {
     300             : 
     301           0 :   fd_eslot_ele_t *                 pool            = fd_eslot_mgr_pool_get( mgr );
     302           0 :   fd_eslot_mgr_map_eslot_t *       eslot_map       = fd_eslot_mgr_eslot_map_get( mgr );
     303           0 :   fd_eslot_mgr_map_merkle_root_t * merkle_root_map = fd_eslot_mgr_merkle_root_map_get( mgr );
     304             : 
     305           0 :   fd_eslot_ele_t * ele = fd_eslot_mgr_pool_ele_acquire( pool );
     306           0 :   if( FD_UNLIKELY( !ele ) ) {
     307           0 :     FD_LOG_ERR(( "Failed to acquire eslot ele" ));
     308           0 :   }
     309             : 
     310           0 :   fd_hash_t merkle_root = { .ul[0] = slot };
     311             : 
     312             :   /* Our leader blocks will never be equivocated. */
     313           0 :   ele->eslot        = fd_eslot( slot, 0UL );
     314           0 :   ele->parent_eslot = parent_eslot;
     315           0 :   ele->is_leader    = 1;
     316           0 :   ele->merkle_root  = merkle_root;
     317             : 
     318           0 :   fd_eslot_mgr_map_eslot_ele_insert( eslot_map, ele, pool );
     319           0 :   fd_eslot_mgr_map_merkle_root_ele_insert( merkle_root_map, ele, pool );
     320           0 :   return ele;
     321           0 : }
     322             : 
     323             : fd_eslot_ele_t *
     324             : fd_eslot_mgr_ele_insert_initial( fd_eslot_mgr_t * mgr,
     325           0 :                                  ulong            slot ) {
     326           0 :   fd_eslot_ele_t *                 pool            = fd_eslot_mgr_pool_get( mgr );
     327           0 :   fd_eslot_mgr_map_eslot_t *       eslot_map       = fd_eslot_mgr_eslot_map_get( mgr );
     328           0 :   fd_eslot_mgr_map_merkle_root_t * merkle_root_map = fd_eslot_mgr_merkle_root_map_get( mgr );
     329             : 
     330           0 :   fd_eslot_ele_t * ele = fd_eslot_mgr_pool_ele_acquire( pool );
     331           0 :   if( FD_UNLIKELY( !ele ) ) {
     332           0 :     FD_LOG_ERR(( "Failed to acquire eslot ele" ));
     333           0 :   }
     334             : 
     335           0 :   fd_hash_t merkle_root = { .ul[0] = FD_RUNTIME_INITIAL_BLOCK_ID };
     336             : 
     337           0 :   ele->parent_eslot.id = ULONG_MAX;
     338           0 :   ele->eslot        = fd_eslot( slot, 0UL );
     339           0 :   ele->is_leader    = 0;
     340           0 :   ele->merkle_root  = merkle_root;
     341             : 
     342           0 :   fd_eslot_mgr_map_eslot_ele_insert( eslot_map, ele, pool );
     343           0 :   fd_eslot_mgr_map_merkle_root_ele_insert( merkle_root_map, ele, pool );
     344           0 :   return ele;
     345           0 : }
     346             : 
     347             : int
     348             : fd_eslot_mgr_is_leader( fd_eslot_mgr_t * mgr,
     349           0 :                         ulong            slot ) {
     350           0 :   fd_eslot_mgr_map_eslot_t * eslot_map = fd_eslot_mgr_eslot_map_get( mgr );
     351           0 :   fd_eslot_ele_t *           pool      = fd_eslot_mgr_pool_get( mgr );
     352           0 :   fd_eslot_t                 eslot     = fd_eslot( slot, 0UL );
     353           0 :   fd_eslot_ele_t *           ele       = fd_eslot_mgr_map_eslot_ele_query( eslot_map, &eslot, NULL, pool );
     354           0 :   if( FD_LIKELY( ele ) ) {
     355           0 :     return ele->is_leader;
     356           0 :   }
     357           0 :   return 0;
     358           0 : }
     359             : 
     360             : fd_eslot_ele_t *
     361             : fd_eslot_mgr_ele_query_eslot( fd_eslot_mgr_t * mgr,
     362           0 :                               fd_eslot_t       eslot ) {
     363           0 :   fd_eslot_mgr_map_eslot_t * eslot_map = fd_eslot_mgr_eslot_map_get( mgr );
     364           0 :   fd_eslot_ele_t *           pool      = fd_eslot_mgr_pool_get( mgr );
     365           0 :   return fd_eslot_mgr_map_eslot_ele_query( eslot_map, &eslot, NULL, pool );
     366           0 : }
     367             : 
     368             : fd_eslot_ele_t *
     369             : fd_eslot_mgr_ele_query_merkle_root( fd_eslot_mgr_t *  mgr,
     370           0 :                                     fd_hash_t const * merkle_root ) {
     371           0 :   fd_eslot_mgr_map_merkle_root_t * merkle_root_map = fd_eslot_mgr_merkle_root_map_get( mgr );
     372           0 :   fd_eslot_ele_t *                 pool            = fd_eslot_mgr_pool_get( mgr );
     373           0 :   return fd_eslot_mgr_map_merkle_root_ele_query( merkle_root_map, merkle_root, NULL, pool );
     374           0 : }
     375             : 
     376             : void
     377             : fd_eslot_mgr_rekey_merkle_root( fd_eslot_mgr_t *  mgr,
     378             :                                 fd_eslot_ele_t *  ele,
     379           0 :                                 fd_hash_t const * merkle_root ) {
     380           0 :   fd_eslot_mgr_map_merkle_root_t * merkle_root_map = fd_eslot_mgr_merkle_root_map_get( mgr );
     381           0 :   fd_eslot_ele_t *                 pool            = fd_eslot_mgr_pool_get( mgr );
     382             : 
     383           0 :   fd_eslot_mgr_map_merkle_root_ele_remove( merkle_root_map, &ele->merkle_root, NULL, pool );
     384           0 :   ele->merkle_root = *merkle_root;
     385           0 :   fd_eslot_mgr_map_merkle_root_ele_insert( merkle_root_map, ele, pool );
     386           0 : }
     387             : 
     388             : void
     389             : fd_eslot_mgr_publish( fd_eslot_mgr_t * mgr,
     390             :                       ulong            old_root_slot,
     391           0 :                       ulong            new_root_slot ) {
     392           0 :   fd_eslot_mgr_map_eslot_t *       eslot_map       = fd_eslot_mgr_eslot_map_get( mgr );
     393           0 :   fd_eslot_mgr_map_merkle_root_t * merkle_root_map = fd_eslot_mgr_merkle_root_map_get( mgr );
     394           0 :   fd_eslot_ele_t *                 pool            = fd_eslot_mgr_pool_get( mgr );
     395             : 
     396           0 :   for( ulong slot=old_root_slot; slot<new_root_slot; slot++ ) {
     397           0 :     for( ulong prime=0UL; prime<FD_ESLOT_EQVOC_PER_SLOT_CNT_MAX; prime++ ) {
     398           0 :       fd_eslot_t eslot = fd_eslot( slot, prime );
     399           0 :       fd_eslot_ele_t * ele = fd_eslot_mgr_map_eslot_ele_query( eslot_map, &eslot, NULL, pool );
     400           0 :       if( FD_LIKELY( !ele ) ) {
     401           0 :         break;
     402           0 :       } else {
     403           0 :         fd_eslot_mgr_map_merkle_root_ele_remove( merkle_root_map, &ele->merkle_root, NULL, pool );
     404             :         fd_eslot_mgr_map_eslot_ele_remove( eslot_map, &eslot, NULL, pool );
     405           0 :         fd_eslot_mgr_pool_ele_release( pool, ele );
     406           0 :       }
     407           0 :     }
     408           0 :   }
     409           0 : }

Generated by: LCOV version 1.14