Skip to content

Commit e07bca5

Browse files
committed
lookup address to keys
1 parent 76d6352 commit e07bca5

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

crates/plugin/src/selectors.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use hashbrown::HashMap;
22
use itertools::Itertools;
3+
use solana_sdk::message::AccountKeys;
34
use solana_transaction::versioned::VersionedTransaction;
45
use solana_transaction_status::TransactionStatusMeta;
56

@@ -82,9 +83,12 @@ impl TransactionSelector {
8283
}
8384
let instructions = &tx.message.instructions();
8485

85-
let keys = &tx.message.static_account_keys();
86+
let account_keys = AccountKeys::new(
87+
tx.message.static_account_keys(),
88+
Some(&meta.loaded_addresses),
89+
);
8690

87-
let pubkey_routes = keys
91+
let pubkey_routes = account_keys
8892
.iter()
8993
.filter_map(|a| self.pubkeys.get(a))
9094
.unique()
@@ -104,7 +108,7 @@ impl TransactionSelector {
104108
)
105109
.map(|a| a.program_id_index)
106110
.unique()
107-
.filter_map(|a| Some(keys[a as usize]))
111+
.filter_map(|a| Some(account_keys[a as usize]))
108112
.filter_map(|a| self.programs.get(&a))
109113
.chain(self.allows_all_programs.iter())
110114
.unique()

crates/plugin/src/stats.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::time::Duration;
55
use crate::prelude::*;
66
use indexer_rabbitmq::geyser::{Message, SlotStatistics};
77
use solana_sdk::message::compiled_instruction::CompiledInstruction;
8+
use solana_sdk::message::AccountKeys;
89
use solana_transaction::versioned::VersionedTransaction;
910
use solana_transaction_status::TransactionStatusMeta;
1011

@@ -254,7 +255,7 @@ fn process_slot(
254255
}
255256

256257
let msg = &vtx.message;
257-
let keys = msg.static_account_keys();
258+
let account_keys = AccountKeys::new(msg.static_account_keys(), Some(&meta.loaded_addresses));
258259

259260
let inner_ixs: Vec<(&Pubkey, &CompiledInstruction)> = meta
260261
.inner_instructions
@@ -263,7 +264,7 @@ fn process_slot(
263264
ixss.iter().flat_map(|ixs| {
264265
ixs.instructions.iter().map(|ix| {
265266
(
266-
&keys[ix.instruction.program_id_index as usize],
267+
&account_keys[ix.instruction.program_id_index as usize],
267268
&ix.instruction,
268269
)
269270
})
@@ -274,7 +275,7 @@ fn process_slot(
274275
let top_level_ixs = msg
275276
.instructions()
276277
.iter()
277-
.map(|ix| (&keys[ix.program_id_index as usize], ix));
278+
.map(|ix| (&account_keys[ix.program_id_index as usize], ix));
278279

279280
let all_ixs = top_level_ixs.chain(inner_ixs);
280281
for (pgm_ref, ix_ref) in all_ixs {
@@ -306,7 +307,7 @@ fn process_slot(
306307
//initialize account
307308
1 | 16 | 18 => {
308309
if ix_ref.accounts.len() > 1 {
309-
let mint = keys[ix_ref.accounts[1] as usize].to_string();
310+
let mint = account_keys[ix_ref.accounts[1] as usize].to_string();
310311
let val = stats.new_token_accounts.entry(mint).or_default();
311312
*val += 1;
312313
}
@@ -317,5 +318,5 @@ fn process_slot(
317318
}
318319
}
319320

320-
stats.payers.insert(keys[0].to_string());
321+
stats.payers.insert(account_keys[0].to_string());
321322
}

0 commit comments

Comments
 (0)