@@ -3,10 +3,10 @@ use std::{env, sync::Arc};
33use anyhow:: Context ;
44use hashbrown:: HashSet ;
55use indexer_rabbitmq:: geyser:: { AccountUpdate , InstructionNotify , Message } ;
6- use solana_program:: { instruction:: CompiledInstruction , message:: AccountKeys , program_pack:: Pack } ;
7- use spl_token:: state:: Account as TokenAccount ;
6+ use solana_program:: { instruction:: CompiledInstruction , message:: AccountKeys } ;
87
9- static TOKEN_KEY : Pubkey = solana_program:: pubkey!( "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" ) ;
8+ pub ( crate ) static TOKEN_KEY : Pubkey =
9+ solana_program:: pubkey!( "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" ) ;
1010
1111use serde:: Deserialize ;
1212
@@ -41,7 +41,6 @@ pub(crate) struct Inner {
4141 acct_sel : AccountSelector ,
4242 ins_sel : InstructionSelector ,
4343 metrics : Arc < Metrics > ,
44- token_addresses : HashSet < Pubkey > ,
4544}
4645
4746impl Inner {
@@ -148,7 +147,7 @@ impl GeyserPlugin for GeyserPluginRabbitMq {
148147 . map_err ( custom_err ( & metrics. errs ) ) ?;
149148 }
150149
151- let ( amqp, jobs, metrics_conf, acct_sel, ins_sel) = Config :: read ( cfg)
150+ let ( amqp, jobs, metrics_conf, mut acct_sel, ins_sel) = Config :: read ( cfg)
152151 . and_then ( Config :: into_parts)
153152 . map_err ( custom_err ( & metrics. errs ) ) ?;
154153
@@ -172,7 +171,7 @@ impl GeyserPlugin for GeyserPluginRabbitMq {
172171 . build ( )
173172 . map_err ( custom_err ( & metrics. errs ) ) ?;
174173
175- let ( producer, token_addresses ) = rt. block_on ( async {
174+ let producer = rt. block_on ( async {
176175 let producer = Sender :: new (
177176 amqp,
178177 format ! ( "geyser-rabbitmq-{}@{}" , version, host) ,
@@ -182,11 +181,15 @@ impl GeyserPlugin for GeyserPluginRabbitMq {
182181 . await
183182 . map_err ( custom_err ( & metrics. errs ) ) ?;
184183
185- let tokens = Self :: load_token_reg ( )
186- . await
187- . map_err ( custom_err ( & metrics. errs ) ) ?;
184+ if acct_sel. screen_tokens ( ) {
185+ acct_sel. init_tokens (
186+ Self :: load_token_reg ( )
187+ . await
188+ . map_err ( custom_err ( & metrics. errs ) ) ?,
189+ ) ;
190+ }
188191
189- Result :: < _ > :: Ok ( ( producer, tokens ) )
192+ Result :: < _ > :: Ok ( producer)
190193 } ) ?;
191194
192195 self . 0 = Some ( Arc :: new ( Inner {
@@ -195,7 +198,6 @@ impl GeyserPlugin for GeyserPluginRabbitMq {
195198 acct_sel,
196199 ins_sel,
197200 metrics,
198- token_addresses,
199201 } ) ) ;
200202
201203 Ok ( ( ) )
@@ -228,20 +230,6 @@ impl GeyserPlugin for GeyserPluginRabbitMq {
228230 write_version,
229231 } = * acct;
230232
231- if owner == TOKEN_KEY . as_ref ( )
232- && data. len ( ) == TokenAccount :: get_packed_len ( )
233- {
234- let token_account = TokenAccount :: unpack_from_slice ( data) ;
235-
236- if let Ok ( token_account) = token_account {
237- if token_account. amount > 1
238- || this. token_addresses . contains ( & token_account. mint )
239- {
240- return Ok ( ( ) ) ;
241- }
242- }
243- }
244-
245233 let key = Pubkey :: new_from_array ( pubkey. try_into ( ) ?) ;
246234 let owner = Pubkey :: new_from_array ( owner. try_into ( ) ?) ;
247235 let data = data. to_owned ( ) ;
@@ -288,7 +276,7 @@ impl GeyserPlugin for GeyserPluginRabbitMq {
288276 . get ( ins. program_id_index as usize )
289277 . ok_or_else ( || anyhow ! ( "Couldn't get program ID for instruction" ) ) ?;
290278
291- if !sel. is_selected ( & program) {
279+ if !sel. is_selected ( & program, ins ) {
292280 return Ok ( None ) ;
293281 }
294282
0 commit comments