Struct LedgerDB

Source
pub struct LedgerDB { /* private fields */ }
Expand description

A database which stores the ledger history (slots, transactions, events, etc). Ledger data is first ingested into an in-memory map before being fed to the state-transition function. Once the state-transition function has been executed and finalized, the results are committed to the final db

Implementations§

Source§

impl LedgerDB

Source

pub fn with_path(path: impl AsRef<Path>) -> Result<Self, Error>

Open a LedgerDB (backed by RocksDB) at the specified path. The returned instance will be at the path {path}/ledger-db.

Source

pub fn get_next_items_numbers(&self) -> ItemNumbers

Get the next slot, block, transaction, and event numbers

Source

pub fn commit_slot<S: SlotData, B: Serialize, T: Serialize>( &self, data_to_commit: SlotCommit<S, B, T>, ) -> Result<(), Error>

Commits a slot to the database by inserting its events, transactions, and batches before inserting the slot metadata.

Source

pub fn get_head_slot(&self) -> Result<Option<(SlotNumber, StoredSlot)>>

Get the most recent committed slot, if any

Trait Implementations§

Source§

impl Clone for LedgerDB

Source§

fn clone(&self) -> LedgerDB

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LedgerDB

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl LedgerRpcProvider for LedgerDB

Source§

fn get_slots<B: DeserializeOwned, T: DeserializeOwned>( &self, slot_ids: &[SlotIdentifier], query_mode: QueryMode, ) -> Result<Vec<Option<SlotResponse<B, T>>>, Error>

Get a list of slots by id. The IDs need not be ordered.
Source§

fn get_batches<B: DeserializeOwned, T: DeserializeOwned>( &self, batch_ids: &[BatchIdentifier], query_mode: QueryMode, ) -> Result<Vec<Option<BatchResponse<B, T>>>, Error>

Get a list of batches by id. The IDs need not be ordered.
Source§

fn get_transactions<T: DeserializeOwned>( &self, tx_ids: &[TxIdentifier], _query_mode: QueryMode, ) -> Result<Vec<Option<TxResponse<T>>>, Error>

Get a list of transactions by id. The IDs need not be ordered.
Source§

fn get_events( &self, event_ids: &[EventIdentifier], ) -> Result<Vec<Option<Event>>, Error>

Get events by id. The IDs need not be ordered.
Source§

fn get_head<B: DeserializeOwned, T: DeserializeOwned>( &self, query_mode: QueryMode, ) -> Result<Option<SlotResponse<B, T>>, Error>

Get the latest slot in the ledger.
Source§

fn get_slot_by_hash<B: DeserializeOwned, T: DeserializeOwned>( &self, hash: &[u8; 32], query_mode: QueryMode, ) -> Result<Option<SlotResponse<B, T>>, Error>

Get a single slot by hash.
Source§

fn get_batch_by_hash<B: DeserializeOwned, T: DeserializeOwned>( &self, hash: &[u8; 32], query_mode: QueryMode, ) -> Result<Option<BatchResponse<B, T>>, Error>

Get a single batch by hash.
Source§

fn get_tx_by_hash<T: DeserializeOwned>( &self, hash: &[u8; 32], query_mode: QueryMode, ) -> Result<Option<TxResponse<T>>, Error>

Get a single transaction by hash.
Source§

fn get_slot_by_number<B: DeserializeOwned, T: DeserializeOwned>( &self, number: u64, query_mode: QueryMode, ) -> Result<Option<SlotResponse<B, T>>, Error>

Get a single slot by number.
Source§

fn get_batch_by_number<B: DeserializeOwned, T: DeserializeOwned>( &self, number: u64, query_mode: QueryMode, ) -> Result<Option<BatchResponse<B, T>>, Error>

Get a single batch by number.
Source§

fn get_tx_by_number<T: DeserializeOwned>( &self, number: u64, query_mode: QueryMode, ) -> Result<Option<TxResponse<T>>, Error>

Get a single tx by number.
Source§

fn get_event_by_number(&self, number: u64) -> Result<Option<Event>, Error>

Get a single event by number.
Source§

fn get_slots_range<B: DeserializeOwned, T: DeserializeOwned>( &self, start: u64, end: u64, query_mode: QueryMode, ) -> Result<Vec<Option<SlotResponse<B, T>>>, Error>

Get a range of slots. This query is the most efficient way to fetch large numbers of slots, since it allows for easy batching of db queries for adjacent items.
Source§

fn get_batches_range<B: DeserializeOwned, T: DeserializeOwned>( &self, start: u64, end: u64, query_mode: QueryMode, ) -> Result<Vec<Option<BatchResponse<B, T>>>, Error>

Get a range of batches. This query is the most efficient way to fetch large numbers of batches, since it allows for easy batching of db queries for adjacent items.
Source§

fn get_transactions_range<T: DeserializeOwned>( &self, start: u64, end: u64, query_mode: QueryMode, ) -> Result<Vec<Option<TxResponse<T>>>, Error>

Get a range of batches. This query is the most efficient way to fetch large numbers of transactions, since it allows for easy batching of db queries for adjacent items.
Source§

fn subscribe_slots(&self) -> Result<Receiver<u64>, Error>

Get a notification each time a slot is processed

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more