LCOV - code coverage report
Current view: top level - util/racesan - fd_racesan_weave.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 39 0.0 %
Date: 2025-10-13 04:42:14 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 :   (void)weave;
       7           0 :   return NULL;
       8           0 : }
       9             : 
      10             : void *
      11           0 : fd_racesan_weave_delete( fd_racesan_weave_t * weave ) {
      12           0 :   (void)weave;
      13           0 :   return NULL;
      14           0 : }
      15             : 
      16             : void
      17             : fd_racesan_weave_add( fd_racesan_weave_t * weave,
      18           0 :                       fd_racesan_async_t * async ) {
      19           0 :   if( FD_UNLIKELY( weave->async_cnt>=FD_RACESAN_WEAVE_MAX ) ) {
      20           0 :     FD_LOG_ERR(( "exceeded max async count (%lu)", FD_RACESAN_WEAVE_MAX ));
      21           0 :   }
      22           0 :   weave->async[ weave->async_cnt++ ] = async;
      23           0 : }
      24             : 
      25             : void
      26             : fd_racesan_weave_exec_rand( fd_racesan_weave_t * weave,
      27             :                             ulong                seed,
      28           0 :                             ulong                step_max ) {
      29           0 :   uint async_cnt = weave->async_cnt;
      30           0 :   for( uint i=0U; i<async_cnt; i++ ) {
      31           0 :     weave->rem[ i ] = weave->async[ i ];
      32           0 :     fd_racesan_async_reset( weave->rem[ i ] );
      33           0 :   }
      34           0 :   weave->rem_cnt = async_cnt;
      35             : 
      36           0 :   uint  rng_seed = (uint)( seed>>32 );
      37           0 :   ulong rng_idx  = fd_ulong_hash( seed );
      38           0 :   fd_rng_t _rng[1];
      39           0 :   fd_rng_t * rng = fd_rng_join( fd_rng_new( _rng, rng_seed, rng_idx ) );
      40             : 
      41           0 :   for( ulong step=0UL;
      42           0 :        step<step_max && weave->rem_cnt;
      43           0 :        step++ ) {
      44           0 :     if( step>=step_max ) {
      45             :       /* FIXME gracefully handle this condition */
      46           0 :       FD_LOG_ERR(( "step_max (%lu) reached", step_max ));
      47           0 :     }
      48             : 
      49           0 :     uint rem_idx = fd_rng_uint_roll( rng, weave->rem_cnt );
      50           0 :     int done = !fd_racesan_async_step( weave->rem[ rem_idx ] );
      51           0 :     if( done ) {
      52           0 :       weave->rem[ rem_idx ] = weave->rem[ --weave->rem_cnt ];
      53           0 :     }
      54           0 :   }
      55             : 
      56           0 :   fd_rng_delete( fd_rng_leave( rng ) );
      57           0 : }

Generated by: LCOV version 1.14