solana_accounts_db/
accounts_update_notifier_interface.rs1use {
2 solana_account::{AccountSharedData, ReadableAccount},
3 solana_clock::{Epoch, Slot},
4 solana_pubkey::Pubkey,
5 solana_transaction::sanitized::SanitizedTransaction,
6 std::sync::Arc,
7};
8
9pub trait AccountsUpdateNotifierInterface: std::fmt::Debug {
10 fn snapshot_notifications_enabled(&self) -> bool;
12
13 fn notify_account_update(
15 &self,
16 slot: Slot,
17 account: &AccountSharedData,
18 txn: &Option<&SanitizedTransaction>,
19 pubkey: &Pubkey,
20 write_version: u64,
21 );
22
23 fn notify_account_restore_from_snapshot(
26 &self,
27 slot: Slot,
28 write_version: u64,
29 account: &AccountForGeyser<'_>,
30 );
31
32 fn notify_end_of_restore_from_snapshot(&self);
34}
35
36pub type AccountsUpdateNotifier = Arc<dyn AccountsUpdateNotifierInterface + Sync + Send>;
37
38#[derive(Debug, Clone)]
40pub struct AccountForGeyser<'a> {
41 pub pubkey: &'a Pubkey,
42 pub lamports: u64,
43 pub owner: &'a Pubkey,
44 pub executable: bool,
45 pub rent_epoch: Epoch,
46 pub data: &'a [u8],
47}
48
49impl ReadableAccount for AccountForGeyser<'_> {
50 fn lamports(&self) -> u64 {
51 self.lamports
52 }
53 fn data(&self) -> &[u8] {
54 self.data
55 }
56 fn owner(&self) -> &Pubkey {
57 self.owner
58 }
59 fn executable(&self) -> bool {
60 self.executable
61 }
62 fn rent_epoch(&self) -> Epoch {
63 self.rent_epoch
64 }
65}