pub struct CardanoTransactionRepository { /* private fields */ }
Expand description
§Cardano transaction repository
This is a business oriented layer to perform actions on the database through queries.
Implementations§
source§impl CardanoTransactionRepository
impl CardanoTransactionRepository
sourcepub fn new(connection_pool: Arc<SqliteConnectionPool>) -> Self
pub fn new(connection_pool: Arc<SqliteConnectionPool>) -> Self
Instantiate service
sourcepub async fn get_all_transactions(
&self,
) -> StdResult<Vec<CardanoTransactionRecord>>
pub async fn get_all_transactions( &self, ) -> StdResult<Vec<CardanoTransactionRecord>>
Return all the CardanoTransactionRecords in the database.
sourcepub async fn get_transactions_in_range_blocks(
&self,
range: Range<BlockNumber>,
) -> StdResult<Vec<CardanoTransactionRecord>>
pub async fn get_transactions_in_range_blocks( &self, range: Range<BlockNumber>, ) -> StdResult<Vec<CardanoTransactionRecord>>
Return all the CardanoTransactionRecords in the database where block number is in the given range.
sourcepub async fn get_transaction<T: Into<TransactionHash>>(
&self,
transaction_hash: T,
) -> StdResult<Option<CardanoTransactionRecord>>
pub async fn get_transaction<T: Into<TransactionHash>>( &self, transaction_hash: T, ) -> StdResult<Option<CardanoTransactionRecord>>
Return the CardanoTransactionRecord for the given transaction hash.
sourcepub async fn create_transaction<T: Into<TransactionHash>, U: Into<BlockHash>>(
&self,
transaction_hash: T,
block_number: BlockNumber,
slot_number: SlotNumber,
block_hash: U,
) -> StdResult<Option<CardanoTransactionRecord>>
pub async fn create_transaction<T: Into<TransactionHash>, U: Into<BlockHash>>( &self, transaction_hash: T, block_number: BlockNumber, slot_number: SlotNumber, block_hash: U, ) -> StdResult<Option<CardanoTransactionRecord>>
Create a new CardanoTransactionRecord in the database.
sourcepub async fn create_transactions<T: Into<CardanoTransactionRecord>>(
&self,
transactions: Vec<T>,
) -> StdResult<Vec<CardanoTransactionRecord>>
pub async fn create_transactions<T: Into<CardanoTransactionRecord>>( &self, transactions: Vec<T>, ) -> StdResult<Vec<CardanoTransactionRecord>>
Create new CardanoTransactionRecords in the database.
sourcepub async fn create_block_range_roots<T: Into<BlockRangeRootRecord>>(
&self,
block_ranges: Vec<T>,
) -> StdResult<Vec<BlockRangeRootRecord>>
pub async fn create_block_range_roots<T: Into<BlockRangeRootRecord>>( &self, block_ranges: Vec<T>, ) -> StdResult<Vec<BlockRangeRootRecord>>
Create new BlockRangeRootRecords in the database.
sourcepub async fn get_transaction_highest_chain_point(
&self,
) -> StdResult<Option<ChainPoint>>
pub async fn get_transaction_highest_chain_point( &self, ) -> StdResult<Option<ChainPoint>>
Get the highest ChainPoint of the cardano transactions stored in the database.
sourcepub async fn get_highest_start_block_number_for_block_range_roots(
&self,
) -> StdResult<Option<BlockNumber>>
pub async fn get_highest_start_block_number_for_block_range_roots( &self, ) -> StdResult<Option<BlockNumber>>
Get the highest start BlockNumber of the block range roots stored in the database.
sourcepub async fn retrieve_block_range_roots_up_to(
&self,
block_number: BlockNumber,
) -> StdResult<Box<dyn Iterator<Item = (BlockRange, MKTreeNode)> + '_>>
pub async fn retrieve_block_range_roots_up_to( &self, block_number: BlockNumber, ) -> StdResult<Box<dyn Iterator<Item = (BlockRange, MKTreeNode)> + '_>>
Retrieve all the Block Range Roots in database up to the block range that contains the given block number.
sourcepub async fn retrieve_highest_block_range_root(
&self,
) -> StdResult<Option<BlockRangeRootRecord>>
pub async fn retrieve_highest_block_range_root( &self, ) -> StdResult<Option<BlockRangeRootRecord>>
Retrieve the block range root with the highest bounds in the database.
sourcepub async fn get_all(&self) -> StdResult<Vec<CardanoTransaction>>
pub async fn get_all(&self) -> StdResult<Vec<CardanoTransaction>>
Retrieve all the CardanoTransaction in database.
sourcepub fn get_all_block_range_root(&self) -> StdResult<Vec<BlockRangeRootRecord>>
pub fn get_all_block_range_root(&self) -> StdResult<Vec<BlockRangeRootRecord>>
Retrieve all the BlockRangeRootRecord in database.
sourcepub async fn store_transactions<T: Into<CardanoTransactionRecord> + Clone>(
&self,
transactions: Vec<T>,
) -> StdResult<()>
pub async fn store_transactions<T: Into<CardanoTransactionRecord> + Clone>( &self, transactions: Vec<T>, ) -> StdResult<()>
Store the given transactions in the database.
The storage is done in chunks to avoid exceeding sqlite binding limitations.
sourcepub async fn get_closest_block_number_above_slot_number(
&self,
slot_number: SlotNumber,
) -> StdResult<Option<BlockNumber>>
pub async fn get_closest_block_number_above_slot_number( &self, slot_number: SlotNumber, ) -> StdResult<Option<BlockNumber>>
Get the closest block number above a given slot number
sourcepub async fn get_transaction_by_hashes<T: Into<TransactionHash>>(
&self,
hashes: Vec<T>,
up_to: BlockNumber,
) -> StdResult<Vec<CardanoTransactionRecord>>
pub async fn get_transaction_by_hashes<T: Into<TransactionHash>>( &self, hashes: Vec<T>, up_to: BlockNumber, ) -> StdResult<Vec<CardanoTransactionRecord>>
Get the CardanoTransactionRecord for the given transaction hashes, up to a block number
sourcepub async fn get_transaction_by_block_ranges(
&self,
block_ranges: Vec<BlockRange>,
) -> StdResult<Vec<CardanoTransactionRecord>>
pub async fn get_transaction_by_block_ranges( &self, block_ranges: Vec<BlockRange>, ) -> StdResult<Vec<CardanoTransactionRecord>>
Get the CardanoTransactionRecord for the given block ranges.
sourcepub async fn prune_transaction(
&self,
number_of_blocks_to_keep: BlockNumber,
) -> StdResult<()>
pub async fn prune_transaction( &self, number_of_blocks_to_keep: BlockNumber, ) -> StdResult<()>
Prune the transactions older than the given number of blocks (based on the block range root stored).
sourcepub async fn remove_rolled_back_transactions_and_block_range_by_block_number(
&self,
block_number: BlockNumber,
) -> StdResult<()>
pub async fn remove_rolled_back_transactions_and_block_range_by_block_number( &self, block_number: BlockNumber, ) -> StdResult<()>
Remove transactions and block range roots that are in a rolled-back fork
- Remove transactions with block number strictly greater than the given block number
- Remove block range roots that have lower bound range strictly above the given block number
sourcepub async fn remove_rolled_back_transactions_and_block_range_by_slot_number(
&self,
slot_number: SlotNumber,
) -> StdResult<()>
pub async fn remove_rolled_back_transactions_and_block_range_by_slot_number( &self, slot_number: SlotNumber, ) -> StdResult<()>
Remove transactions and block range roots that are in a rolled-back fork
- Remove transactions with closest block number strictly greater than the given slot number if exists
- Remove block range roots that have lower bound range strictly above the aforementioned block number
Trait Implementations§
source§impl<S: MKTreeStorer> BlockRangeRootRetriever<S> for CardanoTransactionRepository
impl<S: MKTreeStorer> BlockRangeRootRetriever<S> for CardanoTransactionRepository
source§fn retrieve_block_range_roots<'a, 'async_trait>(
&'a self,
up_to_beacon: BlockNumber,
) -> Pin<Box<dyn Future<Output = StdResult<Box<dyn Iterator<Item = (BlockRange, MKTreeNode)> + 'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn retrieve_block_range_roots<'a, 'async_trait>(
&'a self,
up_to_beacon: BlockNumber,
) -> Pin<Box<dyn Future<Output = StdResult<Box<dyn Iterator<Item = (BlockRange, MKTreeNode)> + 'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
source§fn compute_merkle_map_from_block_range_roots<'life0, 'async_trait>(
&'life0 self,
up_to_beacon: BlockNumber,
) -> Pin<Box<dyn Future<Output = Result<MKMap<BlockRange, MKMapNode<BlockRange, S>, S>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn compute_merkle_map_from_block_range_roots<'life0, 'async_trait>(
&'life0 self,
up_to_beacon: BlockNumber,
) -> Pin<Box<dyn Future<Output = Result<MKMap<BlockRange, MKMapNode<BlockRange, S>, S>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations§
impl Freeze for CardanoTransactionRepository
impl RefUnwindSafe for CardanoTransactionRepository
impl Send for CardanoTransactionRepository
impl Sync for CardanoTransactionRepository
impl Unpin for CardanoTransactionRepository
impl UnwindSafe for CardanoTransactionRepository
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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