1
- #include "../fd_flamenco.h"
2
1
#include "fd_solcap_proto.h"
3
2
#include "fd_solcap_reader.h"
4
3
#include "fd_solcap.pb.h"
5
4
#include "../runtime/fd_executor_err.h"
5
+ #include "../../ballet/base64/fd_base64.h"
6
6
#include "../../ballet/nanopb/pb_decode.h"
7
- #include "../../util/textstream/fd_textstream.h"
8
7
#include <errno.h>
9
8
#include <stdio.h>
10
9
@@ -118,7 +117,6 @@ process_account( FILE * file,
118
117
allows padding in the middle, but it's cleaner to only have
119
118
padding at the end of the message. */
120
119
# define PART_RAW_SZ (720UL)
121
- # define PART_BLK_SZ (4UL*(PART_RAW_SZ+2UL)/3UL) /* see fd_textstream_encode_base64 */
122
120
ulong data_sz = meta -> data_sz ;
123
121
while ( data_sz > 0UL ) {
124
122
ulong n = fd_ulong_min ( data_sz , PART_RAW_SZ );
@@ -129,25 +127,13 @@ process_account( FILE * file,
129
127
FD_LOG_ERR (( "fread account data failed (%d-%s)" , errno , strerror ( errno ) ));
130
128
131
129
/* Encode chunk */
132
- fd_valloc_t valloc = fd_scratch_virtual ();
133
- fd_scratch_push ();
134
-
135
- fd_textstream_t _data_out [1 ];
136
- fd_textstream_t * data_out = fd_textstream_new ( _data_out , valloc , PART_BLK_SZ );
137
- fd_textstream_encode_base64 ( data_out , buf , n );
138
-
139
- /* Get pointer to encoded chunk */
140
- FD_TEST ( 1UL == fd_textstream_get_iov_count ( data_out ) );
141
- struct fd_iovec iov [1 ];
142
- FD_TEST ( 0 == fd_textstream_get_iov ( data_out , iov ) );
143
-
130
+ char chunk [ FD_BASE64_ENC_SZ ( PART_RAW_SZ ) ];
131
+ ulong chunk_sz = fd_base64_encode ( chunk , buf , n );
144
132
/* Print encoded chunk */
145
- FD_TEST ( 1UL == fwrite ( iov [ 0 ]. iov_base , iov [ 0 ]. iov_len , 1UL , stdout ) );
133
+ FD_TEST ( 1UL == fwrite ( chunk , chunk_sz , 1UL , stdout ) );
146
134
147
135
/* Wind up for next iteration */
148
136
data_sz -= n ;
149
- fd_textstream_destroy ( data_out ); /* technically noop */
150
- fd_scratch_pop ();
151
137
}
152
138
# undef PART_RAW_SZ
153
139
# undef PART_BLK_SZ
@@ -473,36 +459,16 @@ main( int argc,
473
459
for ( int i = 1 ; i < argc ; i ++ )
474
460
if ( 0 == strcmp ( argv [i ], "--help" ) ) return usage ();
475
461
476
- char const * _page_sz = fd_env_strip_cmdline_cstr ( & argc , & argv , "--page-sz" , NULL , "gigantic" );
477
- ulong page_cnt = fd_env_strip_cmdline_ulong ( & argc , & argv , "--page-cnt" , NULL , 2UL );
478
- ulong scratch_mb = fd_env_strip_cmdline_ulong ( & argc , & argv , "--scratch-mb" , NULL , 1024UL );
479
- int verbose = fd_env_strip_cmdline_int ( & argc , & argv , "-v" , NULL , 0 );
480
- ulong start_slot = fd_env_strip_cmdline_ulong ( & argc , & argv , "--start-slot" , NULL , 0 );
481
- ulong end_slot = fd_env_strip_cmdline_ulong ( & argc , & argv , "--end-slot" , NULL , ULONG_MAX );
482
-
483
- ulong page_sz = fd_cstr_to_shmem_page_sz ( _page_sz );
484
- if ( FD_UNLIKELY ( !page_sz ) ) FD_LOG_ERR (( "unsupported --page-sz" ));
462
+ int verbose = fd_env_strip_cmdline_int ( & argc , & argv , "-v" , NULL , 0 );
463
+ ulong start_slot = fd_env_strip_cmdline_ulong ( & argc , & argv , "--start-slot" , NULL , 0 );
464
+ ulong end_slot = fd_env_strip_cmdline_ulong ( & argc , & argv , "--end-slot" , NULL , ULONG_MAX );
485
465
486
466
if ( argc != 2 ) {
487
467
fprintf ( stderr , "ERROR: expected 1 argument, got %d\n" , argc - 1 );
488
468
usage ();
489
469
return 1 ;
490
470
}
491
471
492
- /* Create workspace and scratch allocator */
493
-
494
- fd_wksp_t * wksp = fd_wksp_new_anonymous ( page_sz , page_cnt , fd_log_cpu_id (), "wksp" , 0UL );
495
- if ( FD_UNLIKELY ( !wksp ) ) FD_LOG_ERR (( "fd_wksp_new_anonymous() failed" ));
496
-
497
- ulong smax = scratch_mb << 20 ;
498
- void * smem = fd_wksp_alloc_laddr ( wksp , fd_scratch_smem_align (), smax , 1UL );
499
- if ( FD_UNLIKELY ( !smem ) ) FD_LOG_ERR (( "Failed to alloc scratch mem" ));
500
- ulong scratch_depth = 4UL ;
501
- void * fmem = fd_wksp_alloc_laddr ( wksp , fd_scratch_fmem_align (), fd_scratch_fmem_footprint ( scratch_depth ), 2UL );
502
- if ( FD_UNLIKELY ( !fmem ) ) FD_LOG_ERR (( "Failed to alloc scratch frames" ));
503
-
504
- fd_scratch_attach ( smem , fmem , smax , scratch_depth );
505
-
506
472
/* Open file */
507
473
508
474
char const * path = argv [ 1 ];
@@ -558,9 +524,6 @@ main( int argc,
558
524
/* Cleanup */
559
525
560
526
FD_LOG_NOTICE (( "Done" ));
561
- FD_TEST ( fd_scratch_frame_used ()== 0UL );
562
- fd_wksp_free_laddr ( fd_scratch_detach ( NULL ) );
563
- fd_wksp_free_laddr ( fmem );
564
527
fclose ( file );
565
528
fd_halt ();
566
529
return 0 ;
0 commit comments