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