|
| 1 | +// use solana_geyser_plugin_interface::geyser_plugin_interface::{ReplicaBlockInfoV2, SlotStatus}; |
| 2 | +use { |
| 3 | + borsh::{BorshDeserialize, BorshSerialize}, |
| 4 | + solana_sdk::{hash::Hash, message::legacy::Message, pubkey::Pubkey, signature::Signature}, |
| 5 | + std::collections::HashMap, |
| 6 | +}; |
| 7 | +pub mod utils; |
| 8 | +pub type AccountHashAccumulator = HashMap<u64, AccountHashMap>; |
| 9 | +pub type TransactionSigAccumulator = HashMap<u64, u64>; |
| 10 | +pub type SlotHashProofAccumulator = HashMap<u64, (Hash, BankHashProof)>; |
| 11 | +pub type VoteAccumulator = HashMap<u64, VoteHashMap>; |
| 12 | +pub type VoteHashMap = HashMap<Signature, VoteInfo>; |
| 13 | +pub type AccountHashMap = HashMap<Pubkey, (u64, Hash, AccountInfo)>; |
| 14 | + |
| 15 | +#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)] |
| 16 | +pub struct Proof { |
| 17 | + pub path: Vec<usize>, // Position in the chunk (between 0 and 15) for each level. |
| 18 | + pub siblings: Vec<Vec<Hash>>, // Sibling hashes at each level. |
| 19 | +} |
| 20 | + |
| 21 | +#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)] |
| 22 | +pub struct BankHashComponents { |
| 23 | + parent_bankhash: Hash, |
| 24 | + accounts_delta_hash: Hash, |
| 25 | + num_sigs: u64, |
| 26 | + current_blockhash: Hash, |
| 27 | +} |
| 28 | + |
| 29 | +#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)] |
| 30 | +pub struct Data { |
| 31 | + pub pubkey: Pubkey, |
| 32 | + pub hash: Hash, |
| 33 | + pub account: AccountInfo, |
| 34 | +} |
| 35 | + |
| 36 | +#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)] |
| 37 | +pub struct AccountDeltaProof(pub Pubkey, pub (Data, Proof)); |
| 38 | + |
| 39 | +#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)] |
| 40 | +pub struct BankHashProof { |
| 41 | + pub proofs: Vec<AccountDeltaProof>, |
| 42 | + pub num_sigs: u64, |
| 43 | + pub account_delta_root: Hash, |
| 44 | + pub parent_bankhash: Hash, |
| 45 | + pub blockhash: Hash, |
| 46 | +} |
| 47 | + |
| 48 | +#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)] |
| 49 | +pub struct Update { |
| 50 | + pub slot: u64, |
| 51 | + pub root: Hash, |
| 52 | + pub proof: BankHashProof, |
| 53 | +} |
| 54 | + |
| 55 | +#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)] |
| 56 | +pub struct AccountInfo { |
| 57 | + /// The Pubkey for the account |
| 58 | + pub pubkey: Pubkey, |
| 59 | + |
| 60 | + /// The lamports for the account |
| 61 | + pub lamports: u64, |
| 62 | + |
| 63 | + /// The Pubkey of the owner program account |
| 64 | + pub owner: Pubkey, |
| 65 | + |
| 66 | + /// This account's data contains a loaded program (and is now read-only) |
| 67 | + pub executable: bool, |
| 68 | + |
| 69 | + /// The epoch at which this account will next owe rent |
| 70 | + pub rent_epoch: u64, |
| 71 | + |
| 72 | + /// The data held in this account. |
| 73 | + pub data: Vec<u8>, |
| 74 | + |
| 75 | + /// A global monotonically increasing atomic number, which can be used |
| 76 | + /// to tell the order of the account update. For example, when an |
| 77 | + /// account is updated in the same slot multiple times, the update |
| 78 | + /// with higher write_version should supersede the one with lower |
| 79 | + /// write_version. |
| 80 | + pub write_version: u64, |
| 81 | + |
| 82 | + /// Slot number for this update |
| 83 | + pub slot: u64, |
| 84 | +} |
| 85 | + |
| 86 | +impl Default for AccountInfo { |
| 87 | + fn default() -> Self { |
| 88 | + AccountInfo { |
| 89 | + pubkey: Pubkey::default(), |
| 90 | + lamports: 0, |
| 91 | + owner: Pubkey::default(), |
| 92 | + executable: false, |
| 93 | + rent_epoch: 0, |
| 94 | + data: Vec::new(), |
| 95 | + write_version: 0, |
| 96 | + slot: 0, |
| 97 | + } |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +#[derive(Debug, Clone)] |
| 102 | +pub struct TransactionInfo { |
| 103 | + pub slot: u64, |
| 104 | + pub num_sigs: u64, |
| 105 | +} |
| 106 | + |
| 107 | +#[derive(Debug, Clone)] |
| 108 | +pub struct VoteInfo { |
| 109 | + pub slot: u64, |
| 110 | + pub signature: Signature, |
| 111 | + pub vote_for_slot: u64, |
| 112 | + pub vote_for_hash: Hash, |
| 113 | + pub message: Message, |
| 114 | +} |
0 commit comments