Skip to content

Commit

Permalink
make InstructionContext::new() private
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Aug 19, 2022
1 parent 59abda0 commit 7a1ef08
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
19 changes: 9 additions & 10 deletions programs/bpf_loader/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,21 +497,20 @@ mod tests {
&program_indices,
)
.instruction_accounts;
let instruction_data = vec![];

let transaction_context =
let mut transaction_context =
TransactionContext::new(transaction_accounts, Some(Rent::default()), 1, 1);
let instruction_data = vec![];
let instruction_context = InstructionContext::new(
0,
0,
&program_indices,
&instruction_accounts,
&instruction_data,
);
transaction_context
.push(&program_indices, &instruction_accounts, &instruction_data)
.unwrap();
let instruction_context = transaction_context
.get_instruction_context_at_index(0)
.unwrap();

let serialization_result = serialize_parameters(
&transaction_context,
&instruction_context,
instruction_context,
should_cap_ix_accounts,
);
assert_eq!(
Expand Down
22 changes: 11 additions & 11 deletions sdk/src/transaction_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ impl TransactionContext {
return Err(InstructionError::UnbalancedInstruction);
}
}
let instruction_context = InstructionContext {
nesting_level: self.instruction_stack.len(),
instruction_accounts_lamport_sum: callee_instruction_accounts_lamport_sum,
program_accounts: program_accounts.to_vec(),
instruction_accounts: instruction_accounts.to_vec(),
instruction_data: instruction_data.to_vec(),
};
let instruction_context = InstructionContext::new(
self.instruction_stack.len(),
callee_instruction_accounts_lamport_sum,
program_accounts.to_vec(),
instruction_accounts.to_vec(),
instruction_data.to_vec(),
);
let index_in_trace = self.instruction_trace.len();
self.instruction_trace.push(instruction_context);
if self.instruction_stack.len() >= self.instruction_context_capacity {
Expand Down Expand Up @@ -335,12 +335,12 @@ pub struct InstructionContext {

impl InstructionContext {
/// New
pub fn new(
fn new(
nesting_level: usize,
instruction_accounts_lamport_sum: u128,
program_accounts: &[usize],
instruction_accounts: &[InstructionAccount],
instruction_data: &[u8],
program_accounts: Vec<usize>,
instruction_accounts: Vec<InstructionAccount>,
instruction_data: Vec<u8>,
) -> Self {
InstructionContext {
nesting_level,
Expand Down

0 comments on commit 7a1ef08

Please sign in to comment.