@@ -81,6 +81,17 @@ fd_exec_instr_ctx_delete( void * mem ) {
81
81
return mem ;
82
82
}
83
83
84
+ int
85
+ fd_exec_instr_ctx_find_idx_of_instr_account ( fd_exec_instr_ctx_t const * ctx ,
86
+ fd_pubkey_t const * pubkey ) {
87
+ for ( int i = 0 ; i < ctx -> instr -> acct_cnt ; i ++ ) {
88
+ if ( memcmp ( pubkey -> uc , ctx -> instr -> acct_pubkeys [i ].uc , sizeof (fd_pubkey_t ) )== 0 ) {
89
+ return i ;
90
+ }
91
+ }
92
+ return -1 ;
93
+ }
94
+
84
95
int
85
96
fd_exec_instr_ctx_try_borrow_account ( fd_exec_instr_ctx_t const * ctx ,
86
97
ulong idx ,
@@ -105,8 +116,8 @@ fd_exec_instr_ctx_try_borrow_account( fd_exec_instr_ctx_t const * ctx,
105
116
106
117
int
107
118
fd_exec_instr_ctx_try_borrow_instr_account ( fd_exec_instr_ctx_t const * ctx ,
108
- ulong idx ,
109
- fd_borrowed_account_t * account ) {
119
+ ulong idx ,
120
+ fd_borrowed_account_t * account ) {
110
121
/* Return a NotEnoughAccountKeys error if the idx is out of bounds.
111
122
https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L603 */
112
123
if ( FD_UNLIKELY ( idx >= ctx -> instr -> acct_cnt ) ) {
@@ -115,30 +126,26 @@ fd_exec_instr_ctx_try_borrow_instr_account( fd_exec_instr_ctx_t const * ctx,
115
126
116
127
fd_txn_account_t * instr_account = ctx -> instr -> accounts [idx ];
117
128
118
- return fd_exec_instr_ctx_try_borrow_account ( ctx , idx , instr_account , account );
129
+ return fd_exec_instr_ctx_try_borrow_account ( ctx ,
130
+ idx ,
131
+ instr_account ,
132
+ account );
119
133
}
120
134
121
135
int
122
136
fd_exec_instr_ctx_try_borrow_instr_account_with_key ( fd_exec_instr_ctx_t * ctx ,
123
- fd_pubkey_t const * pubkey ,
124
- fd_borrowed_account_t * account ) {
137
+ fd_pubkey_t const * pubkey ,
138
+ fd_borrowed_account_t * account ) {
125
139
for ( ulong i = 0 ; i < ctx -> instr -> acct_cnt ; i ++ ) {
126
140
if ( memcmp ( pubkey -> uc , ctx -> instr -> acct_pubkeys [i ].uc , sizeof (fd_pubkey_t ) )== 0 ) {
127
141
return fd_exec_instr_ctx_try_borrow_instr_account ( ctx , i , account );
128
142
}
129
143
}
130
- return FD_EXECUTOR_INSTR_ERR_MISSING_ACC ;
131
- }
132
144
133
- int
134
- fd_exec_instr_ctx_find_idx_of_instr_account ( fd_exec_instr_ctx_t const * ctx ,
135
- fd_pubkey_t const * pubkey ) {
136
- for ( int i = 0 ; i < ctx -> instr -> acct_cnt ; i ++ ) {
137
- if ( memcmp ( pubkey -> uc , ctx -> instr -> acct_pubkeys [i ].uc , sizeof (fd_pubkey_t ) )== 0 ) {
138
- return i ;
139
- }
140
- }
141
- return -1 ;
145
+ /* Return a NotEnoughAccountKeys error if the account is not found
146
+ in the instruction context to match the error code returned by
147
+ fd_exec_instr_ctx_try_borrow_instr_account. */
148
+ return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS ;
142
149
}
143
150
144
151
int
@@ -147,7 +154,7 @@ fd_exec_instr_ctx_try_borrow_last_program_account( fd_exec_instr_ctx_t const * c
147
154
fd_txn_account_t * program_account = NULL ;
148
155
fd_exec_txn_ctx_get_account_at_index ( ctx -> txn_ctx ,
149
156
ctx -> instr -> program_id ,
150
- & program_account ,
157
+ & program_account ,
151
158
NULL );
152
159
153
160
return fd_exec_instr_ctx_try_borrow_account ( ctx ,
0 commit comments