|
14 | 14 |
|
15 | 15 | use {
|
16 | 16 | crate::*,
|
17 |
| - log::info, |
| 17 | + log::{debug, info, log_enabled}, |
18 | 18 | rdkafka::util::get_rdkafka_version,
|
19 | 19 | simple_error::simple_error,
|
20 | 20 | solana_geyser_plugin_interface::geyser_plugin_interface::{
|
21 | 21 | GeyserPlugin, GeyserPluginError as PluginError, ReplicaAccountInfo,
|
22 |
| - ReplicaAccountInfoVersions, ReplicaTransactionInfoVersions, Result as PluginResult, |
23 |
| - SlotStatus as PluginSlotStatus, |
| 22 | + ReplicaAccountInfoVersions, ReplicaTransactionInfo, ReplicaTransactionInfoVersions, |
| 23 | + Result as PluginResult, SlotStatus as PluginSlotStatus, |
24 | 24 | },
|
| 25 | + solana_program::pubkey::Pubkey, |
25 | 26 | std::fmt::{Debug, Formatter},
|
26 | 27 | };
|
27 | 28 |
|
@@ -90,7 +91,8 @@ impl GeyserPlugin for KafkaPlugin {
|
90 | 91 | }
|
91 | 92 |
|
92 | 93 | let info = Self::unwrap_update_account(account);
|
93 |
| - if !self.unwrap_filter().wants_program(info.owner) { |
| 94 | + if !self.unwrap_filter().wants_account_key(info.owner) { |
| 95 | + Self::log_ignore_account_update(info); |
94 | 96 | return Ok(());
|
95 | 97 | }
|
96 | 98 |
|
@@ -143,7 +145,23 @@ impl GeyserPlugin for KafkaPlugin {
|
143 | 145 | return Ok(());
|
144 | 146 | }
|
145 | 147 |
|
146 |
| - let event = Self::build_transaction_event(slot, transaction); |
| 148 | + let info = Self::unwrap_transaction(transaction); |
| 149 | + let maybe_ignored = info |
| 150 | + .transaction |
| 151 | + .message() |
| 152 | + .account_keys() |
| 153 | + .iter() |
| 154 | + .find(|key| !self.unwrap_filter().wants_account_key(&key.to_bytes())); |
| 155 | + if maybe_ignored.is_some() { |
| 156 | + debug!( |
| 157 | + "Ignoring transaction {:?} due to account key: {:?}", |
| 158 | + info.signature, |
| 159 | + &maybe_ignored.unwrap() |
| 160 | + ); |
| 161 | + return Ok(()); |
| 162 | + } |
| 163 | + |
| 164 | + let event = Self::build_transaction_event(slot, info); |
147 | 165 |
|
148 | 166 | publisher
|
149 | 167 | .update_transaction(event)
|
@@ -178,6 +196,12 @@ impl KafkaPlugin {
|
178 | 196 | }
|
179 | 197 | }
|
180 | 198 |
|
| 199 | + fn unwrap_transaction(transaction: ReplicaTransactionInfoVersions) -> &ReplicaTransactionInfo { |
| 200 | + match transaction { |
| 201 | + ReplicaTransactionInfoVersions::V0_0_1(info) => info, |
| 202 | + } |
| 203 | + } |
| 204 | + |
181 | 205 | fn build_compiled_instruction(
|
182 | 206 | ix: &solana_program::instruction::CompiledInstruction,
|
183 | 207 | ) -> CompiledInstruction {
|
@@ -216,9 +240,8 @@ impl KafkaPlugin {
|
216 | 240 |
|
217 | 241 | fn build_transaction_event(
|
218 | 242 | slot: u64,
|
219 |
| - transaction: ReplicaTransactionInfoVersions, |
| 243 | + transaction: &ReplicaTransactionInfo, |
220 | 244 | ) -> TransactionEvent {
|
221 |
| - let ReplicaTransactionInfoVersions::V0_0_1(transaction) = transaction; |
222 | 245 | let transaction_status_meta = transaction.transaction_status_meta;
|
223 | 246 | let signature = transaction.signature;
|
224 | 247 | let is_vote = transaction.is_vote;
|
@@ -380,4 +403,17 @@ impl KafkaPlugin {
|
380 | 403 | }),
|
381 | 404 | }
|
382 | 405 | }
|
| 406 | + |
| 407 | + fn log_ignore_account_update(info: &ReplicaAccountInfo) { |
| 408 | + if log_enabled!(::log::Level::Debug) { |
| 409 | + match <&[u8; 32]>::try_from(info.owner) { |
| 410 | + Ok(key) => debug!( |
| 411 | + "Ignoring update for account key: {:?}", |
| 412 | + Pubkey::new_from_array(*key) |
| 413 | + ), |
| 414 | + // Err should never happen because wants_account_key only returns false if the input is &[u8; 32] |
| 415 | + Err(_err) => debug!("Ignoring update for account key: {:?}", info.owner), |
| 416 | + }; |
| 417 | + } |
| 418 | + } |
383 | 419 | }
|
0 commit comments