-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
405 additions
and
312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/target | ||
target | ||
test-ledger | ||
/.history | ||
/config.json | ||
.history | ||
config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace AccountData; | ||
|
||
table AccountData { | ||
lamports: ulong; | ||
rent_epoch: ulong; | ||
executable: bool; | ||
version: ulong; | ||
data: [ubyte]; | ||
} | ||
|
||
root_type AccountData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,293 @@ | ||
// automatically generated by the FlatBuffers compiler, do not modify | ||
|
||
// @generated | ||
|
||
extern crate flatbuffers; | ||
|
||
#[allow(unused_imports, dead_code)] | ||
pub mod account_data { | ||
|
||
use core::cmp::Ordering; | ||
use core::mem; | ||
|
||
extern crate flatbuffers; | ||
use self::flatbuffers::{EndianScalar, Follow}; | ||
|
||
pub enum AccountDataOffset {} | ||
#[derive(Copy, Clone, PartialEq)] | ||
|
||
pub struct AccountData<'a> { | ||
pub _tab: flatbuffers::Table<'a>, | ||
} | ||
|
||
impl<'a> flatbuffers::Follow<'a> for AccountData<'a> { | ||
type Inner = AccountData<'a>; | ||
#[inline] | ||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { | ||
Self { | ||
_tab: flatbuffers::Table::new(buf, loc), | ||
} | ||
} | ||
} | ||
|
||
impl<'a> AccountData<'a> { | ||
pub const VT_LAMPORTS: flatbuffers::VOffsetT = 4; | ||
pub const VT_RENT_EPOCH: flatbuffers::VOffsetT = 6; | ||
pub const VT_EXECUTABLE: flatbuffers::VOffsetT = 8; | ||
pub const VT_VERSION: flatbuffers::VOffsetT = 10; | ||
pub const VT_DATA: flatbuffers::VOffsetT = 12; | ||
|
||
#[inline] | ||
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { | ||
AccountData { _tab: table } | ||
} | ||
#[allow(unused_mut)] | ||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( | ||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, | ||
args: &'args AccountDataArgs<'args>, | ||
) -> flatbuffers::WIPOffset<AccountData<'bldr>> { | ||
let mut builder = AccountDataBuilder::new(_fbb); | ||
builder.add_version(args.version); | ||
builder.add_rent_epoch(args.rent_epoch); | ||
builder.add_lamports(args.lamports); | ||
if let Some(x) = args.data { | ||
builder.add_data(x); | ||
} | ||
builder.add_executable(args.executable); | ||
builder.finish() | ||
} | ||
|
||
#[inline] | ||
pub fn lamports(&self) -> u64 { | ||
// Safety: | ||
// Created from valid Table for this object | ||
// which contains a valid value in this slot | ||
unsafe { | ||
self._tab | ||
.get::<u64>(AccountData::VT_LAMPORTS, Some(0)) | ||
.unwrap() | ||
} | ||
} | ||
#[inline] | ||
pub fn rent_epoch(&self) -> u64 { | ||
// Safety: | ||
// Created from valid Table for this object | ||
// which contains a valid value in this slot | ||
unsafe { | ||
self._tab | ||
.get::<u64>(AccountData::VT_RENT_EPOCH, Some(0)) | ||
.unwrap() | ||
} | ||
} | ||
#[inline] | ||
pub fn executable(&self) -> bool { | ||
// Safety: | ||
// Created from valid Table for this object | ||
// which contains a valid value in this slot | ||
unsafe { | ||
self._tab | ||
.get::<bool>(AccountData::VT_EXECUTABLE, Some(false)) | ||
.unwrap() | ||
} | ||
} | ||
#[inline] | ||
pub fn version(&self) -> u64 { | ||
// Safety: | ||
// Created from valid Table for this object | ||
// which contains a valid value in this slot | ||
unsafe { | ||
self._tab | ||
.get::<u64>(AccountData::VT_VERSION, Some(0)) | ||
.unwrap() | ||
} | ||
} | ||
#[inline] | ||
pub fn data(&self) -> Option<flatbuffers::Vector<'a, u8>> { | ||
// Safety: | ||
// Created from valid Table for this object | ||
// which contains a valid value in this slot | ||
unsafe { | ||
self._tab | ||
.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>( | ||
AccountData::VT_DATA, | ||
None, | ||
) | ||
} | ||
} | ||
} | ||
|
||
impl flatbuffers::Verifiable for AccountData<'_> { | ||
#[inline] | ||
fn run_verifier( | ||
v: &mut flatbuffers::Verifier, | ||
pos: usize, | ||
) -> Result<(), flatbuffers::InvalidFlatbuffer> { | ||
use self::flatbuffers::Verifiable; | ||
v.visit_table(pos)? | ||
.visit_field::<u64>("lamports", Self::VT_LAMPORTS, false)? | ||
.visit_field::<u64>("rent_epoch", Self::VT_RENT_EPOCH, false)? | ||
.visit_field::<bool>("executable", Self::VT_EXECUTABLE, false)? | ||
.visit_field::<u64>("version", Self::VT_VERSION, false)? | ||
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>( | ||
"data", | ||
Self::VT_DATA, | ||
false, | ||
)? | ||
.finish(); | ||
Ok(()) | ||
} | ||
} | ||
pub struct AccountDataArgs<'a> { | ||
pub lamports: u64, | ||
pub rent_epoch: u64, | ||
pub executable: bool, | ||
pub version: u64, | ||
pub data: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>, | ||
} | ||
impl<'a> Default for AccountDataArgs<'a> { | ||
#[inline] | ||
fn default() -> Self { | ||
AccountDataArgs { | ||
lamports: 0, | ||
rent_epoch: 0, | ||
executable: false, | ||
version: 0, | ||
data: None, | ||
} | ||
} | ||
} | ||
|
||
pub struct AccountDataBuilder<'a: 'b, 'b> { | ||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, | ||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>, | ||
} | ||
impl<'a: 'b, 'b> AccountDataBuilder<'a, 'b> { | ||
#[inline] | ||
pub fn add_lamports(&mut self, lamports: u64) { | ||
self.fbb_ | ||
.push_slot::<u64>(AccountData::VT_LAMPORTS, lamports, 0); | ||
} | ||
#[inline] | ||
pub fn add_rent_epoch(&mut self, rent_epoch: u64) { | ||
self.fbb_ | ||
.push_slot::<u64>(AccountData::VT_RENT_EPOCH, rent_epoch, 0); | ||
} | ||
#[inline] | ||
pub fn add_executable(&mut self, executable: bool) { | ||
self.fbb_ | ||
.push_slot::<bool>(AccountData::VT_EXECUTABLE, executable, false); | ||
} | ||
#[inline] | ||
pub fn add_version(&mut self, version: u64) { | ||
self.fbb_ | ||
.push_slot::<u64>(AccountData::VT_VERSION, version, 0); | ||
} | ||
#[inline] | ||
pub fn add_data(&mut self, data: flatbuffers::WIPOffset<flatbuffers::Vector<'b, u8>>) { | ||
self.fbb_ | ||
.push_slot_always::<flatbuffers::WIPOffset<_>>(AccountData::VT_DATA, data); | ||
} | ||
#[inline] | ||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AccountDataBuilder<'a, 'b> { | ||
let start = _fbb.start_table(); | ||
AccountDataBuilder { | ||
fbb_: _fbb, | ||
start_: start, | ||
} | ||
} | ||
#[inline] | ||
pub fn finish(self) -> flatbuffers::WIPOffset<AccountData<'a>> { | ||
let o = self.fbb_.end_table(self.start_); | ||
flatbuffers::WIPOffset::new(o.value()) | ||
} | ||
} | ||
|
||
impl core::fmt::Debug for AccountData<'_> { | ||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
let mut ds = f.debug_struct("AccountData"); | ||
ds.field("lamports", &self.lamports()); | ||
ds.field("rent_epoch", &self.rent_epoch()); | ||
ds.field("executable", &self.executable()); | ||
ds.field("version", &self.version()); | ||
ds.field("data", &self.data()); | ||
ds.finish() | ||
} | ||
} | ||
#[inline] | ||
/// Verifies that a buffer of bytes contains a `AccountData` | ||
/// and returns it. | ||
/// Note that verification is still experimental and may not | ||
/// catch every error, or be maximally performant. For the | ||
/// previous, unchecked, behavior use | ||
/// `root_as_account_data_unchecked`. | ||
pub fn root_as_account_data(buf: &[u8]) -> Result<AccountData, flatbuffers::InvalidFlatbuffer> { | ||
flatbuffers::root::<AccountData>(buf) | ||
} | ||
#[inline] | ||
/// Verifies that a buffer of bytes contains a size prefixed | ||
/// `AccountData` and returns it. | ||
/// Note that verification is still experimental and may not | ||
/// catch every error, or be maximally performant. For the | ||
/// previous, unchecked, behavior use | ||
/// `size_prefixed_root_as_account_data_unchecked`. | ||
pub fn size_prefixed_root_as_account_data( | ||
buf: &[u8], | ||
) -> Result<AccountData, flatbuffers::InvalidFlatbuffer> { | ||
flatbuffers::size_prefixed_root::<AccountData>(buf) | ||
} | ||
#[inline] | ||
/// Verifies, with the given options, that a buffer of bytes | ||
/// contains a `AccountData` and returns it. | ||
/// Note that verification is still experimental and may not | ||
/// catch every error, or be maximally performant. For the | ||
/// previous, unchecked, behavior use | ||
/// `root_as_account_data_unchecked`. | ||
pub fn root_as_account_data_with_opts<'b, 'o>( | ||
opts: &'o flatbuffers::VerifierOptions, | ||
buf: &'b [u8], | ||
) -> Result<AccountData<'b>, flatbuffers::InvalidFlatbuffer> { | ||
flatbuffers::root_with_opts::<AccountData<'b>>(opts, buf) | ||
} | ||
#[inline] | ||
/// Verifies, with the given verifier options, that a buffer of | ||
/// bytes contains a size prefixed `AccountData` and returns | ||
/// it. Note that verification is still experimental and may not | ||
/// catch every error, or be maximally performant. For the | ||
/// previous, unchecked, behavior use | ||
/// `root_as_account_data_unchecked`. | ||
pub fn size_prefixed_root_as_account_data_with_opts<'b, 'o>( | ||
opts: &'o flatbuffers::VerifierOptions, | ||
buf: &'b [u8], | ||
) -> Result<AccountData<'b>, flatbuffers::InvalidFlatbuffer> { | ||
flatbuffers::size_prefixed_root_with_opts::<AccountData<'b>>(opts, buf) | ||
} | ||
#[inline] | ||
/// Assumes, without verification, that a buffer of bytes contains a AccountData and returns it. | ||
/// # Safety | ||
/// Callers must trust the given bytes do indeed contain a valid `AccountData`. | ||
pub unsafe fn root_as_account_data_unchecked(buf: &[u8]) -> AccountData { | ||
flatbuffers::root_unchecked::<AccountData>(buf) | ||
} | ||
#[inline] | ||
/// Assumes, without verification, that a buffer of bytes contains a size prefixed AccountData and returns it. | ||
/// # Safety | ||
/// Callers must trust the given bytes do indeed contain a valid size prefixed `AccountData`. | ||
pub unsafe fn size_prefixed_root_as_account_data_unchecked(buf: &[u8]) -> AccountData { | ||
flatbuffers::size_prefixed_root_unchecked::<AccountData>(buf) | ||
} | ||
#[inline] | ||
pub fn finish_account_data_buffer<'a, 'b>( | ||
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, | ||
root: flatbuffers::WIPOffset<AccountData<'a>>, | ||
) { | ||
fbb.finish(root, None); | ||
} | ||
|
||
#[inline] | ||
pub fn finish_size_prefixed_account_data_buffer<'a, 'b>( | ||
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, | ||
root: flatbuffers::WIPOffset<AccountData<'a>>, | ||
) { | ||
fbb.finish_size_prefixed(root, None); | ||
} | ||
} // pub mod AccountData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
namespace AccountInfoV2; | ||
namespace AccountInfo; | ||
|
||
table AccountInfoV2 { | ||
table AccountInfo { | ||
pubkey: string; | ||
owner: string; | ||
slot: uint64; | ||
account_data: AccountData; | ||
account_data: [uint8]; | ||
} | ||
|
||
table AccountData { | ||
lamports: ulong; | ||
rent_epoch: ulong; | ||
executable: bool; | ||
version: ulong; | ||
data: [ubyte]; | ||
} | ||
|
||
root_type AccountInfoV2; | ||
root_type AccountInfo; |
Oops, something went wrong.