Add program_ids() methods

Added CompiledInstruction::program_id() so that we don't need to pass
around instruction indexes just for Message::program_id().

Also added Message.program_ids() that returns a slice so that we
can move those pubkeys into Message::account_keys.
This commit is contained in:
Greg Fitzgerald
2019-04-02 16:02:57 -06:00
parent 025b4f90de
commit 4c0bc1fd88
6 changed files with 31 additions and 25 deletions

View File

@@ -83,7 +83,7 @@ pub struct Message {
/// All the program id keys used to execute this transaction's instructions
#[serde(with = "short_vec")]
pub program_ids: Vec<Pubkey>,
program_ids: Vec<Pubkey>,
/// Programs that will be executed in sequence and committed in one atomic transaction if all
/// succeed.
@@ -123,9 +123,8 @@ impl Message {
)
}
pub fn program_id(&self, instruction_index: usize) -> &Pubkey {
let program_ids_index = self.instructions[instruction_index].program_ids_index;
&self.program_ids[program_ids_index as usize]
pub fn program_ids(&self) -> &[Pubkey] {
&self.program_ids
}
}