Remove MessageProcessor::loaders
This commit is contained in:
parent
df8dab9d2b
commit
2664a1f7ef
|
@ -21,7 +21,6 @@ use solana_sdk::{
|
|||
bpf_loader, bpf_loader_deprecated,
|
||||
decode_error::DecodeError,
|
||||
entrypoint::SUCCESS,
|
||||
feature_set::compute_budget_balancing,
|
||||
feature_set::{bpf_just_in_time_compilation, compute_budget_balancing},
|
||||
instruction::InstructionError,
|
||||
keyed_account::{is_executable, next_keyed_account, KeyedAccount},
|
||||
|
|
|
@ -1296,8 +1296,6 @@ fn call<'a>(
|
|||
for (program_id, process_instruction) in invoke_context.get_programs().iter() {
|
||||
message_processor.add_program(*program_id, *process_instruction);
|
||||
}
|
||||
message_processor.add_loader(bpf_loader::id(), crate::process_instruction);
|
||||
message_processor.add_loader(bpf_loader_deprecated::id(), crate::process_instruction);
|
||||
|
||||
#[allow(clippy::deref_addrof)]
|
||||
match message_processor.process_cross_program_instruction(
|
||||
|
|
|
@ -328,8 +328,6 @@ pub struct MessageProcessor {
|
|||
#[serde(skip)]
|
||||
programs: Vec<(Pubkey, ProcessInstructionWithContext)>,
|
||||
#[serde(skip)]
|
||||
loaders: Vec<(Pubkey, ProcessInstructionWithContext)>,
|
||||
#[serde(skip)]
|
||||
native_loader: NativeLoader,
|
||||
}
|
||||
|
||||
|
@ -338,7 +336,6 @@ impl std::fmt::Debug for MessageProcessor {
|
|||
#[derive(Debug)]
|
||||
struct MessageProcessor<'a> {
|
||||
programs: Vec<String>,
|
||||
loaders: Vec<String>,
|
||||
native_loader: &'a NativeLoader,
|
||||
}
|
||||
// rustc doesn't compile due to bug without this work around
|
||||
|
@ -353,14 +350,6 @@ impl std::fmt::Debug for MessageProcessor {
|
|||
format!("{}: {:p}", pubkey, erased_instruction)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
loaders: self
|
||||
.loaders
|
||||
.iter()
|
||||
.map(|(pubkey, instruction)| {
|
||||
let erased_instruction: ErasedProcessInstructionWithContext = *instruction;
|
||||
format!("{}: {:p}", pubkey, erased_instruction)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
native_loader: &self.native_loader,
|
||||
};
|
||||
|
||||
|
@ -372,7 +361,6 @@ impl Default for MessageProcessor {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
programs: vec![],
|
||||
loaders: vec![],
|
||||
native_loader: NativeLoader::default(),
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +369,6 @@ impl Clone for MessageProcessor {
|
|||
fn clone(&self) -> Self {
|
||||
MessageProcessor {
|
||||
programs: self.programs.clone(),
|
||||
loaders: self.loaders.clone(),
|
||||
native_loader: NativeLoader::default(),
|
||||
}
|
||||
}
|
||||
|
@ -414,10 +401,7 @@ impl MessageProcessor {
|
|||
program_id: Pubkey,
|
||||
process_instruction: ProcessInstructionWithContext,
|
||||
) {
|
||||
match self.loaders.iter_mut().find(|(key, _)| program_id == *key) {
|
||||
Some((_, processor)) => *processor = process_instruction,
|
||||
None => self.loaders.push((program_id, process_instruction)),
|
||||
}
|
||||
self.add_program(program_id, process_instruction);
|
||||
}
|
||||
|
||||
fn get_compute_budget(feature_set: &FeatureSet) -> ComputeBudget {
|
||||
|
@ -462,17 +446,6 @@ impl MessageProcessor {
|
|||
if let Some(root_account) = keyed_accounts.iter().next() {
|
||||
if native_loader::check_id(&root_account.owner()?) {
|
||||
let root_id = root_account.unsigned_key();
|
||||
for (id, process_instruction) in &self.loaders {
|
||||
if id == root_id {
|
||||
// Call the program via a builtin loader
|
||||
return process_instruction(
|
||||
&root_id,
|
||||
&keyed_accounts[1..],
|
||||
instruction_data,
|
||||
invoke_context,
|
||||
);
|
||||
}
|
||||
}
|
||||
for (id, process_instruction) in &self.programs {
|
||||
if id == root_id {
|
||||
// Call the builtin program
|
||||
|
@ -493,7 +466,7 @@ impl MessageProcessor {
|
|||
);
|
||||
} else {
|
||||
let owner_id = &root_account.owner()?;
|
||||
for (id, process_instruction) in &self.loaders {
|
||||
for (id, process_instruction) in &self.programs {
|
||||
if id == owner_id {
|
||||
// Call the program via a builtin loader
|
||||
return process_instruction(
|
||||
|
|
Loading…
Reference in New Issue