Line data Source code
1 : #include "fd_acc_mgr.h" 2 : #include "../../funk/fd_funk.h" 3 : 4 : fd_account_meta_t const * 5 : fd_funk_get_acc_meta_readonly( fd_funk_t const * funk, 6 : fd_funk_txn_xid_t const * xid, 7 : fd_pubkey_t const * pubkey, 8 : fd_funk_rec_t const ** orec, 9 : int * opt_err, 10 4194 : fd_funk_txn_xid_t * out_xid ) { 11 4194 : fd_funk_rec_key_t id = fd_funk_acc_key( pubkey ); 12 : 13 : /* When we access this pointer later on in the execution pipeline, we assume that 14 : nothing else will change that account. If the account is writable in the solana txn, 15 : then we copy the data. If the account is read-only, we do not. This is safe because of 16 : the read-write locks that the solana transaction holds on the account. */ 17 4194 : for( ; ; ) { 18 : 19 4194 : fd_funk_rec_query_t query[1]; 20 4194 : fd_funk_rec_t const * rec = fd_funk_rec_query_try_global( funk, xid, &id, out_xid, query ); 21 : 22 4194 : if( FD_UNLIKELY( !rec ) ) { 23 3675 : fd_int_store_if( !!opt_err, opt_err, FD_ACC_MGR_ERR_UNKNOWN_ACCOUNT ); 24 3675 : return NULL; 25 3675 : } 26 519 : if( NULL != orec ) 27 0 : *orec = rec; 28 : 29 519 : void const * raw = fd_funk_val( rec, fd_funk_wksp(funk) ); 30 : 31 519 : fd_account_meta_t const * metadata = fd_type_pun_const( raw ); 32 519 : fd_int_store_if( !!opt_err, opt_err, FD_ACC_MGR_SUCCESS ); 33 519 : return metadata; 34 : 35 4194 : } 36 : 37 : /* unreachable */ 38 0 : return NULL; 39 4194 : } 40 : 41 : FD_FN_CONST char const * 42 0 : fd_acc_mgr_strerror( int err ) { 43 0 : switch( err ) { 44 0 : case FD_ACC_MGR_SUCCESS: 45 0 : return "success"; 46 0 : case FD_ACC_MGR_ERR_UNKNOWN_ACCOUNT: 47 0 : return "unknown account"; 48 0 : default: 49 0 : return "unknown"; 50 0 : } 51 0 : }