Remove programs clone()
This commit is contained in:
@ -552,7 +552,7 @@ mod tests {
|
|||||||
&program_id,
|
&program_id,
|
||||||
Rent::default(),
|
Rent::default(),
|
||||||
vec![],
|
vec![],
|
||||||
vec![],
|
&[],
|
||||||
None,
|
None,
|
||||||
ComputeBudget {
|
ComputeBudget {
|
||||||
max_units: 1,
|
max_units: 1,
|
||||||
|
@ -200,11 +200,11 @@ impl ComputeMeter for ThisComputeMeter {
|
|||||||
self.remaining
|
self.remaining
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub struct ThisInvokeContext {
|
pub struct ThisInvokeContext<'a> {
|
||||||
program_ids: Vec<Pubkey>,
|
program_ids: Vec<Pubkey>,
|
||||||
rent: Rent,
|
rent: Rent,
|
||||||
pre_accounts: Vec<PreAccount>,
|
pre_accounts: Vec<PreAccount>,
|
||||||
programs: Vec<(Pubkey, ProcessInstructionWithContext)>,
|
programs: &'a [(Pubkey, ProcessInstructionWithContext)],
|
||||||
logger: Rc<RefCell<dyn Logger>>,
|
logger: Rc<RefCell<dyn Logger>>,
|
||||||
compute_budget: ComputeBudget,
|
compute_budget: ComputeBudget,
|
||||||
compute_meter: Rc<RefCell<dyn ComputeMeter>>,
|
compute_meter: Rc<RefCell<dyn ComputeMeter>>,
|
||||||
@ -212,12 +212,12 @@ pub struct ThisInvokeContext {
|
|||||||
instruction_recorder: Option<InstructionRecorder>,
|
instruction_recorder: Option<InstructionRecorder>,
|
||||||
feature_set: Arc<FeatureSet>,
|
feature_set: Arc<FeatureSet>,
|
||||||
}
|
}
|
||||||
impl ThisInvokeContext {
|
impl<'a> ThisInvokeContext<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
program_id: &Pubkey,
|
program_id: &Pubkey,
|
||||||
rent: Rent,
|
rent: Rent,
|
||||||
pre_accounts: Vec<PreAccount>,
|
pre_accounts: Vec<PreAccount>,
|
||||||
programs: Vec<(Pubkey, ProcessInstructionWithContext)>,
|
programs: &'a [(Pubkey, ProcessInstructionWithContext)],
|
||||||
log_collector: Option<Rc<LogCollector>>,
|
log_collector: Option<Rc<LogCollector>>,
|
||||||
compute_budget: ComputeBudget,
|
compute_budget: ComputeBudget,
|
||||||
executors: Rc<RefCell<Executors>>,
|
executors: Rc<RefCell<Executors>>,
|
||||||
@ -242,7 +242,7 @@ impl ThisInvokeContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl InvokeContext for ThisInvokeContext {
|
impl<'a> InvokeContext for ThisInvokeContext<'a> {
|
||||||
fn push(&mut self, key: &Pubkey) -> Result<(), InstructionError> {
|
fn push(&mut self, key: &Pubkey) -> Result<(), InstructionError> {
|
||||||
if self.program_ids.len() > self.compute_budget.max_invoke_depth {
|
if self.program_ids.len() > self.compute_budget.max_invoke_depth {
|
||||||
return Err(InstructionError::CallDepth);
|
return Err(InstructionError::CallDepth);
|
||||||
@ -281,7 +281,7 @@ impl InvokeContext for ThisInvokeContext {
|
|||||||
.ok_or(InstructionError::GenericError)
|
.ok_or(InstructionError::GenericError)
|
||||||
}
|
}
|
||||||
fn get_programs(&self) -> &[(Pubkey, ProcessInstructionWithContext)] {
|
fn get_programs(&self) -> &[(Pubkey, ProcessInstructionWithContext)] {
|
||||||
&self.programs
|
self.programs
|
||||||
}
|
}
|
||||||
fn get_logger(&self) -> Rc<RefCell<dyn Logger>> {
|
fn get_logger(&self) -> Rc<RefCell<dyn Logger>> {
|
||||||
self.logger.clone()
|
self.logger.clone()
|
||||||
@ -674,7 +674,7 @@ impl MessageProcessor {
|
|||||||
instruction.program_id(&message.account_keys),
|
instruction.program_id(&message.account_keys),
|
||||||
rent_collector.rent,
|
rent_collector.rent,
|
||||||
pre_accounts,
|
pre_accounts,
|
||||||
self.programs.clone(), // get rid of clone
|
&self.programs,
|
||||||
log_collector,
|
log_collector,
|
||||||
Self::get_compute_budget(&feature_set),
|
Self::get_compute_budget(&feature_set),
|
||||||
executors,
|
executors,
|
||||||
@ -767,7 +767,7 @@ mod tests {
|
|||||||
&program_ids[0],
|
&program_ids[0],
|
||||||
Rent::default(),
|
Rent::default(),
|
||||||
pre_accounts,
|
pre_accounts,
|
||||||
vec![],
|
&[],
|
||||||
None,
|
None,
|
||||||
ComputeBudget::default(),
|
ComputeBudget::default(),
|
||||||
Rc::new(RefCell::new(Executors::default())),
|
Rc::new(RefCell::new(Executors::default())),
|
||||||
@ -1598,7 +1598,7 @@ mod tests {
|
|||||||
&caller_program_id,
|
&caller_program_id,
|
||||||
Rent::default(),
|
Rent::default(),
|
||||||
vec![owned_preaccount, not_owned_preaccount],
|
vec![owned_preaccount, not_owned_preaccount],
|
||||||
vec![],
|
&[],
|
||||||
None,
|
None,
|
||||||
ComputeBudget::default(),
|
ComputeBudget::default(),
|
||||||
Rc::new(RefCell::new(Executors::default())),
|
Rc::new(RefCell::new(Executors::default())),
|
||||||
|
Reference in New Issue
Block a user