LCOV - code coverage report
Current view: top level - util/racesan - fd_racesan_weave.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 38 0.0 %
Date: 2025-12-07 04:58:33 Functions: 0 4 0.0 %

          Line data    Source code
       1             : #include "fd_racesan_weave.h"
       2             : #include "../../util/fd_util.h"
       3             : 
       4             : fd_racesan_weave_t *
       5           0 : fd_racesan_weave_new( fd_racesan_weave_t * weave ) {
       6           0 :   memset( weave, 0, sizeof(fd_racesan_weave_t) );
       7           0 :   return NULL;
       8           0 : }
       9             : 
      10             : void *
      11           0 : fd_racesan_weave_delete( fd_racesan_weave_t * weave ) {
      12           0 :   return weave;
      13           0 : }
      14             : 
      15             : void
      16             : fd_racesan_weave_add( fd_racesan_weave_t * weave,
      17           0 :                       fd_racesan_async_t * async ) {
      18           0 :   if( FD_UNLIKELY( weave->async_cnt>=FD_RACESAN_WEAVE_MAX ) ) {
      19           0 :     FD_LOG_ERR(( "exceeded max async count (%lu)", FD_RACESAN_WEAVE_MAX ));
      20           0 :   }
      21           0 :   weave->async[ weave->async_cnt++ ] = async;
      22           0 : }
      23             : 
      24             : void
      25             : fd_racesan_weave_exec_rand( fd_racesan_weave_t * weave,
      26             :                             ulong                seed,
      27           0 :                             ulong                step_max ) {
      28           0 :   uint async_cnt = weave->async_cnt;
      29           0 :   for( uint i=0U; i<async_cnt; i++ ) {
      30           0 :     weave->rem[ i ] = weave->async[ i ];
      31           0 :     fd_racesan_async_reset( weave->rem[ i ] );
      32           0 :   }
      33           0 :   weave->rem_cnt = async_cnt;
      34             : 
      35           0 :   uint  rng_seed = (uint)( seed>>32 );
      36           0 :   ulong rng_idx  = fd_ulong_hash( seed );
      37           0 :   fd_rng_t _rng[1];
      38           0 :   fd_rng_t * rng = fd_rng_join( fd_rng_new( _rng, rng_seed, rng_idx ) );
      39             : 
      40           0 :   for( ulong step=0UL;
      41           0 :        step<step_max && weave->rem_cnt;
      42           0 :        step++ ) {
      43           0 :     if( step>=step_max ) {
      44             :       /* FIXME gracefully handle this condition */
      45           0 :       FD_LOG_ERR(( "step_max (%lu) reached", step_max ));
      46           0 :     }
      47             : 
      48           0 :     uint rem_idx = fd_rng_uint_roll( rng, weave->rem_cnt );
      49           0 :     int done = !fd_racesan_async_step( weave->rem[ rem_idx ] );
      50           0 :     if( done ) {
      51           0 :       weave->rem[ rem_idx ] = weave->rem[ --weave->rem_cnt ];
      52           0 :     }
      53           0 :   }
      54             : 
      55           0 :   fd_rng_delete( fd_rng_leave( rng ) );
      56           0 : }

Generated by: LCOV version 1.14