@@ -110,50 +110,13 @@ impl ComputeBudgetInstructionDetailsBuilder {
110
110
111
111
impl ComputeBudgetInstructionDetails {
112
112
pub fn try_from < ' a > (
113
- instructions : impl Iterator < Item = ( & ' a Pubkey , SVMInstruction < ' a > ) > + Clone ,
113
+ instructions : impl Iterator < Item = ( & ' a Pubkey , SVMInstruction < ' a > ) > ,
114
114
) -> Result < Self > {
115
- let mut filter = ComputeBudgetProgramIdFilter :: new ( ) ;
116
- let mut compute_budget_instruction_details = ComputeBudgetInstructionDetails :: default ( ) ;
117
-
118
- for ( i, ( program_id, instruction) ) in instructions. clone ( ) . enumerate ( ) {
119
- if filter. is_compute_budget_program ( instruction. program_id_index as usize , program_id) {
120
- compute_budget_instruction_details. process_instruction ( i as u8 , & instruction) ?;
121
- } else {
122
- compute_budget_instruction_details. num_non_compute_budget_instructions += 1 ;
123
- }
124
- }
125
-
126
- if compute_budget_instruction_details
127
- . requested_compute_unit_limit
128
- . is_none ( )
129
- {
130
- let mut filter = BuiltinProgramsFilter :: new ( ) ;
131
- // reiterate to collect builtin details
132
- for ( program_id, instruction) in instructions {
133
- match filter. get_program_kind ( instruction. program_id_index as usize , program_id) {
134
- ProgramKind :: Builtin => {
135
- compute_budget_instruction_details
136
- . num_non_migratable_builtin_instructions += 1 ;
137
- }
138
- ProgramKind :: NotBuiltin => {
139
- compute_budget_instruction_details. num_non_builtin_instructions += 1 ;
140
- }
141
- ProgramKind :: MigratingBuiltin {
142
- core_bpf_migration_feature_index,
143
- } => {
144
- * compute_budget_instruction_details
145
- . migrating_builtin_feature_counters
146
- . migrating_builtin
147
- . get_mut ( core_bpf_migration_feature_index)
148
- . expect (
149
- "migrating feature index within range of MIGRATION_FEATURE_IDS" ,
150
- ) += 1 ;
151
- }
152
- }
153
- }
115
+ let mut builder = ComputeBudgetInstructionDetailsBuilder :: default ( ) ;
116
+ for ( program_id, instruction) in instructions {
117
+ builder. process_instruction ( program_id, & instruction) ?;
154
118
}
155
-
156
- Ok ( compute_budget_instruction_details)
119
+ Ok ( builder. build ( ) )
157
120
}
158
121
159
122
pub fn sanitize_and_convert_to_compute_budget_limits (
0 commit comments