pub struct BlockchainCacheDatabase { /* private fields */ }Expand description
Database interface for persisting and retrieving blockchain entities and domain objects.
Implementations§
Source§impl BlockchainCacheDatabase
impl BlockchainCacheDatabase
Sourcepub async fn init(pg_options: PgConnectOptions) -> Self
pub async fn init(pg_options: PgConnectOptions) -> Self
Initializes a new database instance by establishing a connection to PostgreSQL.
Sourcepub async fn seed_chain(&self, chain: &Chain) -> Result<()>
pub async fn seed_chain(&self, chain: &Chain) -> Result<()>
Seeds the database with a blockchain chain record.
Sourcepub async fn add_block(&self, chain_id: u32, block: &Block) -> Result<()>
pub async fn add_block(&self, chain_id: u32, block: &Block) -> Result<()>
Inserts or updates a block record in the database.
Sourcepub async fn load_block_timestamps(
&self,
chain: SharedChain,
from_block: u64,
) -> Result<Vec<BlockTimestampRow>>
pub async fn load_block_timestamps( &self, chain: SharedChain, from_block: u64, ) -> Result<Vec<BlockTimestampRow>>
Retrieves block timestamps for a given chain starting from a specific block number.
Sourcepub async fn add_dex(&self, dex: &Dex) -> Result<()>
pub async fn add_dex(&self, dex: &Dex) -> Result<()>
Adds or updates a DEX (Decentralized Exchange) record in the database.
Sourcepub async fn add_pool(&self, pool: &Pool) -> Result<()>
pub async fn add_pool(&self, pool: &Pool) -> Result<()>
Adds or updates a liquidity pool/pair record in the database.
Sourcepub async fn add_token(&self, token: &Token) -> Result<()>
pub async fn add_token(&self, token: &Token) -> Result<()>
Adds or updates a token record in the database.
Sourcepub async fn add_swap(&self, chain_id: u32, swap: &PoolSwap) -> Result<()>
pub async fn add_swap(&self, chain_id: u32, swap: &PoolSwap) -> Result<()>
Persists a token swap transaction event to the pool_swap table.
Sourcepub async fn add_pool_liquidity_update(
&self,
chain_id: u32,
liquidity_update: &PoolLiquidityUpdate,
) -> Result<()>
pub async fn add_pool_liquidity_update( &self, chain_id: u32, liquidity_update: &PoolLiquidityUpdate, ) -> Result<()>
Persists a liquidity position change (mint/burn) event to the pool_liquidity table.
Sourcepub async fn load_tokens(&self, chain: SharedChain) -> Result<Vec<Token>>
pub async fn load_tokens(&self, chain: SharedChain) -> Result<Vec<Token>>
Retrieves all token records for the given chain and converts them into Token domain objects.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BlockchainCacheDatabase
impl !RefUnwindSafe for BlockchainCacheDatabase
impl Send for BlockchainCacheDatabase
impl Sync for BlockchainCacheDatabase
impl Unpin for BlockchainCacheDatabase
impl !UnwindSafe for BlockchainCacheDatabase
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
§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> 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>
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