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
impl LedgerDB
Sourcepub fn with_path(path: impl AsRef<Path>) -> Result<Self, Error>
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
.
Sourcepub fn get_next_items_numbers(&self) -> ItemNumbers
pub fn get_next_items_numbers(&self) -> ItemNumbers
Get the next slot, block, transaction, and event numbers
Sourcepub fn commit_slot<S: SlotData, B: Serialize, T: Serialize>(
&self,
data_to_commit: SlotCommit<S, B, T>,
) -> Result<(), Error>
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.
Sourcepub fn get_head_slot(&self) -> Result<Option<(SlotNumber, StoredSlot)>>
pub fn get_head_slot(&self) -> Result<Option<(SlotNumber, StoredSlot)>>
Get the most recent committed slot, if any
Trait Implementations§
Source§impl LedgerRpcProvider for LedgerDB
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
Auto Trait Implementations§
impl Freeze for LedgerDB
impl !RefUnwindSafe for LedgerDB
impl Send for LedgerDB
impl Sync for LedgerDB
impl Unpin for LedgerDB
impl !UnwindSafe for LedgerDB
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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