From 35b5328a166807e495512bea8b8c6755e7ec701e Mon Sep 17 00:00:00 2001 From: austbot Date: Fri, 30 Sep 2022 16:29:30 -0500 Subject: [PATCH] add seet att to all types --- Cargo.lock | 6 +- docker/runs.sh | 2 +- plerkle/Cargo.toml | 6 +- plerkle/src/geyser_plugin_nft.rs | 19 +- plerkle_messenger/Cargo.toml | 2 +- plerkle_serialization/Cargo.toml | 2 +- plerkle_serialization/account_info.fbs | 1 + plerkle_serialization/block_info.fbs | 1 + plerkle_serialization/slot_status_info.fbs | 1 + .../src/account_info_generated.rs | 433 +++++------ .../src/block_info_generated.rs | 718 ++++++++---------- plerkle_serialization/src/common_generated.rs | 85 ++- .../src/compiled_instruction_generated.rs | 282 +++---- .../src/serializer/serializer_stable.rs | 6 + .../src/slot_status_info_generated.rs | 376 +++++---- .../src/transaction_info_generated.rs | 656 +++++++--------- 16 files changed, 1170 insertions(+), 1426 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ea5e133..26e0d331 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2169,7 +2169,7 @@ checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "plerkle" -version = "0.4.4" +version = "0.4.6" dependencies = [ "async-trait", "base64 0.13.0", @@ -2200,7 +2200,7 @@ dependencies = [ [[package]] name = "plerkle_messenger" -version = "0.4.4" +version = "0.4.6" dependencies = [ "async-mutex", "async-trait", @@ -2216,7 +2216,7 @@ dependencies = [ [[package]] name = "plerkle_serialization" -version = "0.4.4" +version = "0.4.6" dependencies = [ "chrono", "flatbuffers", diff --git a/docker/runs.sh b/docker/runs.sh index a154fc1d..42f785a9 100755 --- a/docker/runs.sh +++ b/docker/runs.sh @@ -21,7 +21,7 @@ cat << EOL > /plugin-config/accountsdb-plugin-config.json { "libpath": "/plugin/plugin.so", "accounts_selector" : { - "accounts" : [ + "owners" : [ "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", "GRoLLMza82AiYN7W9S9KCCtCyyPRAQP2ifBy4v4D5RMD", "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", diff --git a/plerkle/Cargo.toml b/plerkle/Cargo.toml index 1a4dd3c5..ab6ee308 100644 --- a/plerkle/Cargo.toml +++ b/plerkle/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "plerkle" description = "Geyser plugin with dynamic config reloading, message bus agnostic abstractions and a whole lot of fun." -version = "0.4.5" +version = "0.4.6" authors = ["Metaplex Developers "] repository = "https://github.com/metaplex-foundation/digital-asset-validator-plugin" license = "AGPL-3.0" @@ -33,9 +33,9 @@ cadence-macros = "0.29.0" chrono = "0.4.19" tracing = "0.1.35" hex = "0.4.3" -plerkle_messenger = { path = "../plerkle_messenger", version = "0.4.5", features = ["redis"] } +plerkle_messenger = { path = "../plerkle_messenger", version = "0.4.6", features = ["redis"] } flatbuffers = "2.1.2" -plerkle_serialization = { path = "../plerkle_serialization", version = "0.4.5" } +plerkle_serialization = { path = "../plerkle_serialization", version = "0.4.6" } tokio = { version = "1.17.0", features = ["full"] } figment = { version = "0.10.6", features = ["env", "test"] } diff --git a/plerkle/src/geyser_plugin_nft.rs b/plerkle/src/geyser_plugin_nft.rs index a95c9ca7..0d432047 100644 --- a/plerkle/src/geyser_plugin_nft.rs +++ b/plerkle/src/geyser_plugin_nft.rs @@ -252,23 +252,7 @@ impl GeyserPlugin for Plerkle<'static> { slot: u64, is_startup: bool, ) -> solana_geyser_plugin_interface::geyser_plugin_interface::Result<()> { - let acct: ReplicaAccountInfo; - let account = match account { - // ReplicaAccountInfoVersions::V0_0_2(a) => a, removed because dependency hell - ReplicaAccountInfoVersions::V0_0_1(a) => { - acct = ReplicaAccountInfo { - pubkey: a.pubkey, - lamports: a.lamports, - owner: a.owner, - executable: a.executable, - rent_epoch: a.rent_epoch, - data: a.data, - write_version: a.write_version, - }; - &acct - } - }; - + let ReplicaAccountInfoVersions::V0_0_1(account) = account; if let Some(accounts_selector) = &self.accounts_selector { if !accounts_selector.is_account_selected(account.pubkey, account.owner) { return Ok(()); @@ -276,7 +260,6 @@ impl GeyserPlugin for Plerkle<'static> { } else { return Ok(()); } - // Get runtime and sender channel. let runtime = self.get_runtime()?; let sender = self.get_sender_clone()?; diff --git a/plerkle_messenger/Cargo.toml b/plerkle_messenger/Cargo.toml index 4f3ec355..8b02248c 100644 --- a/plerkle_messenger/Cargo.toml +++ b/plerkle_messenger/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "plerkle_messenger" description = "Metaplex Messenger trait for Geyser plugin producer/consumer patterns." -version = "0.4.5" +version = "0.4.6" authors = ["Metaplex Developers "] repository = "https://github.com/metaplex-foundation/digital-asset-validator-plugin" license = "AGPL-3.0" diff --git a/plerkle_serialization/Cargo.toml b/plerkle_serialization/Cargo.toml index ab240d1c..4b18476f 100644 --- a/plerkle_serialization/Cargo.toml +++ b/plerkle_serialization/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "plerkle_serialization" description = "Metaplex Flatbuffers Plerkle Serialization for Geyser plugin producer/consumer patterns." -version = "0.4.5" +version = "0.4.6" authors = ["Metaplex Developers "] repository = "https://github.com/metaplex-foundation/digital-asset-validator-plugin" license = "AGPL-3.0" diff --git a/plerkle_serialization/account_info.fbs b/plerkle_serialization/account_info.fbs index 32c463e4..67dbc261 100644 --- a/plerkle_serialization/account_info.fbs +++ b/plerkle_serialization/account_info.fbs @@ -11,6 +11,7 @@ table AccountInfo { write_version:uint64; slot:uint64; is_startup:bool; + seen_at: int64; } root_type AccountInfo; diff --git a/plerkle_serialization/block_info.fbs b/plerkle_serialization/block_info.fbs index cc7bbf0a..ca6b379f 100644 --- a/plerkle_serialization/block_info.fbs +++ b/plerkle_serialization/block_info.fbs @@ -25,6 +25,7 @@ table BlockInfo { rewards:[Reward]; block_time:int64 = null; block_height:uint64 = null; + seen_at: int64; } root_type BlockInfo; diff --git a/plerkle_serialization/slot_status_info.fbs b/plerkle_serialization/slot_status_info.fbs index 278cf070..923bcf0b 100644 --- a/plerkle_serialization/slot_status_info.fbs +++ b/plerkle_serialization/slot_status_info.fbs @@ -8,6 +8,7 @@ table SlotStatusInfo { slot:uint64; parent:uint64 = null; status:Status; + seen_at: int64; } root_type SlotStatusInfo; diff --git a/plerkle_serialization/src/account_info_generated.rs b/plerkle_serialization/src/account_info_generated.rs index 718dc2d5..346dc09b 100644 --- a/plerkle_serialization/src/account_info_generated.rs +++ b/plerkle_serialization/src/account_info_generated.rs @@ -1,146 +1,128 @@ // automatically generated by the FlatBuffers compiler, do not modify + // @generated use crate::common_generated::*; - +use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; - +use self::flatbuffers::{EndianScalar, Follow}; pub enum AccountInfoOffset {} #[derive(Copy, Clone, PartialEq)] pub struct AccountInfo<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for AccountInfo<'a> { - type Inner = AccountInfo<'a>; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table { buf, loc }, - } - } + type Inner = AccountInfo<'a>; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table { buf, loc } } + } } impl<'a> AccountInfo<'a> { - pub const VT_PUBKEY: flatbuffers::VOffsetT = 4; - pub const VT_LAMPORTS: flatbuffers::VOffsetT = 6; - pub const VT_OWNER: flatbuffers::VOffsetT = 8; - pub const VT_EXECUTABLE: flatbuffers::VOffsetT = 10; - pub const VT_RENT_EPOCH: flatbuffers::VOffsetT = 12; - pub const VT_DATA: flatbuffers::VOffsetT = 14; - pub const VT_WRITE_VERSION: flatbuffers::VOffsetT = 16; - pub const VT_SLOT: flatbuffers::VOffsetT = 18; - pub const VT_IS_STARTUP: flatbuffers::VOffsetT = 20; + pub const VT_PUBKEY: flatbuffers::VOffsetT = 4; + pub const VT_LAMPORTS: flatbuffers::VOffsetT = 6; + pub const VT_OWNER: flatbuffers::VOffsetT = 8; + pub const VT_EXECUTABLE: flatbuffers::VOffsetT = 10; + pub const VT_RENT_EPOCH: flatbuffers::VOffsetT = 12; + pub const VT_DATA: flatbuffers::VOffsetT = 14; + pub const VT_WRITE_VERSION: flatbuffers::VOffsetT = 16; + pub const VT_SLOT: flatbuffers::VOffsetT = 18; + pub const VT_IS_STARTUP: flatbuffers::VOffsetT = 20; + pub const VT_SEEN_AT: flatbuffers::VOffsetT = 22; - #[inline] - pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - AccountInfo { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args AccountInfoArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = AccountInfoBuilder::new(_fbb); - builder.add_slot(args.slot); - builder.add_write_version(args.write_version); - builder.add_rent_epoch(args.rent_epoch); - builder.add_lamports(args.lamports); - if let Some(x) = args.data { - builder.add_data(x); - } - if let Some(x) = args.owner { - builder.add_owner(x); - } - if let Some(x) = args.pubkey { - builder.add_pubkey(x); - } - builder.add_is_startup(args.is_startup); - builder.add_executable(args.executable); - builder.finish() - } + #[inline] + pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + AccountInfo { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args AccountInfoArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = AccountInfoBuilder::new(_fbb); + builder.add_seen_at(args.seen_at); + builder.add_slot(args.slot); + builder.add_write_version(args.write_version); + builder.add_rent_epoch(args.rent_epoch); + builder.add_lamports(args.lamports); + if let Some(x) = args.data { builder.add_data(x); } + if let Some(x) = args.owner { builder.add_owner(x); } + if let Some(x) = args.pubkey { builder.add_pubkey(x); } + builder.add_is_startup(args.is_startup); + builder.add_executable(args.executable); + builder.finish() + } - #[inline] - pub fn pubkey(&self) -> Option<&'a Pubkey> { - self._tab.get::(AccountInfo::VT_PUBKEY, None) - } - #[inline] - pub fn lamports(&self) -> u64 { - self._tab - .get::(AccountInfo::VT_LAMPORTS, Some(0)) - .unwrap() - } - #[inline] - pub fn owner(&self) -> Option<&'a Pubkey> { - self._tab.get::(AccountInfo::VT_OWNER, None) - } - #[inline] - pub fn executable(&self) -> bool { - self._tab - .get::(AccountInfo::VT_EXECUTABLE, Some(false)) - .unwrap() - } - #[inline] - pub fn rent_epoch(&self) -> u64 { - self._tab - .get::(AccountInfo::VT_RENT_EPOCH, Some(0)) - .unwrap() - } - #[inline] - pub fn data(&self) -> Option<&'a [u8]> { - self._tab - .get::>>( - AccountInfo::VT_DATA, - None, - ) - .map(|v| v.safe_slice()) - } - #[inline] - pub fn write_version(&self) -> u64 { - self._tab - .get::(AccountInfo::VT_WRITE_VERSION, Some(0)) - .unwrap() - } - #[inline] - pub fn slot(&self) -> u64 { - self._tab.get::(AccountInfo::VT_SLOT, Some(0)).unwrap() - } - #[inline] - pub fn is_startup(&self) -> bool { - self._tab - .get::(AccountInfo::VT_IS_STARTUP, Some(false)) - .unwrap() - } + + #[inline] + pub fn pubkey(&self) -> Option<&'a Pubkey> { + self._tab.get::(AccountInfo::VT_PUBKEY, None) + } + #[inline] + pub fn lamports(&self) -> u64 { + self._tab.get::(AccountInfo::VT_LAMPORTS, Some(0)).unwrap() + } + #[inline] + pub fn owner(&self) -> Option<&'a Pubkey> { + self._tab.get::(AccountInfo::VT_OWNER, None) + } + #[inline] + pub fn executable(&self) -> bool { + self._tab.get::(AccountInfo::VT_EXECUTABLE, Some(false)).unwrap() + } + #[inline] + pub fn rent_epoch(&self) -> u64 { + self._tab.get::(AccountInfo::VT_RENT_EPOCH, Some(0)).unwrap() + } + #[inline] + pub fn data(&self) -> Option<&'a [u8]> { + self._tab.get::>>(AccountInfo::VT_DATA, None).map(|v| v.safe_slice()) + } + #[inline] + pub fn write_version(&self) -> u64 { + self._tab.get::(AccountInfo::VT_WRITE_VERSION, Some(0)).unwrap() + } + #[inline] + pub fn slot(&self) -> u64 { + self._tab.get::(AccountInfo::VT_SLOT, Some(0)).unwrap() + } + #[inline] + pub fn is_startup(&self) -> bool { + self._tab.get::(AccountInfo::VT_IS_STARTUP, Some(false)).unwrap() + } + #[inline] + pub fn seen_at(&self) -> i64 { + self._tab.get::(AccountInfo::VT_SEEN_AT, Some(0)).unwrap() + } } impl flatbuffers::Verifiable for AccountInfo<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - - v.visit_table(pos)? - .visit_field::("pubkey", Self::VT_PUBKEY, false)? - .visit_field::("lamports", Self::VT_LAMPORTS, false)? - .visit_field::("owner", Self::VT_OWNER, false)? - .visit_field::("executable", Self::VT_EXECUTABLE, false)? - .visit_field::("rent_epoch", Self::VT_RENT_EPOCH, false)? - .visit_field::>>( - "data", - Self::VT_DATA, - false, - )? - .visit_field::("write_version", Self::VT_WRITE_VERSION, false)? - .visit_field::("slot", Self::VT_SLOT, false)? - .visit_field::("is_startup", Self::VT_IS_STARTUP, false)? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("pubkey", Self::VT_PUBKEY, false)? + .visit_field::("lamports", Self::VT_LAMPORTS, false)? + .visit_field::("owner", Self::VT_OWNER, false)? + .visit_field::("executable", Self::VT_EXECUTABLE, false)? + .visit_field::("rent_epoch", Self::VT_RENT_EPOCH, false)? + .visit_field::>>("data", Self::VT_DATA, false)? + .visit_field::("write_version", Self::VT_WRITE_VERSION, false)? + .visit_field::("slot", Self::VT_SLOT, false)? + .visit_field::("is_startup", Self::VT_IS_STARTUP, false)? + .visit_field::("seen_at", Self::VT_SEEN_AT, false)? + .finish(); + Ok(()) + } } pub struct AccountInfoArgs<'a> { pub pubkey: Option<&'a Pubkey>, @@ -152,113 +134,112 @@ pub struct AccountInfoArgs<'a> { pub write_version: u64, pub slot: u64, pub is_startup: bool, + pub seen_at: i64, } impl<'a> Default for AccountInfoArgs<'a> { - #[inline] - fn default() -> Self { - AccountInfoArgs { - pubkey: None, - lamports: 0, - owner: None, - executable: false, - rent_epoch: 0, - data: None, - write_version: 0, - slot: 0, - is_startup: false, - } + #[inline] + fn default() -> Self { + AccountInfoArgs { + pubkey: None, + lamports: 0, + owner: None, + executable: false, + rent_epoch: 0, + data: None, + write_version: 0, + slot: 0, + is_startup: false, + seen_at: 0, } + } } pub struct AccountInfoBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, } impl<'a: 'b, 'b> AccountInfoBuilder<'a, 'b> { - #[inline] - pub fn add_pubkey(&mut self, pubkey: &Pubkey) { - self.fbb_ - .push_slot_always::<&Pubkey>(AccountInfo::VT_PUBKEY, pubkey); - } - #[inline] - pub fn add_lamports(&mut self, lamports: u64) { - self.fbb_ - .push_slot::(AccountInfo::VT_LAMPORTS, lamports, 0); - } - #[inline] - pub fn add_owner(&mut self, owner: &Pubkey) { - self.fbb_ - .push_slot_always::<&Pubkey>(AccountInfo::VT_OWNER, owner); - } - #[inline] - pub fn add_executable(&mut self, executable: bool) { - self.fbb_ - .push_slot::(AccountInfo::VT_EXECUTABLE, executable, false); - } - #[inline] - pub fn add_rent_epoch(&mut self, rent_epoch: u64) { - self.fbb_ - .push_slot::(AccountInfo::VT_RENT_EPOCH, rent_epoch, 0); - } - #[inline] - pub fn add_data(&mut self, data: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(AccountInfo::VT_DATA, data); - } - #[inline] - pub fn add_write_version(&mut self, write_version: u64) { - self.fbb_ - .push_slot::(AccountInfo::VT_WRITE_VERSION, write_version, 0); - } - #[inline] - pub fn add_slot(&mut self, slot: u64) { - self.fbb_.push_slot::(AccountInfo::VT_SLOT, slot, 0); - } - #[inline] - pub fn add_is_startup(&mut self, is_startup: bool) { - self.fbb_ - .push_slot::(AccountInfo::VT_IS_STARTUP, is_startup, false); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AccountInfoBuilder<'a, 'b> { - let start = _fbb.start_table(); - AccountInfoBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + #[inline] + pub fn add_pubkey(&mut self, pubkey: &Pubkey) { + self.fbb_.push_slot_always::<&Pubkey>(AccountInfo::VT_PUBKEY, pubkey); + } + #[inline] + pub fn add_lamports(&mut self, lamports: u64) { + self.fbb_.push_slot::(AccountInfo::VT_LAMPORTS, lamports, 0); + } + #[inline] + pub fn add_owner(&mut self, owner: &Pubkey) { + self.fbb_.push_slot_always::<&Pubkey>(AccountInfo::VT_OWNER, owner); + } + #[inline] + pub fn add_executable(&mut self, executable: bool) { + self.fbb_.push_slot::(AccountInfo::VT_EXECUTABLE, executable, false); + } + #[inline] + pub fn add_rent_epoch(&mut self, rent_epoch: u64) { + self.fbb_.push_slot::(AccountInfo::VT_RENT_EPOCH, rent_epoch, 0); + } + #[inline] + pub fn add_data(&mut self, data: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(AccountInfo::VT_DATA, data); + } + #[inline] + pub fn add_write_version(&mut self, write_version: u64) { + self.fbb_.push_slot::(AccountInfo::VT_WRITE_VERSION, write_version, 0); + } + #[inline] + pub fn add_slot(&mut self, slot: u64) { + self.fbb_.push_slot::(AccountInfo::VT_SLOT, slot, 0); + } + #[inline] + pub fn add_is_startup(&mut self, is_startup: bool) { + self.fbb_.push_slot::(AccountInfo::VT_IS_STARTUP, is_startup, false); + } + #[inline] + pub fn add_seen_at(&mut self, seen_at: i64) { + self.fbb_.push_slot::(AccountInfo::VT_SEEN_AT, seen_at, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AccountInfoBuilder<'a, 'b> { + let start = _fbb.start_table(); + AccountInfoBuilder { + fbb_: _fbb, + start_: start, } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for AccountInfo<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("AccountInfo"); - ds.field("pubkey", &self.pubkey()); - ds.field("lamports", &self.lamports()); - ds.field("owner", &self.owner()); - ds.field("executable", &self.executable()); - ds.field("rent_epoch", &self.rent_epoch()); - ds.field("data", &self.data()); - ds.field("write_version", &self.write_version()); - ds.field("slot", &self.slot()); - ds.field("is_startup", &self.is_startup()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("AccountInfo"); + ds.field("pubkey", &self.pubkey()); + ds.field("lamports", &self.lamports()); + ds.field("owner", &self.owner()); + ds.field("executable", &self.executable()); + ds.field("rent_epoch", &self.rent_epoch()); + ds.field("data", &self.data()); + ds.field("write_version", &self.write_version()); + ds.field("slot", &self.slot()); + ds.field("is_startup", &self.is_startup()); + ds.field("seen_at", &self.seen_at()); + ds.finish() + } } #[inline] -#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")] +#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] pub fn get_root_as_account_info<'a>(buf: &'a [u8]) -> AccountInfo<'a> { - unsafe { flatbuffers::root_unchecked::>(buf) } + unsafe { flatbuffers::root_unchecked::>(buf) } } #[inline] -#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")] +#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] pub fn get_size_prefixed_root_as_account_info<'a>(buf: &'a [u8]) -> AccountInfo<'a> { - unsafe { flatbuffers::size_prefixed_root_unchecked::>(buf) } + unsafe { flatbuffers::size_prefixed_root_unchecked::>(buf) } } #[inline] @@ -269,7 +250,7 @@ pub fn get_size_prefixed_root_as_account_info<'a>(buf: &'a [u8]) -> AccountInfo< /// previous, unchecked, behavior use /// `root_as_account_info_unchecked`. pub fn root_as_account_info(buf: &[u8]) -> Result { - flatbuffers::root::(buf) + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -278,10 +259,8 @@ pub fn root_as_account_info(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_account_info(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -291,10 +270,10 @@ pub fn size_prefixed_root_as_account_info( /// previous, unchecked, behavior use /// `root_as_account_info_unchecked`. pub fn root_as_account_info_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -304,37 +283,33 @@ pub fn root_as_account_info_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_account_info_unchecked`. pub fn size_prefixed_root_as_account_info_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a AccountInfo and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `AccountInfo`. pub unsafe fn root_as_account_info_unchecked(buf: &[u8]) -> AccountInfo { - flatbuffers::root_unchecked::(buf) + flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed AccountInfo and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `AccountInfo`. pub unsafe fn size_prefixed_root_as_account_info_unchecked(buf: &[u8]) -> AccountInfo { - flatbuffers::size_prefixed_root_unchecked::(buf) + flatbuffers::size_prefixed_root_unchecked::(buf) } #[inline] pub fn finish_account_info_buffer<'a, 'b>( fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish(root, None); + root: flatbuffers::WIPOffset>) { + fbb.finish(root, None); } #[inline] -pub fn finish_size_prefixed_account_info_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); +pub fn finish_size_prefixed_account_info_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, None); } diff --git a/plerkle_serialization/src/block_info_generated.rs b/plerkle_serialization/src/block_info_generated.rs index ec2a851e..207a7182 100644 --- a/plerkle_serialization/src/block_info_generated.rs +++ b/plerkle_serialization/src/block_info_generated.rs @@ -1,32 +1,25 @@ // automatically generated by the FlatBuffers compiler, do not modify -// @generated +// @generated +use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; +use self::flatbuffers::{EndianScalar, Follow}; - -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_REWARD_TYPE: u8 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MAX_REWARD_TYPE: u8 = 3; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] #[allow(non_camel_case_types)] pub const ENUM_VALUES_REWARD_TYPE: [RewardType; 4] = [ - RewardType::Fee, - RewardType::Rent, - RewardType::Staking, - RewardType::Voting, + RewardType::Fee, + RewardType::Rent, + RewardType::Staking, + RewardType::Voting, ]; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] @@ -34,76 +27,80 @@ pub const ENUM_VALUES_REWARD_TYPE: [RewardType; 4] = [ pub struct RewardType(pub u8); #[allow(non_upper_case_globals)] impl RewardType { - pub const Fee: Self = Self(0); - pub const Rent: Self = Self(1); - pub const Staking: Self = Self(2); - pub const Voting: Self = Self(3); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 3; - pub const ENUM_VALUES: &'static [Self] = &[Self::Fee, Self::Rent, Self::Staking, Self::Voting]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::Fee => Some("Fee"), - Self::Rent => Some("Rent"), - Self::Staking => Some("Staking"), - Self::Voting => Some("Voting"), - _ => None, - } - } + pub const Fee: Self = Self(0); + pub const Rent: Self = Self(1); + pub const Staking: Self = Self(2); + pub const Voting: Self = Self(3); + + pub const ENUM_MIN: u8 = 0; + pub const ENUM_MAX: u8 = 3; + pub const ENUM_VALUES: &'static [Self] = &[ + Self::Fee, + Self::Rent, + Self::Staking, + Self::Voting, + ]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::Fee => Some("Fee"), + Self::Rent => Some("Rent"), + Self::Staking => Some("Staking"), + Self::Voting => Some("Voting"), + _ => None, + } + } } impl core::fmt::Debug for RewardType { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(name) = self.variant_name() { + f.write_str(name) + } else { + f.write_fmt(format_args!("", self.0)) } + } } impl<'a> flatbuffers::Follow<'a> for RewardType { - type Inner = Self; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } + type Inner = Self; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = unsafe { + flatbuffers::read_scalar_at::(buf, loc) + }; + Self(b) + } } impl flatbuffers::Push for RewardType { type Output = RewardType; #[inline] fn push(&self, dst: &mut [u8], _rest: &[u8]) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } + unsafe { flatbuffers::emplace_scalar::(dst, self.0); } } } impl flatbuffers::EndianScalar for RewardType { - #[inline] - fn to_little_endian(self) -> Self { - let b = u8::to_le(self.0); - Self(b) - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(self) -> Self { - let b = u8::from_le(self.0); - Self(b) - } + #[inline] + fn to_little_endian(self) -> Self { + let b = u8::to_le(self.0); + Self(b) + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(self) -> Self { + let b = u8::from_le(self.0); + Self(b) + } } impl<'a> flatbuffers::Verifiable for RewardType { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - u8::run_verifier(v, pos) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + u8::run_verifier(v, pos) + } } impl flatbuffers::SimpleToVerifyInSlice for RewardType {} @@ -111,99 +108,80 @@ pub enum RewardOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Reward<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for Reward<'a> { - type Inner = Reward<'a>; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table { buf, loc }, - } - } + type Inner = Reward<'a>; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table { buf, loc } } + } } impl<'a> Reward<'a> { - pub const VT_PUBKEY: flatbuffers::VOffsetT = 4; - pub const VT_LAMPORTS: flatbuffers::VOffsetT = 6; - pub const VT_POST_BALANCE: flatbuffers::VOffsetT = 8; - pub const VT_REWARD_TYPE: flatbuffers::VOffsetT = 10; - pub const VT_COMMISSION: flatbuffers::VOffsetT = 12; + pub const VT_PUBKEY: flatbuffers::VOffsetT = 4; + pub const VT_LAMPORTS: flatbuffers::VOffsetT = 6; + pub const VT_POST_BALANCE: flatbuffers::VOffsetT = 8; + pub const VT_REWARD_TYPE: flatbuffers::VOffsetT = 10; + pub const VT_COMMISSION: flatbuffers::VOffsetT = 12; - #[inline] - pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Reward { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args RewardArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = RewardBuilder::new(_fbb); - builder.add_post_balance(args.post_balance); - builder.add_lamports(args.lamports); - if let Some(x) = args.pubkey { - builder.add_pubkey(x); - } - if let Some(x) = args.commission { - builder.add_commission(x); - } - if let Some(x) = args.reward_type { - builder.add_reward_type(x); - } - builder.finish() - } + #[inline] + pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Reward { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args RewardArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = RewardBuilder::new(_fbb); + builder.add_post_balance(args.post_balance); + builder.add_lamports(args.lamports); + if let Some(x) = args.pubkey { builder.add_pubkey(x); } + if let Some(x) = args.commission { builder.add_commission(x); } + if let Some(x) = args.reward_type { builder.add_reward_type(x); } + builder.finish() + } - #[inline] - pub fn pubkey(&self) -> Option<&'a [u8]> { - self._tab - .get::>>( - Reward::VT_PUBKEY, - None, - ) - .map(|v| v.safe_slice()) - } - #[inline] - pub fn lamports(&self) -> i64 { - self._tab.get::(Reward::VT_LAMPORTS, Some(0)).unwrap() - } - #[inline] - pub fn post_balance(&self) -> u64 { - self._tab - .get::(Reward::VT_POST_BALANCE, Some(0)) - .unwrap() - } - #[inline] - pub fn reward_type(&self) -> Option { - self._tab.get::(Reward::VT_REWARD_TYPE, None) - } - #[inline] - pub fn commission(&self) -> Option { - self._tab.get::(Reward::VT_COMMISSION, None) - } + + #[inline] + pub fn pubkey(&self) -> Option<&'a [u8]> { + self._tab.get::>>(Reward::VT_PUBKEY, None).map(|v| v.safe_slice()) + } + #[inline] + pub fn lamports(&self) -> i64 { + self._tab.get::(Reward::VT_LAMPORTS, Some(0)).unwrap() + } + #[inline] + pub fn post_balance(&self) -> u64 { + self._tab.get::(Reward::VT_POST_BALANCE, Some(0)).unwrap() + } + #[inline] + pub fn reward_type(&self) -> Option { + self._tab.get::(Reward::VT_REWARD_TYPE, None) + } + #[inline] + pub fn commission(&self) -> Option { + self._tab.get::(Reward::VT_COMMISSION, None) + } } impl flatbuffers::Verifiable for Reward<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - - v.visit_table(pos)? - .visit_field::>>( - "pubkey", - Self::VT_PUBKEY, - false, - )? - .visit_field::("lamports", Self::VT_LAMPORTS, false)? - .visit_field::("post_balance", Self::VT_POST_BALANCE, false)? - .visit_field::("reward_type", Self::VT_REWARD_TYPE, false)? - .visit_field::("commission", Self::VT_COMMISSION, false)? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>>("pubkey", Self::VT_PUBKEY, false)? + .visit_field::("lamports", Self::VT_LAMPORTS, false)? + .visit_field::("post_balance", Self::VT_POST_BALANCE, false)? + .visit_field::("reward_type", Self::VT_REWARD_TYPE, false)? + .visit_field::("commission", Self::VT_COMMISSION, false)? + .finish(); + Ok(()) + } } pub struct RewardArgs<'a> { pub pubkey: Option>>, @@ -213,265 +191,243 @@ pub struct RewardArgs<'a> { pub commission: Option, } impl<'a> Default for RewardArgs<'a> { - #[inline] - fn default() -> Self { - RewardArgs { - pubkey: None, - lamports: 0, - post_balance: 0, - reward_type: None, - commission: None, - } + #[inline] + fn default() -> Self { + RewardArgs { + pubkey: None, + lamports: 0, + post_balance: 0, + reward_type: None, + commission: None, } + } } pub struct RewardBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, } impl<'a: 'b, 'b> RewardBuilder<'a, 'b> { - #[inline] - pub fn add_pubkey(&mut self, pubkey: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(Reward::VT_PUBKEY, pubkey); - } - #[inline] - pub fn add_lamports(&mut self, lamports: i64) { - self.fbb_.push_slot::(Reward::VT_LAMPORTS, lamports, 0); - } - #[inline] - pub fn add_post_balance(&mut self, post_balance: u64) { - self.fbb_ - .push_slot::(Reward::VT_POST_BALANCE, post_balance, 0); - } - #[inline] - pub fn add_reward_type(&mut self, reward_type: RewardType) { - self.fbb_ - .push_slot_always::(Reward::VT_REWARD_TYPE, reward_type); - } - #[inline] - pub fn add_commission(&mut self, commission: u8) { - self.fbb_ - .push_slot_always::(Reward::VT_COMMISSION, commission); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> RewardBuilder<'a, 'b> { - let start = _fbb.start_table(); - RewardBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) - } + #[inline] + pub fn add_pubkey(&mut self, pubkey: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Reward::VT_PUBKEY, pubkey); + } + #[inline] + pub fn add_lamports(&mut self, lamports: i64) { + self.fbb_.push_slot::(Reward::VT_LAMPORTS, lamports, 0); + } + #[inline] + pub fn add_post_balance(&mut self, post_balance: u64) { + self.fbb_.push_slot::(Reward::VT_POST_BALANCE, post_balance, 0); + } + #[inline] + pub fn add_reward_type(&mut self, reward_type: RewardType) { + self.fbb_.push_slot_always::(Reward::VT_REWARD_TYPE, reward_type); + } + #[inline] + pub fn add_commission(&mut self, commission: u8) { + self.fbb_.push_slot_always::(Reward::VT_COMMISSION, commission); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> RewardBuilder<'a, 'b> { + let start = _fbb.start_table(); + RewardBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for Reward<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Reward"); - ds.field("pubkey", &self.pubkey()); - ds.field("lamports", &self.lamports()); - ds.field("post_balance", &self.post_balance()); - ds.field("reward_type", &self.reward_type()); - ds.field("commission", &self.commission()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Reward"); + ds.field("pubkey", &self.pubkey()); + ds.field("lamports", &self.lamports()); + ds.field("post_balance", &self.post_balance()); + ds.field("reward_type", &self.reward_type()); + ds.field("commission", &self.commission()); + ds.finish() + } } pub enum BlockInfoOffset {} #[derive(Copy, Clone, PartialEq)] pub struct BlockInfo<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for BlockInfo<'a> { - type Inner = BlockInfo<'a>; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table { buf, loc }, - } - } + type Inner = BlockInfo<'a>; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table { buf, loc } } + } } impl<'a> BlockInfo<'a> { - pub const VT_SLOT: flatbuffers::VOffsetT = 4; - pub const VT_BLOCKHASH: flatbuffers::VOffsetT = 6; - pub const VT_REWARDS: flatbuffers::VOffsetT = 8; - pub const VT_BLOCK_TIME: flatbuffers::VOffsetT = 10; - pub const VT_BLOCK_HEIGHT: flatbuffers::VOffsetT = 12; + pub const VT_SLOT: flatbuffers::VOffsetT = 4; + pub const VT_BLOCKHASH: flatbuffers::VOffsetT = 6; + pub const VT_REWARDS: flatbuffers::VOffsetT = 8; + pub const VT_BLOCK_TIME: flatbuffers::VOffsetT = 10; + pub const VT_BLOCK_HEIGHT: flatbuffers::VOffsetT = 12; + pub const VT_SEEN_AT: flatbuffers::VOffsetT = 14; - #[inline] - pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - BlockInfo { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args BlockInfoArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = BlockInfoBuilder::new(_fbb); - if let Some(x) = args.block_height { - builder.add_block_height(x); - } - if let Some(x) = args.block_time { - builder.add_block_time(x); - } - builder.add_slot(args.slot); - if let Some(x) = args.rewards { - builder.add_rewards(x); - } - if let Some(x) = args.blockhash { - builder.add_blockhash(x); - } - builder.finish() - } + #[inline] + pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + BlockInfo { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args BlockInfoArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = BlockInfoBuilder::new(_fbb); + builder.add_seen_at(args.seen_at); + if let Some(x) = args.block_height { builder.add_block_height(x); } + if let Some(x) = args.block_time { builder.add_block_time(x); } + builder.add_slot(args.slot); + if let Some(x) = args.rewards { builder.add_rewards(x); } + if let Some(x) = args.blockhash { builder.add_blockhash(x); } + builder.finish() + } - #[inline] - pub fn slot(&self) -> u64 { - self._tab.get::(BlockInfo::VT_SLOT, Some(0)).unwrap() - } - #[inline] - pub fn blockhash(&self) -> Option<&'a str> { - self._tab - .get::>(BlockInfo::VT_BLOCKHASH, None) - } - #[inline] - pub fn rewards( - &self, - ) -> Option>>> { - self._tab.get::>, - >>(BlockInfo::VT_REWARDS, None) - } - #[inline] - pub fn block_time(&self) -> Option { - self._tab.get::(BlockInfo::VT_BLOCK_TIME, None) - } - #[inline] - pub fn block_height(&self) -> Option { - self._tab.get::(BlockInfo::VT_BLOCK_HEIGHT, None) - } + + #[inline] + pub fn slot(&self) -> u64 { + self._tab.get::(BlockInfo::VT_SLOT, Some(0)).unwrap() + } + #[inline] + pub fn blockhash(&self) -> Option<&'a str> { + self._tab.get::>(BlockInfo::VT_BLOCKHASH, None) + } + #[inline] + pub fn rewards(&self) -> Option>>> { + self._tab.get::>>>(BlockInfo::VT_REWARDS, None) + } + #[inline] + pub fn block_time(&self) -> Option { + self._tab.get::(BlockInfo::VT_BLOCK_TIME, None) + } + #[inline] + pub fn block_height(&self) -> Option { + self._tab.get::(BlockInfo::VT_BLOCK_HEIGHT, None) + } + #[inline] + pub fn seen_at(&self) -> i64 { + self._tab.get::(BlockInfo::VT_SEEN_AT, Some(0)).unwrap() + } } impl flatbuffers::Verifiable for BlockInfo<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - - v.visit_table(pos)? - .visit_field::("slot", Self::VT_SLOT, false)? - .visit_field::>( - "blockhash", - Self::VT_BLOCKHASH, - false, - )? - .visit_field::>, - >>("rewards", Self::VT_REWARDS, false)? - .visit_field::("block_time", Self::VT_BLOCK_TIME, false)? - .visit_field::("block_height", Self::VT_BLOCK_HEIGHT, false)? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("slot", Self::VT_SLOT, false)? + .visit_field::>("blockhash", Self::VT_BLOCKHASH, false)? + .visit_field::>>>("rewards", Self::VT_REWARDS, false)? + .visit_field::("block_time", Self::VT_BLOCK_TIME, false)? + .visit_field::("block_height", Self::VT_BLOCK_HEIGHT, false)? + .visit_field::("seen_at", Self::VT_SEEN_AT, false)? + .finish(); + Ok(()) + } } pub struct BlockInfoArgs<'a> { pub slot: u64, pub blockhash: Option>, - pub rewards: Option< - flatbuffers::WIPOffset>>>, - >, + pub rewards: Option>>>>, pub block_time: Option, pub block_height: Option, + pub seen_at: i64, } impl<'a> Default for BlockInfoArgs<'a> { - #[inline] - fn default() -> Self { - BlockInfoArgs { - slot: 0, - blockhash: None, - rewards: None, - block_time: None, - block_height: None, - } - } + #[inline] + fn default() -> Self { + BlockInfoArgs { + slot: 0, + blockhash: None, + rewards: None, + block_time: None, + block_height: None, + seen_at: 0, + } + } } pub struct BlockInfoBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, } impl<'a: 'b, 'b> BlockInfoBuilder<'a, 'b> { - #[inline] - pub fn add_slot(&mut self, slot: u64) { - self.fbb_.push_slot::(BlockInfo::VT_SLOT, slot, 0); - } - #[inline] - pub fn add_blockhash(&mut self, blockhash: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(BlockInfo::VT_BLOCKHASH, blockhash); - } - #[inline] - pub fn add_rewards( - &mut self, - rewards: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(BlockInfo::VT_REWARDS, rewards); - } - #[inline] - pub fn add_block_time(&mut self, block_time: i64) { - self.fbb_ - .push_slot_always::(BlockInfo::VT_BLOCK_TIME, block_time); - } - #[inline] - pub fn add_block_height(&mut self, block_height: u64) { - self.fbb_ - .push_slot_always::(BlockInfo::VT_BLOCK_HEIGHT, block_height); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> BlockInfoBuilder<'a, 'b> { - let start = _fbb.start_table(); - BlockInfoBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) - } + #[inline] + pub fn add_slot(&mut self, slot: u64) { + self.fbb_.push_slot::(BlockInfo::VT_SLOT, slot, 0); + } + #[inline] + pub fn add_blockhash(&mut self, blockhash: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(BlockInfo::VT_BLOCKHASH, blockhash); + } + #[inline] + pub fn add_rewards(&mut self, rewards: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(BlockInfo::VT_REWARDS, rewards); + } + #[inline] + pub fn add_block_time(&mut self, block_time: i64) { + self.fbb_.push_slot_always::(BlockInfo::VT_BLOCK_TIME, block_time); + } + #[inline] + pub fn add_block_height(&mut self, block_height: u64) { + self.fbb_.push_slot_always::(BlockInfo::VT_BLOCK_HEIGHT, block_height); + } + #[inline] + pub fn add_seen_at(&mut self, seen_at: i64) { + self.fbb_.push_slot::(BlockInfo::VT_SEEN_AT, seen_at, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> BlockInfoBuilder<'a, 'b> { + let start = _fbb.start_table(); + BlockInfoBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for BlockInfo<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("BlockInfo"); - ds.field("slot", &self.slot()); - ds.field("blockhash", &self.blockhash()); - ds.field("rewards", &self.rewards()); - ds.field("block_time", &self.block_time()); - ds.field("block_height", &self.block_height()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("BlockInfo"); + ds.field("slot", &self.slot()); + ds.field("blockhash", &self.blockhash()); + ds.field("rewards", &self.rewards()); + ds.field("block_time", &self.block_time()); + ds.field("block_height", &self.block_height()); + ds.field("seen_at", &self.seen_at()); + ds.finish() + } } #[inline] -#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")] +#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] pub fn get_root_as_block_info<'a>(buf: &'a [u8]) -> BlockInfo<'a> { - unsafe { flatbuffers::root_unchecked::>(buf) } + unsafe { flatbuffers::root_unchecked::>(buf) } } #[inline] -#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")] +#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] pub fn get_size_prefixed_root_as_block_info<'a>(buf: &'a [u8]) -> BlockInfo<'a> { - unsafe { flatbuffers::size_prefixed_root_unchecked::>(buf) } + unsafe { flatbuffers::size_prefixed_root_unchecked::>(buf) } } #[inline] @@ -482,7 +438,7 @@ pub fn get_size_prefixed_root_as_block_info<'a>(buf: &'a [u8]) -> BlockInfo<'a> /// previous, unchecked, behavior use /// `root_as_block_info_unchecked`. pub fn root_as_block_info(buf: &[u8]) -> Result { - flatbuffers::root::(buf) + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -491,10 +447,8 @@ pub fn root_as_block_info(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_block_info(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -504,10 +458,10 @@ pub fn size_prefixed_root_as_block_info( /// previous, unchecked, behavior use /// `root_as_block_info_unchecked`. pub fn root_as_block_info_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -517,37 +471,33 @@ pub fn root_as_block_info_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_block_info_unchecked`. pub fn size_prefixed_root_as_block_info_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a BlockInfo and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `BlockInfo`. pub unsafe fn root_as_block_info_unchecked(buf: &[u8]) -> BlockInfo { - flatbuffers::root_unchecked::(buf) + flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed BlockInfo and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `BlockInfo`. pub unsafe fn size_prefixed_root_as_block_info_unchecked(buf: &[u8]) -> BlockInfo { - flatbuffers::size_prefixed_root_unchecked::(buf) + flatbuffers::size_prefixed_root_unchecked::(buf) } #[inline] pub fn finish_block_info_buffer<'a, 'b>( fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish(root, None); + root: flatbuffers::WIPOffset>) { + fbb.finish(root, None); } #[inline] -pub fn finish_size_prefixed_block_info_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); +pub fn finish_size_prefixed_block_info_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, None); } diff --git a/plerkle_serialization/src/common_generated.rs b/plerkle_serialization/src/common_generated.rs index b3844062..d5e6e00f 100644 --- a/plerkle_serialization/src/common_generated.rs +++ b/plerkle_serialization/src/common_generated.rs @@ -1,42 +1,46 @@ // automatically generated by the FlatBuffers compiler, do not modify -// @generated +// @generated +use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; -use self::flatbuffers::{Follow}; +use self::flatbuffers::{EndianScalar, Follow}; // struct Pubkey, aligned to 1 #[repr(transparent)] #[derive(Clone, Copy, PartialEq)] pub struct Pubkey(pub [u8; 32]); -impl Default for Pubkey { - fn default() -> Self { - Self([0; 32]) - } +impl Default for Pubkey { + fn default() -> Self { + Self([0; 32]) + } } impl core::fmt::Debug for Pubkey { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - f.debug_struct("Pubkey").field("key", &self.key()).finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.debug_struct("Pubkey") + .field("key", &self.key()) + .finish() + } } impl flatbuffers::SimpleToVerifyInSlice for Pubkey {} impl flatbuffers::SafeSliceAccess for Pubkey {} impl<'a> flatbuffers::Follow<'a> for Pubkey { - type Inner = &'a Pubkey; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - <&'a Pubkey>::follow(buf, loc) - } + type Inner = &'a Pubkey; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + <&'a Pubkey>::follow(buf, loc) + } } impl<'a> flatbuffers::Follow<'a> for &'a Pubkey { - type Inner = &'a Pubkey; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) - } + type Inner = &'a Pubkey; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + flatbuffers::follow_cast_ref::(buf, loc) + } } impl<'b> flatbuffers::Push for Pubkey { type Output = Pubkey; @@ -61,29 +65,32 @@ impl<'b> flatbuffers::Push for &'b Pubkey { } impl<'a> flatbuffers::Verifiable for Pubkey { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - - v.in_buffer::(pos) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.in_buffer::(pos) + } } impl<'a> Pubkey { - #[allow(clippy::too_many_arguments)] - pub fn new(key: &[u8; 32]) -> Self { - let mut s = Self([0; 32]); - s.set_key(key); - s - } + #[allow(clippy::too_many_arguments)] + pub fn new( + key: &[u8; 32], + ) -> Self { + let mut s = Self([0; 32]); + s.set_key(key); + s + } - pub fn key(&'a self) -> flatbuffers::Array<'a, u8, 32> { - flatbuffers::Array::follow(&self.0, 0) - } + pub fn key(&'a self) -> flatbuffers::Array<'a, u8, 32> { + flatbuffers::Array::follow(&self.0, 0) + } + + pub fn set_key(&mut self, items: &[u8; 32]) { + flatbuffers::emplace_scalar_array(&mut self.0, 0, items); + } - pub fn set_key(&mut self, items: &[u8; 32]) { - flatbuffers::emplace_scalar_array(&mut self.0, 0, items); - } } + diff --git a/plerkle_serialization/src/compiled_instruction_generated.rs b/plerkle_serialization/src/compiled_instruction_generated.rs index 6e517276..d8a92c0e 100644 --- a/plerkle_serialization/src/compiled_instruction_generated.rs +++ b/plerkle_serialization/src/compiled_instruction_generated.rs @@ -1,103 +1,79 @@ // automatically generated by the FlatBuffers compiler, do not modify -// @generated - +// @generated +use crate::common_generated::*; +use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; - +use self::flatbuffers::{EndianScalar, Follow}; pub enum CompiledInstructionOffset {} #[derive(Copy, Clone, PartialEq)] pub struct CompiledInstruction<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for CompiledInstruction<'a> { - type Inner = CompiledInstruction<'a>; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table { buf, loc }, - } - } + type Inner = CompiledInstruction<'a>; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table { buf, loc } } + } } impl<'a> CompiledInstruction<'a> { - pub const VT_PROGRAM_ID_INDEX: flatbuffers::VOffsetT = 4; - pub const VT_ACCOUNTS: flatbuffers::VOffsetT = 6; - pub const VT_DATA: flatbuffers::VOffsetT = 8; - - #[inline] - pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - CompiledInstruction { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args CompiledInstructionArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = CompiledInstructionBuilder::new(_fbb); - if let Some(x) = args.data { - builder.add_data(x); - } - if let Some(x) = args.accounts { - builder.add_accounts(x); - } - builder.add_program_id_index(args.program_id_index); - builder.finish() - } - - #[inline] - pub fn program_id_index(&self) -> u8 { - self._tab - .get::(CompiledInstruction::VT_PROGRAM_ID_INDEX, Some(0)) - .unwrap() - } - #[inline] - pub fn accounts(&self) -> Option<&'a [u8]> { - self._tab - .get::>>( - CompiledInstruction::VT_ACCOUNTS, - None, - ) - .map(|v| v.safe_slice()) - } - #[inline] - pub fn data(&self) -> Option<&'a [u8]> { - self._tab - .get::>>( - CompiledInstruction::VT_DATA, - None, - ) - .map(|v| v.safe_slice()) - } + pub const VT_PROGRAM_ID_INDEX: flatbuffers::VOffsetT = 4; + pub const VT_ACCOUNTS: flatbuffers::VOffsetT = 6; + pub const VT_DATA: flatbuffers::VOffsetT = 8; + + #[inline] + pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + CompiledInstruction { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args CompiledInstructionArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = CompiledInstructionBuilder::new(_fbb); + if let Some(x) = args.data { builder.add_data(x); } + if let Some(x) = args.accounts { builder.add_accounts(x); } + builder.add_program_id_index(args.program_id_index); + builder.finish() + } + + + #[inline] + pub fn program_id_index(&self) -> u8 { + self._tab.get::(CompiledInstruction::VT_PROGRAM_ID_INDEX, Some(0)).unwrap() + } + #[inline] + pub fn accounts(&self) -> Option<&'a [u8]> { + self._tab.get::>>(CompiledInstruction::VT_ACCOUNTS, None).map(|v| v.safe_slice()) + } + #[inline] + pub fn data(&self) -> Option<&'a [u8]> { + self._tab.get::>>(CompiledInstruction::VT_DATA, None).map(|v| v.safe_slice()) + } } impl flatbuffers::Verifiable for CompiledInstruction<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - - v.visit_table(pos)? - .visit_field::("program_id_index", Self::VT_PROGRAM_ID_INDEX, false)? - .visit_field::>>( - "accounts", - Self::VT_ACCOUNTS, - false, - )? - .visit_field::>>( - "data", - Self::VT_DATA, - false, - )? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("program_id_index", Self::VT_PROGRAM_ID_INDEX, false)? + .visit_field::>>("accounts", Self::VT_ACCOUNTS, false)? + .visit_field::>>("data", Self::VT_DATA, false)? + .finish(); + Ok(()) + } } pub struct CompiledInstructionArgs<'a> { pub program_id_index: u8, @@ -105,79 +81,67 @@ pub struct CompiledInstructionArgs<'a> { pub data: Option>>, } impl<'a> Default for CompiledInstructionArgs<'a> { - #[inline] - fn default() -> Self { - CompiledInstructionArgs { - program_id_index: 0, - accounts: None, - data: None, - } + #[inline] + fn default() -> Self { + CompiledInstructionArgs { + program_id_index: 0, + accounts: None, + data: None, } + } } pub struct CompiledInstructionBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, } impl<'a: 'b, 'b> CompiledInstructionBuilder<'a, 'b> { - #[inline] - pub fn add_program_id_index(&mut self, program_id_index: u8) { - self.fbb_.push_slot::( - CompiledInstruction::VT_PROGRAM_ID_INDEX, - program_id_index, - 0, - ); - } - #[inline] - pub fn add_accounts(&mut self, accounts: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>( - CompiledInstruction::VT_ACCOUNTS, - accounts, - ); - } - #[inline] - pub fn add_data(&mut self, data: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(CompiledInstruction::VT_DATA, data); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - ) -> CompiledInstructionBuilder<'a, 'b> { - let start = _fbb.start_table(); - CompiledInstructionBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + #[inline] + pub fn add_program_id_index(&mut self, program_id_index: u8) { + self.fbb_.push_slot::(CompiledInstruction::VT_PROGRAM_ID_INDEX, program_id_index, 0); + } + #[inline] + pub fn add_accounts(&mut self, accounts: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(CompiledInstruction::VT_ACCOUNTS, accounts); + } + #[inline] + pub fn add_data(&mut self, data: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(CompiledInstruction::VT_DATA, data); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> CompiledInstructionBuilder<'a, 'b> { + let start = _fbb.start_table(); + CompiledInstructionBuilder { + fbb_: _fbb, + start_: start, } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for CompiledInstruction<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("CompiledInstruction"); - ds.field("program_id_index", &self.program_id_index()); - ds.field("accounts", &self.accounts()); - ds.field("data", &self.data()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("CompiledInstruction"); + ds.field("program_id_index", &self.program_id_index()); + ds.field("accounts", &self.accounts()); + ds.field("data", &self.data()); + ds.finish() + } } #[inline] -#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")] +#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] pub fn get_root_as_compiled_instruction<'a>(buf: &'a [u8]) -> CompiledInstruction<'a> { - unsafe { flatbuffers::root_unchecked::>(buf) } + unsafe { flatbuffers::root_unchecked::>(buf) } } #[inline] -#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")] -pub fn get_size_prefixed_root_as_compiled_instruction<'a>( - buf: &'a [u8], -) -> CompiledInstruction<'a> { - unsafe { flatbuffers::size_prefixed_root_unchecked::>(buf) } +#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] +pub fn get_size_prefixed_root_as_compiled_instruction<'a>(buf: &'a [u8]) -> CompiledInstruction<'a> { + unsafe { flatbuffers::size_prefixed_root_unchecked::>(buf) } } #[inline] @@ -187,10 +151,8 @@ pub fn get_size_prefixed_root_as_compiled_instruction<'a>( /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `root_as_compiled_instruction_unchecked`. -pub fn root_as_compiled_instruction( - buf: &[u8], -) -> Result { - flatbuffers::root::(buf) +pub fn root_as_compiled_instruction(buf: &[u8]) -> Result { + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -199,10 +161,8 @@ pub fn root_as_compiled_instruction( /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `size_prefixed_root_as_compiled_instruction_unchecked`. -pub fn size_prefixed_root_as_compiled_instruction( - buf: &[u8], -) -> Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_compiled_instruction(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -212,10 +172,10 @@ pub fn size_prefixed_root_as_compiled_instruction( /// previous, unchecked, behavior use /// `root_as_compiled_instruction_unchecked`. pub fn root_as_compiled_instruction_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -225,39 +185,33 @@ pub fn root_as_compiled_instruction_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_compiled_instruction_unchecked`. pub fn size_prefixed_root_as_compiled_instruction_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a CompiledInstruction and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `CompiledInstruction`. pub unsafe fn root_as_compiled_instruction_unchecked(buf: &[u8]) -> CompiledInstruction { - flatbuffers::root_unchecked::(buf) + flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed CompiledInstruction and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `CompiledInstruction`. -pub unsafe fn size_prefixed_root_as_compiled_instruction_unchecked( - buf: &[u8], -) -> CompiledInstruction { - flatbuffers::size_prefixed_root_unchecked::(buf) +pub unsafe fn size_prefixed_root_as_compiled_instruction_unchecked(buf: &[u8]) -> CompiledInstruction { + flatbuffers::size_prefixed_root_unchecked::(buf) } #[inline] pub fn finish_compiled_instruction_buffer<'a, 'b>( fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish(root, None); + root: flatbuffers::WIPOffset>) { + fbb.finish(root, None); } #[inline] -pub fn finish_size_prefixed_compiled_instruction_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); +pub fn finish_size_prefixed_compiled_instruction_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, None); } diff --git a/plerkle_serialization/src/serializer/serializer_stable.rs b/plerkle_serialization/src/serializer/serializer_stable.rs index 352b0d38..ea42ae41 100644 --- a/plerkle_serialization/src/serializer/serializer_stable.rs +++ b/plerkle_serialization/src/serializer/serializer_stable.rs @@ -19,6 +19,7 @@ pub fn serialize_account<'a>( let data = builder.create_vector(account.data); // Serialize everything into Account Info table. + let seen_at = Utc::now(); let account_info = AccountInfo::create( &mut builder, &AccountInfoArgs { @@ -31,6 +32,7 @@ pub fn serialize_account<'a>( write_version: account.write_version, slot, is_startup, + seen_at: seen_at.timestamp_millis() }, ); @@ -53,12 +55,14 @@ pub fn serialize_slot_status<'a>( }; // Serialize everything into Slot Status Info table. + let seen_at = Utc::now(); let slot_status = SlotStatusInfo::create( &mut builder, &SlotStatusInfoArgs { slot, parent, status, + seen_at: seen_at.timestamp_millis() }, ); @@ -225,6 +229,7 @@ pub fn serialize_block<'a>( }; // Serialize everything into Block Info table. + let seen_at = Utc::now(); let block_info = BlockInfo::create( &mut builder, &BlockInfoArgs { @@ -233,6 +238,7 @@ pub fn serialize_block<'a>( rewards, block_time: block_info.block_time, block_height: block_info.block_height, + seen_at: seen_at.timestamp_millis(), }, ); diff --git a/plerkle_serialization/src/slot_status_info_generated.rs b/plerkle_serialization/src/slot_status_info_generated.rs index 1e157c66..48c20c2a 100644 --- a/plerkle_serialization/src/slot_status_info_generated.rs +++ b/plerkle_serialization/src/slot_status_info_generated.rs @@ -1,102 +1,102 @@ // automatically generated by the FlatBuffers compiler, do not modify -// @generated +// @generated +use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; +use self::flatbuffers::{EndianScalar, Follow}; - -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_STATUS: i8 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MAX_STATUS: i8 = 2; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] #[allow(non_camel_case_types)] -pub const ENUM_VALUES_STATUS: [Status; 3] = [Status::Processed, Status::Rooted, Status::Confirmed]; +pub const ENUM_VALUES_STATUS: [Status; 3] = [ + Status::Processed, + Status::Rooted, + Status::Confirmed, +]; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[repr(transparent)] pub struct Status(pub i8); #[allow(non_upper_case_globals)] impl Status { - pub const Processed: Self = Self(0); - pub const Rooted: Self = Self(1); - pub const Confirmed: Self = Self(2); + pub const Processed: Self = Self(0); + pub const Rooted: Self = Self(1); + pub const Confirmed: Self = Self(2); - pub const ENUM_MIN: i8 = 0; - pub const ENUM_MAX: i8 = 2; - pub const ENUM_VALUES: &'static [Self] = &[Self::Processed, Self::Rooted, Self::Confirmed]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::Processed => Some("Processed"), - Self::Rooted => Some("Rooted"), - Self::Confirmed => Some("Confirmed"), - _ => None, - } + pub const ENUM_MIN: i8 = 0; + pub const ENUM_MAX: i8 = 2; + pub const ENUM_VALUES: &'static [Self] = &[ + Self::Processed, + Self::Rooted, + Self::Confirmed, + ]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::Processed => Some("Processed"), + Self::Rooted => Some("Rooted"), + Self::Confirmed => Some("Confirmed"), + _ => None, } + } } impl core::fmt::Debug for Status { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(name) = self.variant_name() { + f.write_str(name) + } else { + f.write_fmt(format_args!("", self.0)) } + } } impl<'a> flatbuffers::Follow<'a> for Status { - type Inner = Self; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } + type Inner = Self; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = unsafe { + flatbuffers::read_scalar_at::(buf, loc) + }; + Self(b) + } } impl flatbuffers::Push for Status { type Output = Status; #[inline] fn push(&self, dst: &mut [u8], _rest: &[u8]) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } + unsafe { flatbuffers::emplace_scalar::(dst, self.0); } } } impl flatbuffers::EndianScalar for Status { - #[inline] - fn to_little_endian(self) -> Self { - let b = i8::to_le(self.0); - Self(b) - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(self) -> Self { - let b = i8::from_le(self.0); - Self(b) - } + #[inline] + fn to_little_endian(self) -> Self { + let b = i8::to_le(self.0); + Self(b) + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(self) -> Self { + let b = i8::from_le(self.0); + Self(b) + } } impl<'a> flatbuffers::Verifiable for Status { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - i8::run_verifier(v, pos) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + i8::run_verifier(v, pos) + } } impl flatbuffers::SimpleToVerifyInSlice for Status {} @@ -104,144 +104,148 @@ pub enum SlotStatusInfoOffset {} #[derive(Copy, Clone, PartialEq)] pub struct SlotStatusInfo<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for SlotStatusInfo<'a> { - type Inner = SlotStatusInfo<'a>; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table { buf, loc }, - } - } + type Inner = SlotStatusInfo<'a>; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table { buf, loc } } + } } impl<'a> SlotStatusInfo<'a> { - pub const VT_SLOT: flatbuffers::VOffsetT = 4; - pub const VT_PARENT: flatbuffers::VOffsetT = 6; - pub const VT_STATUS: flatbuffers::VOffsetT = 8; + pub const VT_SLOT: flatbuffers::VOffsetT = 4; + pub const VT_PARENT: flatbuffers::VOffsetT = 6; + pub const VT_STATUS: flatbuffers::VOffsetT = 8; + pub const VT_SEEN_AT: flatbuffers::VOffsetT = 10; - #[inline] - pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - SlotStatusInfo { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args SlotStatusInfoArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = SlotStatusInfoBuilder::new(_fbb); - if let Some(x) = args.parent { - builder.add_parent(x); - } - builder.add_slot(args.slot); - builder.add_status(args.status); - builder.finish() - } + #[inline] + pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + SlotStatusInfo { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args SlotStatusInfoArgs + ) -> flatbuffers::WIPOffset> { + let mut builder = SlotStatusInfoBuilder::new(_fbb); + builder.add_seen_at(args.seen_at); + if let Some(x) = args.parent { builder.add_parent(x); } + builder.add_slot(args.slot); + builder.add_status(args.status); + builder.finish() + } - #[inline] - pub fn slot(&self) -> u64 { - self._tab - .get::(SlotStatusInfo::VT_SLOT, Some(0)) - .unwrap() - } - #[inline] - pub fn parent(&self) -> Option { - self._tab.get::(SlotStatusInfo::VT_PARENT, None) - } - #[inline] - pub fn status(&self) -> Status { - self._tab - .get::(SlotStatusInfo::VT_STATUS, Some(Status::Processed)) - .unwrap() - } + + #[inline] + pub fn slot(&self) -> u64 { + self._tab.get::(SlotStatusInfo::VT_SLOT, Some(0)).unwrap() + } + #[inline] + pub fn parent(&self) -> Option { + self._tab.get::(SlotStatusInfo::VT_PARENT, None) + } + #[inline] + pub fn status(&self) -> Status { + self._tab.get::(SlotStatusInfo::VT_STATUS, Some(Status::Processed)).unwrap() + } + #[inline] + pub fn seen_at(&self) -> i64 { + self._tab.get::(SlotStatusInfo::VT_SEEN_AT, Some(0)).unwrap() + } } impl flatbuffers::Verifiable for SlotStatusInfo<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - - v.visit_table(pos)? - .visit_field::("slot", Self::VT_SLOT, false)? - .visit_field::("parent", Self::VT_PARENT, false)? - .visit_field::("status", Self::VT_STATUS, false)? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("slot", Self::VT_SLOT, false)? + .visit_field::("parent", Self::VT_PARENT, false)? + .visit_field::("status", Self::VT_STATUS, false)? + .visit_field::("seen_at", Self::VT_SEEN_AT, false)? + .finish(); + Ok(()) + } } pub struct SlotStatusInfoArgs { pub slot: u64, pub parent: Option, pub status: Status, + pub seen_at: i64, } impl<'a> Default for SlotStatusInfoArgs { - #[inline] - fn default() -> Self { - SlotStatusInfoArgs { - slot: 0, - parent: None, - status: Status::Processed, - } + #[inline] + fn default() -> Self { + SlotStatusInfoArgs { + slot: 0, + parent: None, + status: Status::Processed, + seen_at: 0, } + } } pub struct SlotStatusInfoBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, } impl<'a: 'b, 'b> SlotStatusInfoBuilder<'a, 'b> { - #[inline] - pub fn add_slot(&mut self, slot: u64) { - self.fbb_.push_slot::(SlotStatusInfo::VT_SLOT, slot, 0); - } - #[inline] - pub fn add_parent(&mut self, parent: u64) { - self.fbb_ - .push_slot_always::(SlotStatusInfo::VT_PARENT, parent); - } - #[inline] - pub fn add_status(&mut self, status: Status) { - self.fbb_ - .push_slot::(SlotStatusInfo::VT_STATUS, status, Status::Processed); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SlotStatusInfoBuilder<'a, 'b> { - let start = _fbb.start_table(); - SlotStatusInfoBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + #[inline] + pub fn add_slot(&mut self, slot: u64) { + self.fbb_.push_slot::(SlotStatusInfo::VT_SLOT, slot, 0); + } + #[inline] + pub fn add_parent(&mut self, parent: u64) { + self.fbb_.push_slot_always::(SlotStatusInfo::VT_PARENT, parent); + } + #[inline] + pub fn add_status(&mut self, status: Status) { + self.fbb_.push_slot::(SlotStatusInfo::VT_STATUS, status, Status::Processed); + } + #[inline] + pub fn add_seen_at(&mut self, seen_at: i64) { + self.fbb_.push_slot::(SlotStatusInfo::VT_SEEN_AT, seen_at, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SlotStatusInfoBuilder<'a, 'b> { + let start = _fbb.start_table(); + SlotStatusInfoBuilder { + fbb_: _fbb, + start_: start, } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for SlotStatusInfo<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("SlotStatusInfo"); - ds.field("slot", &self.slot()); - ds.field("parent", &self.parent()); - ds.field("status", &self.status()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("SlotStatusInfo"); + ds.field("slot", &self.slot()); + ds.field("parent", &self.parent()); + ds.field("status", &self.status()); + ds.field("seen_at", &self.seen_at()); + ds.finish() + } } #[inline] -#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")] +#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] pub fn get_root_as_slot_status_info<'a>(buf: &'a [u8]) -> SlotStatusInfo<'a> { - unsafe { flatbuffers::root_unchecked::>(buf) } + unsafe { flatbuffers::root_unchecked::>(buf) } } #[inline] -#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")] +#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] pub fn get_size_prefixed_root_as_slot_status_info<'a>(buf: &'a [u8]) -> SlotStatusInfo<'a> { - unsafe { flatbuffers::size_prefixed_root_unchecked::>(buf) } + unsafe { flatbuffers::size_prefixed_root_unchecked::>(buf) } } #[inline] @@ -251,10 +255,8 @@ pub fn get_size_prefixed_root_as_slot_status_info<'a>(buf: &'a [u8]) -> SlotStat /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `root_as_slot_status_info_unchecked`. -pub fn root_as_slot_status_info( - buf: &[u8], -) -> Result { - flatbuffers::root::(buf) +pub fn root_as_slot_status_info(buf: &[u8]) -> Result { + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -263,10 +265,8 @@ pub fn root_as_slot_status_info( /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `size_prefixed_root_as_slot_status_info_unchecked`. -pub fn size_prefixed_root_as_slot_status_info( - buf: &[u8], -) -> Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_slot_status_info(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -276,10 +276,10 @@ pub fn size_prefixed_root_as_slot_status_info( /// previous, unchecked, behavior use /// `root_as_slot_status_info_unchecked`. pub fn root_as_slot_status_info_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -289,37 +289,33 @@ pub fn root_as_slot_status_info_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_slot_status_info_unchecked`. pub fn size_prefixed_root_as_slot_status_info_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a SlotStatusInfo and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `SlotStatusInfo`. pub unsafe fn root_as_slot_status_info_unchecked(buf: &[u8]) -> SlotStatusInfo { - flatbuffers::root_unchecked::(buf) + flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed SlotStatusInfo and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `SlotStatusInfo`. pub unsafe fn size_prefixed_root_as_slot_status_info_unchecked(buf: &[u8]) -> SlotStatusInfo { - flatbuffers::size_prefixed_root_unchecked::(buf) + flatbuffers::size_prefixed_root_unchecked::(buf) } #[inline] pub fn finish_slot_status_info_buffer<'a, 'b>( fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish(root, None); + root: flatbuffers::WIPOffset>) { + fbb.finish(root, None); } #[inline] -pub fn finish_size_prefixed_slot_status_info_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); +pub fn finish_size_prefixed_slot_status_info_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, None); } diff --git a/plerkle_serialization/src/transaction_info_generated.rs b/plerkle_serialization/src/transaction_info_generated.rs index 6c63f924..2ee84144 100644 --- a/plerkle_serialization/src/transaction_info_generated.rs +++ b/plerkle_serialization/src/transaction_info_generated.rs @@ -1,448 +1,326 @@ // automatically generated by the FlatBuffers compiler, do not modify -// @generated -use crate::{common_generated::*, compiled_instruction_generated::*}; +// @generated +use crate::compiled_instruction_generated::*; +use crate::common_generated::*; +use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; - +use self::flatbuffers::{EndianScalar, Follow}; pub enum TransactionInfoOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TransactionInfo<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for TransactionInfo<'a> { - type Inner = TransactionInfo<'a>; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table { buf, loc }, - } - } + type Inner = TransactionInfo<'a>; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table { buf, loc } } + } } impl<'a> TransactionInfo<'a> { - pub const VT_IS_VOTE: flatbuffers::VOffsetT = 4; - pub const VT_ACCOUNT_KEYS: flatbuffers::VOffsetT = 6; - pub const VT_LOG_MESSAGES: flatbuffers::VOffsetT = 8; - pub const VT_INNER_INSTRUCTIONS: flatbuffers::VOffsetT = 10; - pub const VT_OUTER_INSTRUCTIONS: flatbuffers::VOffsetT = 12; - pub const VT_SLOT: flatbuffers::VOffsetT = 14; - pub const VT_SLOT_INDEX: flatbuffers::VOffsetT = 16; - pub const VT_SEEN_AT: flatbuffers::VOffsetT = 18; + pub const VT_IS_VOTE: flatbuffers::VOffsetT = 4; + pub const VT_ACCOUNT_KEYS: flatbuffers::VOffsetT = 6; + pub const VT_LOG_MESSAGES: flatbuffers::VOffsetT = 8; + pub const VT_INNER_INSTRUCTIONS: flatbuffers::VOffsetT = 10; + pub const VT_OUTER_INSTRUCTIONS: flatbuffers::VOffsetT = 12; + pub const VT_SLOT: flatbuffers::VOffsetT = 14; + pub const VT_SLOT_INDEX: flatbuffers::VOffsetT = 16; + pub const VT_SEEN_AT: flatbuffers::VOffsetT = 18; - #[inline] - pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - TransactionInfo { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args TransactionInfoArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = TransactionInfoBuilder::new(_fbb); - builder.add_seen_at(args.seen_at); - builder.add_slot(args.slot); - if let Some(x) = args.slot_index { - builder.add_slot_index(x); - } - if let Some(x) = args.outer_instructions { - builder.add_outer_instructions(x); - } - if let Some(x) = args.inner_instructions { - builder.add_inner_instructions(x); - } - if let Some(x) = args.log_messages { - builder.add_log_messages(x); - } - if let Some(x) = args.account_keys { - builder.add_account_keys(x); - } - builder.add_is_vote(args.is_vote); - builder.finish() - } + #[inline] + pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + TransactionInfo { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args TransactionInfoArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = TransactionInfoBuilder::new(_fbb); + builder.add_seen_at(args.seen_at); + builder.add_slot(args.slot); + if let Some(x) = args.slot_index { builder.add_slot_index(x); } + if let Some(x) = args.outer_instructions { builder.add_outer_instructions(x); } + if let Some(x) = args.inner_instructions { builder.add_inner_instructions(x); } + if let Some(x) = args.log_messages { builder.add_log_messages(x); } + if let Some(x) = args.account_keys { builder.add_account_keys(x); } + builder.add_is_vote(args.is_vote); + builder.finish() + } - #[inline] - pub fn is_vote(&self) -> bool { - self._tab - .get::(TransactionInfo::VT_IS_VOTE, Some(false)) - .unwrap() - } - #[inline] - pub fn account_keys(&self) -> Option<&'a [Pubkey]> { - self._tab - .get::>>( - TransactionInfo::VT_ACCOUNT_KEYS, - None, - ) - .map(|v| v.safe_slice()) - } - #[inline] - pub fn log_messages( - &self, - ) -> Option>> { - self._tab.get::>, - >>(TransactionInfo::VT_LOG_MESSAGES, None) - } - #[inline] - pub fn inner_instructions( - &self, - ) -> Option>>> { - self._tab.get::>, - >>(TransactionInfo::VT_INNER_INSTRUCTIONS, None) - } - #[inline] - pub fn outer_instructions( - &self, - ) -> Option>>> - { - self._tab.get::>, - >>(TransactionInfo::VT_OUTER_INSTRUCTIONS, None) - } - #[inline] - pub fn slot(&self) -> u64 { - self._tab - .get::(TransactionInfo::VT_SLOT, Some(0)) - .unwrap() - } - #[inline] - pub fn slot_index(&self) -> Option<&'a str> { - self._tab - .get::>(TransactionInfo::VT_SLOT_INDEX, None) - } - #[inline] - pub fn seen_at(&self) -> i64 { - self._tab - .get::(TransactionInfo::VT_SEEN_AT, Some(0)) - .unwrap() - } + + #[inline] + pub fn is_vote(&self) -> bool { + self._tab.get::(TransactionInfo::VT_IS_VOTE, Some(false)).unwrap() + } + #[inline] + pub fn account_keys(&self) -> Option<&'a [Pubkey]> { + self._tab.get::>>(TransactionInfo::VT_ACCOUNT_KEYS, None).map(|v| v.safe_slice()) + } + #[inline] + pub fn log_messages(&self) -> Option>> { + self._tab.get::>>>(TransactionInfo::VT_LOG_MESSAGES, None) + } + #[inline] + pub fn inner_instructions(&self) -> Option>>> { + self._tab.get::>>>(TransactionInfo::VT_INNER_INSTRUCTIONS, None) + } + #[inline] + pub fn outer_instructions(&self) -> Option>>> { + self._tab.get::>>>(TransactionInfo::VT_OUTER_INSTRUCTIONS, None) + } + #[inline] + pub fn slot(&self) -> u64 { + self._tab.get::(TransactionInfo::VT_SLOT, Some(0)).unwrap() + } + #[inline] + pub fn slot_index(&self) -> Option<&'a str> { + self._tab.get::>(TransactionInfo::VT_SLOT_INDEX, None) + } + #[inline] + pub fn seen_at(&self) -> i64 { + self._tab.get::(TransactionInfo::VT_SEEN_AT, Some(0)).unwrap() + } } impl flatbuffers::Verifiable for TransactionInfo<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - - v.visit_table(pos)? - .visit_field::("is_vote", Self::VT_IS_VOTE, false)? - .visit_field::>>( - "account_keys", - Self::VT_ACCOUNT_KEYS, - false, - )? - .visit_field::>, - >>("log_messages", Self::VT_LOG_MESSAGES, false)? - .visit_field::>, - >>("inner_instructions", Self::VT_INNER_INSTRUCTIONS, false)? - .visit_field::>, - >>("outer_instructions", Self::VT_OUTER_INSTRUCTIONS, false)? - .visit_field::("slot", Self::VT_SLOT, false)? - .visit_field::>( - "slot_index", - Self::VT_SLOT_INDEX, - false, - )? - .visit_field::("seen_at", Self::VT_SEEN_AT, false)? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("is_vote", Self::VT_IS_VOTE, false)? + .visit_field::>>("account_keys", Self::VT_ACCOUNT_KEYS, false)? + .visit_field::>>>("log_messages", Self::VT_LOG_MESSAGES, false)? + .visit_field::>>>("inner_instructions", Self::VT_INNER_INSTRUCTIONS, false)? + .visit_field::>>>("outer_instructions", Self::VT_OUTER_INSTRUCTIONS, false)? + .visit_field::("slot", Self::VT_SLOT, false)? + .visit_field::>("slot_index", Self::VT_SLOT_INDEX, false)? + .visit_field::("seen_at", Self::VT_SEEN_AT, false)? + .finish(); + Ok(()) + } } pub struct TransactionInfoArgs<'a> { pub is_vote: bool, pub account_keys: Option>>, - pub log_messages: Option< - flatbuffers::WIPOffset>>, - >, - pub inner_instructions: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub outer_instructions: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, + pub log_messages: Option>>>, + pub inner_instructions: Option>>>>, + pub outer_instructions: Option>>>>, pub slot: u64, pub slot_index: Option>, pub seen_at: i64, } impl<'a> Default for TransactionInfoArgs<'a> { - #[inline] - fn default() -> Self { - TransactionInfoArgs { - is_vote: false, - account_keys: None, - log_messages: None, - inner_instructions: None, - outer_instructions: None, - slot: 0, - slot_index: None, - seen_at: 0, - } - } + #[inline] + fn default() -> Self { + TransactionInfoArgs { + is_vote: false, + account_keys: None, + log_messages: None, + inner_instructions: None, + outer_instructions: None, + slot: 0, + slot_index: None, + seen_at: 0, + } + } } pub struct TransactionInfoBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, } impl<'a: 'b, 'b> TransactionInfoBuilder<'a, 'b> { - #[inline] - pub fn add_is_vote(&mut self, is_vote: bool) { - self.fbb_ - .push_slot::(TransactionInfo::VT_IS_VOTE, is_vote, false); - } - #[inline] - pub fn add_account_keys( - &mut self, - account_keys: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - TransactionInfo::VT_ACCOUNT_KEYS, - account_keys, - ); - } - #[inline] - pub fn add_log_messages( - &mut self, - log_messages: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<&'b str>>, - >, - ) { - self.fbb_.push_slot_always::>( - TransactionInfo::VT_LOG_MESSAGES, - log_messages, - ); - } - #[inline] - pub fn add_inner_instructions( - &mut self, - inner_instructions: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_.push_slot_always::>( - TransactionInfo::VT_INNER_INSTRUCTIONS, - inner_instructions, - ); - } - #[inline] - pub fn add_outer_instructions( - &mut self, - outer_instructions: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_.push_slot_always::>( - TransactionInfo::VT_OUTER_INSTRUCTIONS, - outer_instructions, - ); - } - #[inline] - pub fn add_slot(&mut self, slot: u64) { - self.fbb_ - .push_slot::(TransactionInfo::VT_SLOT, slot, 0); - } - #[inline] - pub fn add_slot_index(&mut self, slot_index: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>( - TransactionInfo::VT_SLOT_INDEX, - slot_index, - ); - } - #[inline] - pub fn add_seen_at(&mut self, seen_at: i64) { - self.fbb_ - .push_slot::(TransactionInfo::VT_SEEN_AT, seen_at, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TransactionInfoBuilder<'a, 'b> { - let start = _fbb.start_table(); - TransactionInfoBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) - } + #[inline] + pub fn add_is_vote(&mut self, is_vote: bool) { + self.fbb_.push_slot::(TransactionInfo::VT_IS_VOTE, is_vote, false); + } + #[inline] + pub fn add_account_keys(&mut self, account_keys: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(TransactionInfo::VT_ACCOUNT_KEYS, account_keys); + } + #[inline] + pub fn add_log_messages(&mut self, log_messages: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(TransactionInfo::VT_LOG_MESSAGES, log_messages); + } + #[inline] + pub fn add_inner_instructions(&mut self, inner_instructions: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(TransactionInfo::VT_INNER_INSTRUCTIONS, inner_instructions); + } + #[inline] + pub fn add_outer_instructions(&mut self, outer_instructions: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(TransactionInfo::VT_OUTER_INSTRUCTIONS, outer_instructions); + } + #[inline] + pub fn add_slot(&mut self, slot: u64) { + self.fbb_.push_slot::(TransactionInfo::VT_SLOT, slot, 0); + } + #[inline] + pub fn add_slot_index(&mut self, slot_index: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(TransactionInfo::VT_SLOT_INDEX, slot_index); + } + #[inline] + pub fn add_seen_at(&mut self, seen_at: i64) { + self.fbb_.push_slot::(TransactionInfo::VT_SEEN_AT, seen_at, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TransactionInfoBuilder<'a, 'b> { + let start = _fbb.start_table(); + TransactionInfoBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for TransactionInfo<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("TransactionInfo"); - ds.field("is_vote", &self.is_vote()); - ds.field("account_keys", &self.account_keys()); - ds.field("log_messages", &self.log_messages()); - ds.field("inner_instructions", &self.inner_instructions()); - ds.field("outer_instructions", &self.outer_instructions()); - ds.field("slot", &self.slot()); - ds.field("slot_index", &self.slot_index()); - ds.field("seen_at", &self.seen_at()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("TransactionInfo"); + ds.field("is_vote", &self.is_vote()); + ds.field("account_keys", &self.account_keys()); + ds.field("log_messages", &self.log_messages()); + ds.field("inner_instructions", &self.inner_instructions()); + ds.field("outer_instructions", &self.outer_instructions()); + ds.field("slot", &self.slot()); + ds.field("slot_index", &self.slot_index()); + ds.field("seen_at", &self.seen_at()); + ds.finish() + } } pub enum InnerInstructionsOffset {} #[derive(Copy, Clone, PartialEq)] pub struct InnerInstructions<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for InnerInstructions<'a> { - type Inner = InnerInstructions<'a>; - #[inline] - fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table { buf, loc }, - } - } + type Inner = InnerInstructions<'a>; + #[inline] + fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table { buf, loc } } + } } impl<'a> InnerInstructions<'a> { - pub const VT_INDEX: flatbuffers::VOffsetT = 4; - pub const VT_INSTRUCTIONS: flatbuffers::VOffsetT = 6; + pub const VT_INDEX: flatbuffers::VOffsetT = 4; + pub const VT_INSTRUCTIONS: flatbuffers::VOffsetT = 6; - #[inline] - pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - InnerInstructions { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args InnerInstructionsArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = InnerInstructionsBuilder::new(_fbb); - if let Some(x) = args.instructions { - builder.add_instructions(x); - } - builder.add_index(args.index); - builder.finish() - } + #[inline] + pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + InnerInstructions { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args InnerInstructionsArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = InnerInstructionsBuilder::new(_fbb); + if let Some(x) = args.instructions { builder.add_instructions(x); } + builder.add_index(args.index); + builder.finish() + } - #[inline] - pub fn index(&self) -> u8 { - self._tab - .get::(InnerInstructions::VT_INDEX, Some(0)) - .unwrap() - } - #[inline] - pub fn instructions( - &self, - ) -> Option>>> - { - self._tab.get::>, - >>(InnerInstructions::VT_INSTRUCTIONS, None) - } + + #[inline] + pub fn index(&self) -> u8 { + self._tab.get::(InnerInstructions::VT_INDEX, Some(0)).unwrap() + } + #[inline] + pub fn instructions(&self) -> Option>>> { + self._tab.get::>>>(InnerInstructions::VT_INSTRUCTIONS, None) + } } impl flatbuffers::Verifiable for InnerInstructions<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - - v.visit_table(pos)? - .visit_field::("index", Self::VT_INDEX, false)? - .visit_field::>, - >>("instructions", Self::VT_INSTRUCTIONS, false)? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("index", Self::VT_INDEX, false)? + .visit_field::>>>("instructions", Self::VT_INSTRUCTIONS, false)? + .finish(); + Ok(()) + } } pub struct InnerInstructionsArgs<'a> { pub index: u8, - pub instructions: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, + pub instructions: Option>>>>, } impl<'a> Default for InnerInstructionsArgs<'a> { - #[inline] - fn default() -> Self { - InnerInstructionsArgs { - index: 0, - instructions: None, - } + #[inline] + fn default() -> Self { + InnerInstructionsArgs { + index: 0, + instructions: None, } + } } pub struct InnerInstructionsBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, } impl<'a: 'b, 'b> InnerInstructionsBuilder<'a, 'b> { - #[inline] - pub fn add_index(&mut self, index: u8) { - self.fbb_ - .push_slot::(InnerInstructions::VT_INDEX, index, 0); - } - #[inline] - pub fn add_instructions( - &mut self, - instructions: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_.push_slot_always::>( - InnerInstructions::VT_INSTRUCTIONS, - instructions, - ); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - ) -> InnerInstructionsBuilder<'a, 'b> { - let start = _fbb.start_table(); - InnerInstructionsBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) - } + #[inline] + pub fn add_index(&mut self, index: u8) { + self.fbb_.push_slot::(InnerInstructions::VT_INDEX, index, 0); + } + #[inline] + pub fn add_instructions(&mut self, instructions: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(InnerInstructions::VT_INSTRUCTIONS, instructions); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> InnerInstructionsBuilder<'a, 'b> { + let start = _fbb.start_table(); + InnerInstructionsBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for InnerInstructions<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("InnerInstructions"); - ds.field("index", &self.index()); - ds.field("instructions", &self.instructions()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("InnerInstructions"); + ds.field("index", &self.index()); + ds.field("instructions", &self.instructions()); + ds.finish() + } } #[inline] -#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")] +#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] pub fn get_root_as_transaction_info<'a>(buf: &'a [u8]) -> TransactionInfo<'a> { - unsafe { flatbuffers::root_unchecked::>(buf) } + unsafe { flatbuffers::root_unchecked::>(buf) } } #[inline] -#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")] +#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] pub fn get_size_prefixed_root_as_transaction_info<'a>(buf: &'a [u8]) -> TransactionInfo<'a> { - unsafe { flatbuffers::size_prefixed_root_unchecked::>(buf) } + unsafe { flatbuffers::size_prefixed_root_unchecked::>(buf) } } #[inline] @@ -452,10 +330,8 @@ pub fn get_size_prefixed_root_as_transaction_info<'a>(buf: &'a [u8]) -> Transact /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `root_as_transaction_info_unchecked`. -pub fn root_as_transaction_info( - buf: &[u8], -) -> Result { - flatbuffers::root::(buf) +pub fn root_as_transaction_info(buf: &[u8]) -> Result { + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -464,10 +340,8 @@ pub fn root_as_transaction_info( /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `size_prefixed_root_as_transaction_info_unchecked`. -pub fn size_prefixed_root_as_transaction_info( - buf: &[u8], -) -> Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_transaction_info(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -477,10 +351,10 @@ pub fn size_prefixed_root_as_transaction_info( /// previous, unchecked, behavior use /// `root_as_transaction_info_unchecked`. pub fn root_as_transaction_info_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -490,37 +364,33 @@ pub fn root_as_transaction_info_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_transaction_info_unchecked`. pub fn size_prefixed_root_as_transaction_info_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a TransactionInfo and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `TransactionInfo`. pub unsafe fn root_as_transaction_info_unchecked(buf: &[u8]) -> TransactionInfo { - flatbuffers::root_unchecked::(buf) + flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed TransactionInfo and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `TransactionInfo`. pub unsafe fn size_prefixed_root_as_transaction_info_unchecked(buf: &[u8]) -> TransactionInfo { - flatbuffers::size_prefixed_root_unchecked::(buf) + flatbuffers::size_prefixed_root_unchecked::(buf) } #[inline] pub fn finish_transaction_info_buffer<'a, 'b>( fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish(root, None); + root: flatbuffers::WIPOffset>) { + fbb.finish(root, None); } #[inline] -pub fn finish_size_prefixed_transaction_info_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); +pub fn finish_size_prefixed_transaction_info_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, None); }