mithril_persistence::database::repository

Struct CardanoTransactionRepository

source
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

source

pub fn new(connection_pool: Arc<SqliteConnectionPool>) -> Self

Instantiate service

source

pub async fn get_all_transactions( &self, ) -> StdResult<Vec<CardanoTransactionRecord>>

Return all the CardanoTransactionRecords in the database.

source

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.

source

pub async fn get_transaction<T: Into<TransactionHash>>( &self, transaction_hash: T, ) -> StdResult<Option<CardanoTransactionRecord>>

Return the CardanoTransactionRecord for the given transaction hash.

source

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.

source

pub async fn create_transactions<T: Into<CardanoTransactionRecord>>( &self, transactions: Vec<T>, ) -> StdResult<Vec<CardanoTransactionRecord>>

Create new CardanoTransactionRecords in the database.

source

pub async fn create_block_range_roots<T: Into<BlockRangeRootRecord>>( &self, block_ranges: Vec<T>, ) -> StdResult<Vec<BlockRangeRootRecord>>

Create new BlockRangeRootRecords in the database.

source

pub async fn get_transaction_highest_chain_point( &self, ) -> StdResult<Option<ChainPoint>>

Get the highest ChainPoint of the cardano transactions stored in the database.

source

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.

source

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.

source

pub async fn retrieve_highest_block_range_root( &self, ) -> StdResult<Option<BlockRangeRootRecord>>

Retrieve the block range root with the highest bounds in the database.

source

pub async fn get_all(&self) -> StdResult<Vec<CardanoTransaction>>

Retrieve all the CardanoTransaction in database.

source

pub fn get_all_block_range_root(&self) -> StdResult<Vec<BlockRangeRootRecord>>

Retrieve all the BlockRangeRootRecord in database.

source

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.

source

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

source

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

source

pub async fn get_transaction_by_block_ranges( &self, block_ranges: Vec<BlockRange>, ) -> StdResult<Vec<CardanoTransactionRecord>>

Get the CardanoTransactionRecord for the given block ranges.

source

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).

source

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
source

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

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,

Returns a Merkle map of the block ranges roots up to a given beacon
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,

Returns a Merkle map of the block ranges roots up to a given beacon

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> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,