Line data Source code
1 : #include "fd_exec.h" 2 : 3 : fd_slice_exec_t * 4 0 : fd_slice_exec_join( void * slmem ) { 5 0 : fd_slice_exec_t * slice_exec_ctx = (fd_slice_exec_t *)slmem; 6 0 : FD_TEST( slice_exec_ctx ); 7 0 : memset( slice_exec_ctx, 0, sizeof(fd_slice_exec_t) ); 8 0 : return slice_exec_ctx; 9 0 : } 10 : 11 : void 12 : fd_slice_exec_txn_parse( fd_slice_exec_t * slice_exec_ctx, 13 0 : fd_txn_p_t * txn_p_out ) { 14 0 : ulong pay_sz = 0UL; 15 0 : ulong txn_sz = fd_txn_parse_core( slice_exec_ctx->buf + slice_exec_ctx->wmark, 16 0 : fd_ulong_min( FD_TXN_MTU, slice_exec_ctx->sz - slice_exec_ctx->wmark ), 17 0 : TXN( txn_p_out ), 18 0 : NULL, 19 0 : &pay_sz ); 20 : 21 0 : if( FD_UNLIKELY( !pay_sz || !txn_sz || txn_sz > FD_TXN_MTU ) ) { 22 0 : FD_LOG_ERR(( "failed to parse transaction in replay" )); 23 0 : } 24 0 : fd_memcpy( txn_p_out->payload, slice_exec_ctx->buf + slice_exec_ctx->wmark, pay_sz ); 25 0 : txn_p_out->payload_sz = pay_sz; 26 : 27 0 : slice_exec_ctx->wmark += pay_sz; 28 0 : slice_exec_ctx->txns_rem--; 29 0 : } 30 : 31 : void 32 0 : fd_slice_exec_microblock_parse( fd_slice_exec_t * slice_exec_ctx ) { 33 0 : fd_microblock_hdr_t * hdr = (fd_microblock_hdr_t *)fd_type_pun( slice_exec_ctx->buf + slice_exec_ctx->wmark ); 34 0 : FD_LOG_DEBUG(( "[%s] reading microblock with %lu txns", __func__, hdr->txn_cnt )); 35 0 : slice_exec_ctx->txns_rem = hdr->txn_cnt; 36 0 : slice_exec_ctx->last_mblk_off = slice_exec_ctx->wmark; 37 0 : slice_exec_ctx->wmark += sizeof(fd_microblock_hdr_t); 38 0 : slice_exec_ctx->mblks_rem--; 39 0 : } 40 : 41 : void 42 0 : fd_slice_exec_reset( fd_slice_exec_t * slice_exec_ctx ) { 43 0 : slice_exec_ctx->last_batch = 0; 44 0 : slice_exec_ctx->txns_rem = 0; 45 0 : slice_exec_ctx->mblks_rem = 0; 46 0 : slice_exec_ctx->sz = 0; 47 0 : slice_exec_ctx->wmark = 0; 48 0 : slice_exec_ctx->last_mblk_off = 0; 49 0 : } 50 : 51 : void 52 : fd_slice_exec_begin( fd_slice_exec_t * slice_exec_ctx, 53 : ulong slice_sz, 54 0 : int last_batch ) { 55 0 : slice_exec_ctx->sz = slice_sz; 56 0 : slice_exec_ctx->last_batch = last_batch; 57 0 : slice_exec_ctx->txns_rem = 0; 58 0 : slice_exec_ctx->mblks_rem = FD_LOAD( ulong, slice_exec_ctx->buf ); 59 0 : slice_exec_ctx->wmark = sizeof(ulong); 60 0 : slice_exec_ctx->last_mblk_off = 0; 61 0 : }