pub struct Database {
connection: Pool<Postgres>,
}
Expand description
PostgreSQL database connection details.
Fields§
§connection: Pool<Postgres>
Implementations§
Source§impl Database
impl Database
Sourcepub async fn insert_signed_emergency_stop_tx_if_not_exists(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
move_txid: &Txid,
encrypted_emergency_stop_tx: &[u8],
) -> Result<(), BridgeError>
pub async fn insert_signed_emergency_stop_tx_if_not_exists( &self, tx: Option<DatabaseTransaction<'_, '_>>, move_txid: &Txid, encrypted_emergency_stop_tx: &[u8], ) -> Result<(), BridgeError>
Sets a signed emergency stop transaction for a given move transaction ID
Sourcepub async fn get_emergency_stop_txs(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
move_txids: Vec<Txid>,
) -> Result<Vec<(Txid, Vec<u8>)>, BridgeError>
pub async fn get_emergency_stop_txs( &self, tx: Option<DatabaseTransaction<'_, '_>>, move_txids: Vec<Txid>, ) -> Result<Vec<(Txid, Vec<u8>)>, BridgeError>
Gets emergency stop transactions for a list of move transaction IDs
Source§impl Database
impl Database
Sourcepub async fn insert_block_info(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block_hash: &BlockHash,
prev_block_hash: &BlockHash,
block_height: u32,
) -> Result<u32, BridgeError>
pub async fn insert_block_info( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: &BlockHash, prev_block_hash: &BlockHash, block_height: u32, ) -> Result<u32, BridgeError>
Sourcepub async fn update_block_as_canonical(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block_hash: BlockHash,
) -> Result<Option<u32>, BridgeError>
pub async fn update_block_as_canonical( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: BlockHash, ) -> Result<Option<u32>, BridgeError>
Sets the block with given block hash as canonical if it exists in the database Returns the block id if the block was found and set as canonical, None otherwise
Sourcepub async fn get_block_info_from_hash(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block_hash: BlockHash,
) -> Result<Option<(BlockHash, u32)>, BridgeError>
pub async fn get_block_info_from_hash( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: BlockHash, ) -> Result<Option<(BlockHash, u32)>, BridgeError>
Sourcepub async fn get_block_info_from_id(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block_id: u32,
) -> Result<Option<(BlockHash, u32)>, BridgeError>
pub async fn get_block_info_from_id( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_id: u32, ) -> Result<Option<(BlockHash, u32)>, BridgeError>
Gets block hash and height from block id (internal id used in bitcoin_syncer)
Sourcepub async fn upsert_full_block(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block: &Block,
block_height: u32,
) -> Result<(), BridgeError>
pub async fn upsert_full_block( &self, tx: Option<DatabaseTransaction<'_, '_>>, block: &Block, block_height: u32, ) -> Result<(), BridgeError>
Stores the full block in bytes in the database, with its height and hash
Sourcepub async fn get_full_block(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block_height: u32,
) -> Result<Option<Block>, BridgeError>
pub async fn get_full_block( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_height: u32, ) -> Result<Option<Block>, BridgeError>
Gets the full block from the database, given the block height
Sourcepub async fn get_full_block_from_hash(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block_hash: BlockHash,
) -> Result<Option<(u32, Block)>, BridgeError>
pub async fn get_full_block_from_hash( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: BlockHash, ) -> Result<Option<(u32, Block)>, BridgeError>
Gets the full block and its height from the database, given the block hash
Sourcepub async fn get_max_height(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
) -> Result<Option<u32>, BridgeError>
pub async fn get_max_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<u32>, BridgeError>
Gets the maximum height of the canonical blocks in the bitcoin_syncer database
Sourcepub async fn update_non_canonical_block_hashes(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
height: u32,
) -> Result<Vec<u32>, BridgeError>
pub async fn update_non_canonical_block_hashes( &self, tx: Option<DatabaseTransaction<'_, '_>>, height: u32, ) -> Result<Vec<u32>, BridgeError>
Gets the block hashes that have height bigger then the given height and deletes them. Marks blocks with height bigger than the given height as non-canonical.
§Parameters
tx
: Optional transaction to use for the query.height
: Height to start marking blocks as such (not inclusive).
§Returns
Vec<u32>
: List of block ids that were marked as non-canonical in ascending order.
Sourcepub async fn get_canonical_block_id_from_height(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
height: u32,
) -> Result<Option<u32>, BridgeError>
pub async fn get_canonical_block_id_from_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, height: u32, ) -> Result<Option<u32>, BridgeError>
Gets the block id of the canonical block at the given height
Sourcepub async fn insert_txid_to_block(
&self,
tx: DatabaseTransaction<'_, '_>,
block_id: u32,
txid: &Txid,
) -> Result<(), BridgeError>
pub async fn insert_txid_to_block( &self, tx: DatabaseTransaction<'_, '_>, block_id: u32, txid: &Txid, ) -> Result<(), BridgeError>
Saves the txid with the id of the block that contains it to the database
Sourcepub async fn get_block_txids(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block_id: u32,
) -> Result<Vec<Txid>, BridgeError>
pub async fn get_block_txids( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_id: u32, ) -> Result<Vec<Txid>, BridgeError>
Gets all the txids that are contained in the block with the given id
Sourcepub async fn insert_spent_utxo(
&self,
tx: DatabaseTransaction<'_, '_>,
block_id: u32,
spending_txid: &Txid,
txid: &Txid,
vout: i64,
) -> Result<(), BridgeError>
pub async fn insert_spent_utxo( &self, tx: DatabaseTransaction<'_, '_>, block_id: u32, spending_txid: &Txid, txid: &Txid, vout: i64, ) -> Result<(), BridgeError>
Inserts a spent utxo into the database, with the block id that contains it, the spending txid and the vout
Sourcepub async fn get_block_height_of_spending_txid(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
outpoint: OutPoint,
) -> Result<Option<u32>, BridgeError>
pub async fn get_block_height_of_spending_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, outpoint: OutPoint, ) -> Result<Option<u32>, BridgeError>
For a given outpoint, gets the block height of the canonical block that spent it. Returns None if the outpoint is not spent.
Sourcepub async fn check_if_utxo_spending_tx_is_finalized(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
outpoint: OutPoint,
current_chain_height: u32,
finality_depth: u32,
) -> Result<bool, BridgeError>
pub async fn check_if_utxo_spending_tx_is_finalized( &self, tx: Option<DatabaseTransaction<'_, '_>>, outpoint: OutPoint, current_chain_height: u32, finality_depth: u32, ) -> Result<bool, BridgeError>
Checks if the utxo is spent, if so checks if the spending tx is finalized Returns true if the utxo is spent and the spending tx is finalized, false otherwise
Sourcepub async fn get_spent_utxos_for_txid(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
txid: Txid,
) -> Result<Vec<(i64, OutPoint)>, BridgeError>
pub async fn get_spent_utxos_for_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, txid: Txid, ) -> Result<Vec<(i64, OutPoint)>, BridgeError>
Gets all the spent utxos for a given txid
Sourcepub async fn insert_event(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
event_type: BitcoinSyncerEvent,
) -> Result<(), BridgeError>
pub async fn insert_event( &self, tx: Option<DatabaseTransaction<'_, '_>>, event_type: BitcoinSyncerEvent, ) -> Result<(), BridgeError>
Adds a bitcoin syncer event to the database. These events can currently be new block or reorged block.
Sourcepub async fn get_last_processed_event_block_height(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
consumer_handle: &str,
) -> Result<Option<u32>, BridgeError>
pub async fn get_last_processed_event_block_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, consumer_handle: &str, ) -> Result<Option<u32>, BridgeError>
Returns the last processed Bitcoin Syncer event’s block height for given consumer.
If the last processed event is missing, i.e. there are no processed events for the consumer, returns None
.
Sourcepub async fn get_last_processed_event_id(
&self,
tx: DatabaseTransaction<'_, '_>,
consumer_handle: &str,
) -> Result<i32, BridgeError>
pub async fn get_last_processed_event_id( &self, tx: DatabaseTransaction<'_, '_>, consumer_handle: &str, ) -> Result<i32, BridgeError>
Gets the last processed event id for a given consumer
Sourcepub async fn get_max_processed_block_height(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
consumer_handle: &str,
) -> Result<Option<u32>, BridgeError>
pub async fn get_max_processed_block_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, consumer_handle: &str, ) -> Result<Option<u32>, BridgeError>
Returns the maximum block height of the blocks that have been processed by the given consumer.
If the last processed event is missing, i.e. there are no processed events for the consumer, returns None
.
Sourcepub async fn get_next_finalized_block_height_for_consumer(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
consumer_handle: &str,
paramset: &'static ProtocolParamset,
) -> Result<u32, BridgeError>
pub async fn get_next_finalized_block_height_for_consumer( &self, tx: Option<DatabaseTransaction<'_, '_>>, consumer_handle: &str, paramset: &'static ProtocolParamset, ) -> Result<u32, BridgeError>
Returns the next finalized block height that should be processed by the given consumer. If there are no processed events, returns the paramset start height. Next height is the max height of the processed block - finality depth + 1.
Sourcepub async fn fetch_next_bitcoin_syncer_evt(
&self,
tx: DatabaseTransaction<'_, '_>,
consumer_handle: &str,
) -> Result<Option<BitcoinSyncerEvent>, BridgeError>
pub async fn fetch_next_bitcoin_syncer_evt( &self, tx: DatabaseTransaction<'_, '_>, consumer_handle: &str, ) -> Result<Option<BitcoinSyncerEvent>, BridgeError>
Fetches the next bitcoin syncer event for a given consumer This function is used to fetch the next event that hasn’t been processed yet It will return the event which includes the event type and the block id The last updated event id is also updated to the id that is returned If there are no more events to fetch, None is returned
Source§impl Database
impl Database
Sourcepub async fn save_unproven_finalized_block(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block_hash: BlockHash,
block_header: Header,
block_height: u64,
) -> Result<(), BridgeError>
pub async fn save_unproven_finalized_block( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: BlockHash, block_header: Header, block_height: u64, ) -> Result<(), BridgeError>
Adds a new finalized block to the database, later to be updated with a proof.
Sourceasync fn save_block_infos_within_range(
&self,
rpc: &ExtendedBitcoinRpc,
height_start: u32,
height_end: u32,
) -> Result<(), BridgeError>
async fn save_block_infos_within_range( &self, rpc: &ExtendedBitcoinRpc, height_start: u32, height_end: u32, ) -> Result<(), BridgeError>
Collect block info from rpc and save it to hcp table.
Sourcepub async fn fetch_and_save_missing_blocks(
&self,
rpc: &ExtendedBitcoinRpc,
genesis_height: u32,
until_height: u32,
) -> Result<(), BridgeError>
pub async fn fetch_and_save_missing_blocks( &self, rpc: &ExtendedBitcoinRpc, genesis_height: u32, until_height: u32, ) -> Result<(), BridgeError>
This function assumes there are no blocks or some contiguous blocks starting from 0 already in the table. Saves the block hashes and headers until given height(exclusive) as they are needed for spv and hcp proofs.
Sourcepub async fn get_block_info_from_range(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
start_height: u64,
end_height: u64,
) -> Result<Vec<(BlockHash, Header)>, BridgeError>
pub async fn get_block_info_from_range( &self, tx: Option<DatabaseTransaction<'_, '_>>, start_height: u64, end_height: u64, ) -> Result<Vec<(BlockHash, Header)>, BridgeError>
Returns block hash and header for a given range of heights. Ranges are inclusive on both ends.
Sourcepub async fn get_block_info_from_hash_hcp(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block_hash: BlockHash,
) -> Result<Option<(BlockHash, Header, u32)>, BridgeError>
pub async fn get_block_info_from_hash_hcp( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: BlockHash, ) -> Result<Option<(BlockHash, Header, u32)>, BridgeError>
Sourcepub async fn get_latest_finalized_block_height(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
) -> Result<Option<u64>, BridgeError>
pub async fn get_latest_finalized_block_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<u64>, BridgeError>
Returns latest finalized blocks height from the database.
Sourcepub async fn get_next_unproven_block(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
) -> Result<Option<(BlockHash, Header, u64, Receipt)>, BridgeError>
pub async fn get_next_unproven_block( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<(BlockHash, Header, u64, Receipt)>, BridgeError>
Gets the first finalized block after the latest proven block (i.e. proof != null). This block will be the candidate block for the prover.
§Returns
Returns None
if either no proved blocks are exists or blockchain tip
is already proven.
- [
BlockHash
] - Hash of the block - [
Header
] - Header of the block u64
- Height of the block- [
Receipt
] - Previous block’s proof
Sourcepub async fn get_next_n_non_proven_block(
&self,
count: u32,
) -> Result<Option<(Vec<(BlockHash, Header, u64)>, Receipt)>, BridgeError>
pub async fn get_next_n_non_proven_block( &self, count: u32, ) -> Result<Option<(Vec<(BlockHash, Header, u64)>, Receipt)>, BridgeError>
Gets the newest n number of block’s info that their previous block has proven before. These blocks will be the candidate blocks for the prover.
§Returns
Returns None
if either no proved blocks are exists or blockchain tip
is already proven.
- [
BlockHash
] - Hash of last block in the batch - [
Header
] - Headers of the blocks u64
- Height of the last block in the batch- [
Receipt
] - Previous block’s proof
Sourcepub async fn get_latest_proven_block_info(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
) -> Result<Option<(BlockHash, Header, u64)>, BridgeError>
pub async fn get_latest_proven_block_info( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<(BlockHash, Header, u64)>, BridgeError>
Sourcepub async fn get_latest_proven_block_info_until_height(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
height: u32,
) -> Result<Option<(BlockHash, Header, u64)>, BridgeError>
pub async fn get_latest_proven_block_info_until_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, height: u32, ) -> Result<Option<(BlockHash, Header, u64)>, BridgeError>
Sourcepub async fn set_block_proof(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
hash: BlockHash,
proof: Receipt,
) -> Result<(), BridgeError>
pub async fn set_block_proof( &self, tx: Option<DatabaseTransaction<'_, '_>>, hash: BlockHash, proof: Receipt, ) -> Result<(), BridgeError>
Sets an existing block’s (in database) proof by referring to it by it’s hash.
Sourcepub async fn get_block_proof_by_hash(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
hash: BlockHash,
) -> Result<Option<Receipt>, BridgeError>
pub async fn get_block_proof_by_hash( &self, tx: Option<DatabaseTransaction<'_, '_>>, hash: BlockHash, ) -> Result<Option<Receipt>, BridgeError>
Gets a block’s proof by referring to it by it’s hash.
Source§impl Database
impl Database
Sourcepub async fn insert_operator_if_not_exists(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
xonly_pubkey: XOnlyPublicKey,
wallet_address: &Address,
collateral_funding_outpoint: OutPoint,
) -> Result<(), BridgeError>
pub async fn insert_operator_if_not_exists( &self, tx: Option<DatabaseTransaction<'_, '_>>, xonly_pubkey: XOnlyPublicKey, wallet_address: &Address, collateral_funding_outpoint: OutPoint, ) -> Result<(), BridgeError>
Sets the operator details to the db. This function additionally checks if the operator data already exists in the db. As we don’t want to overwrite operator data on the db, as it can prevent us slash malicious operators that signed previous deposits. This function should give an error if an operator changed its data.
pub async fn get_operators( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Vec<(XOnlyPublicKey, Address, OutPoint)>, BridgeError>
pub async fn get_operator( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, ) -> Result<Option<OperatorData>, BridgeError>
Sourcepub async fn insert_unspent_kickoff_sigs_if_not_exist(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
operator_xonly_pk: XOnlyPublicKey,
round_idx: RoundIndex,
signatures: Vec<TaggedSignature>,
) -> Result<(), BridgeError>
pub async fn insert_unspent_kickoff_sigs_if_not_exist( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, round_idx: RoundIndex, signatures: Vec<TaggedSignature>, ) -> Result<(), BridgeError>
Sets the unspent kickoff sigs received from operators during initial setup. Sigs of each round are stored together in the same row. On conflict, do not update the existing sigs. Although technically, as long as kickoff winternitz keys and operator data(collateral funding outpoint and reimburse address) are not changed, the sigs are still valid even if they are changed.
Sourcepub async fn get_unspent_kickoff_sigs(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
operator_xonly_pk: XOnlyPublicKey,
round_idx: RoundIndex,
) -> Result<Option<Vec<TaggedSignature>>, BridgeError>
pub async fn get_unspent_kickoff_sigs( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, round_idx: RoundIndex, ) -> Result<Option<Vec<TaggedSignature>>, BridgeError>
Get unspent kickoff sigs for a specific operator and round.
Sourcepub async fn insert_operator_bitvm_keys_if_not_exist(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
operator_xonly_pk: XOnlyPublicKey,
deposit_outpoint: OutPoint,
winternitz_public_key: Vec<WinternitzPublicKey>,
) -> Result<(), BridgeError>
pub async fn insert_operator_bitvm_keys_if_not_exist( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, winternitz_public_key: Vec<WinternitzPublicKey>, ) -> Result<(), BridgeError>
Sets Winternitz public keys for bitvm related inputs of an operator.
Sourcepub async fn get_operator_bitvm_keys(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
operator_xonly_pk: XOnlyPublicKey,
deposit_outpoint: OutPoint,
) -> Result<Vec<PublicKey>, BridgeError>
pub async fn get_operator_bitvm_keys( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, ) -> Result<Vec<PublicKey>, BridgeError>
Gets Winternitz public keys for bitvm related inputs of an operator.
Sourcepub async fn insert_operator_kickoff_winternitz_public_keys_if_not_exist(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
operator_xonly_pk: XOnlyPublicKey,
winternitz_public_key: Vec<WinternitzPublicKey>,
) -> Result<(), BridgeError>
pub async fn insert_operator_kickoff_winternitz_public_keys_if_not_exist( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, winternitz_public_key: Vec<WinternitzPublicKey>, ) -> Result<(), BridgeError>
Sets Winternitz public keys (only for kickoff blockhash commit) for an operator. On conflict, do not update the existing keys. This is very important, as otherwise the txids of operators round tx’s will change.
Sourcepub async fn get_operator_kickoff_winternitz_public_keys(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
op_xonly_pk: XOnlyPublicKey,
) -> Result<Vec<PublicKey>, BridgeError>
pub async fn get_operator_kickoff_winternitz_public_keys( &self, tx: Option<DatabaseTransaction<'_, '_>>, op_xonly_pk: XOnlyPublicKey, ) -> Result<Vec<PublicKey>, BridgeError>
Gets Winternitz public keys for every sequential collateral tx of an operator and a watchtower.
Sourcepub async fn insert_operator_challenge_ack_hashes_if_not_exist(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
operator_xonly_pk: XOnlyPublicKey,
deposit_outpoint: OutPoint,
public_hashes: &Vec<[u8; 20]>,
) -> Result<(), BridgeError>
pub async fn insert_operator_challenge_ack_hashes_if_not_exist( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, public_hashes: &Vec<[u8; 20]>, ) -> Result<(), BridgeError>
Sets public hashes for a specific operator, sequential collateral tx and kickoff index combination. If there is hashes for given indexes, they will be overwritten by the new hashes.
Sourcepub async fn get_operators_challenge_ack_hashes(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
operator_xonly_pk: XOnlyPublicKey,
deposit_outpoint: OutPoint,
) -> Result<Option<Vec<PublicHash>>, BridgeError>
pub async fn get_operators_challenge_ack_hashes( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, ) -> Result<Option<Vec<PublicHash>>, BridgeError>
Retrieves public hashes for a specific operator, sequential collateral tx and kickoff index combination.
Sourcepub async fn insert_deposit_data_if_not_exists(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
deposit_data: &mut DepositData,
paramset: &'static ProtocolParamset,
) -> Result<u32, BridgeError>
pub async fn insert_deposit_data_if_not_exists( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_data: &mut DepositData, paramset: &'static ProtocolParamset, ) -> Result<u32, BridgeError>
Saves deposit infos, and returns the deposit_id This function additionally checks if the deposit data already exists in the db. As we don’t want to overwrite deposit data on the db, this function should give an error if deposit data is changed.
pub async fn get_deposit_data_with_move_tx( &self, tx: Option<DatabaseTransaction<'_, '_>>, move_to_vault_txid: Txid, ) -> Result<Option<DepositData>, BridgeError>
pub async fn get_deposit_data( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_outpoint: OutPoint, ) -> Result<Option<(u32, DepositData)>, BridgeError>
Sourcepub async fn insert_deposit_signatures_if_not_exist(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
deposit_outpoint: OutPoint,
operator_xonly_pk: XOnlyPublicKey,
round_idx: RoundIndex,
kickoff_idx: usize,
kickoff_txid: Txid,
signatures: Vec<TaggedSignature>,
) -> Result<(), BridgeError>
pub async fn insert_deposit_signatures_if_not_exist( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_outpoint: OutPoint, operator_xonly_pk: XOnlyPublicKey, round_idx: RoundIndex, kickoff_idx: usize, kickoff_txid: Txid, signatures: Vec<TaggedSignature>, ) -> Result<(), BridgeError>
Saves the deposit signatures to the database for a single operator.
The signatures array is identified by the deposit_outpoint and operator_idx.
For the order of signatures, please check crate::builder::sighash::create_nofn_sighash_stream
which determines the order of the sighashes that are signed.
Sourcepub async fn get_deposit_id(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
deposit_outpoint: OutPoint,
) -> Result<u32, BridgeError>
pub async fn get_deposit_id( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_outpoint: OutPoint, ) -> Result<u32, BridgeError>
Gets a unique int for a deposit outpoint
Sourcepub async fn get_deposit_outpoint_for_kickoff_txid(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
kickoff_txid: Txid,
) -> Result<OutPoint, BridgeError>
pub async fn get_deposit_outpoint_for_kickoff_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, kickoff_txid: Txid, ) -> Result<OutPoint, BridgeError>
For a given kickoff txid, get the deposit outpoint that corresponds to it
Sourcepub async fn get_deposit_signatures(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
deposit_outpoint: OutPoint,
operator_xonly_pk: XOnlyPublicKey,
round_idx: RoundIndex,
kickoff_idx: usize,
) -> Result<Option<Vec<TaggedSignature>>, BridgeError>
pub async fn get_deposit_signatures( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_outpoint: OutPoint, operator_xonly_pk: XOnlyPublicKey, round_idx: RoundIndex, kickoff_idx: usize, ) -> Result<Option<Vec<TaggedSignature>>, BridgeError>
Retrieves the deposit signatures for a single operator for a single reimburse process (single kickoff utxo). The signatures are tagged so that each signature can be matched with the correct txin it belongs to easily.
Sourcepub async fn get_lcp_for_assert(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
deposit_id: u32,
) -> Result<Option<Receipt>, BridgeError>
pub async fn get_lcp_for_assert( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_id: u32, ) -> Result<Option<Receipt>, BridgeError>
Retrieves the light client proof for a deposit to be used while sending an assert.
Sourcepub async fn insert_lcp_for_assert(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
deposit_id: u32,
lcp: Receipt,
) -> Result<(), BridgeError>
pub async fn insert_lcp_for_assert( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_id: u32, lcp: Receipt, ) -> Result<(), BridgeError>
Saves the light client proof for a deposit to be used while sending an assert. We save first before sending kickoff to be sure we have the LCP available if we need to assert.
pub async fn get_deposit_data_with_kickoff_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, kickoff_txid: Txid, ) -> Result<Option<(DepositData, KickoffData)>, BridgeError>
Sourcepub async fn insert_bitvm_setup_if_not_exists(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
operator_xonly_pk: XOnlyPublicKey,
deposit_outpoint: OutPoint,
assert_tx_addrs: impl AsRef<[[u8; 32]]>,
root_hash: &[u8; 32],
latest_blockhash_root_hash: &[u8; 32],
) -> Result<(), BridgeError>
pub async fn insert_bitvm_setup_if_not_exists( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, assert_tx_addrs: impl AsRef<[[u8; 32]]>, root_hash: &[u8; 32], latest_blockhash_root_hash: &[u8; 32], ) -> Result<(), BridgeError>
Sets BitVM setup data for a specific operator and deposit combination. This function additionally checks if the BitVM setup data already exists in the db. As we don’t want to overwrite BitVM setup data on the db, as maliciously overwriting can prevent us to regenerate previously signed kickoff tx’s.
Sourcepub async fn get_bitvm_setup(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
operator_xonly_pk: XOnlyPublicKey,
deposit_outpoint: OutPoint,
) -> Result<Option<(Vec<[u8; 32]>, [u8; 32], [u8; 32])>, BridgeError>
pub async fn get_bitvm_setup( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, ) -> Result<Option<(Vec<[u8; 32]>, [u8; 32], [u8; 32])>, BridgeError>
Retrieves BitVM setup data for a specific operator, sequential collateral tx and kickoff index combination
pub async fn mark_kickoff_connector_as_used( &self, tx: Option<DatabaseTransaction<'_, '_>>, round_idx: RoundIndex, kickoff_connector_idx: u32, kickoff_txid: Option<Txid>, ) -> Result<(), BridgeError>
pub async fn get_kickoff_connector_for_kickoff_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, kickoff_txid: Txid, ) -> Result<(RoundIndex, u32), BridgeError>
pub async fn get_kickoff_txid_for_used_kickoff_connector( &self, tx: Option<DatabaseTransaction<'_, '_>>, round_idx: RoundIndex, kickoff_connector_idx: u32, ) -> Result<Option<Txid>, BridgeError>
pub async fn get_unused_and_signed_kickoff_connector( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_id: u32, operator_xonly_pk: XOnlyPublicKey, ) -> Result<Option<(RoundIndex, u32)>, BridgeError>
pub async fn get_current_round_index( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<RoundIndex, BridgeError>
pub async fn update_current_round_index( &self, tx: Option<DatabaseTransaction<'_, '_>>, round_idx: RoundIndex, ) -> Result<(), BridgeError>
Source§impl Database
impl Database
Sourcepub async fn save_state_machines(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
kickoff_machines: Vec<(String, String)>,
round_machines: Vec<(String, XOnlyPublicKey)>,
block_height: i32,
owner_type: &str,
) -> Result<(), BridgeError>
pub async fn save_state_machines( &self, tx: Option<DatabaseTransaction<'_, '_>>, kickoff_machines: Vec<(String, String)>, round_machines: Vec<(String, XOnlyPublicKey)>, block_height: i32, owner_type: &str, ) -> Result<(), BridgeError>
Saves state machines to the database with the current block height
§Arguments
tx
- Optional database transactionkickoff_machines
- Vector of (state_json, kickoff_id, owner_type) tuples for kickoff machinesround_machines
- Vector of (state_json, operator_xonly_pk, owner_type) tuples for round machinesblock_height
- Current block height
§Errors
Returns a BridgeError
if the database operation fails
Sourcepub async fn get_next_height_to_process(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
owner_type: &str,
) -> Result<Option<i32>, BridgeError>
pub async fn get_next_height_to_process( &self, tx: Option<DatabaseTransaction<'_, '_>>, owner_type: &str, ) -> Result<Option<i32>, BridgeError>
Sourcepub async fn load_kickoff_machines(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
owner_type: &str,
) -> Result<Vec<(String, String, i32)>, BridgeError>
pub async fn load_kickoff_machines( &self, tx: Option<DatabaseTransaction<'_, '_>>, owner_type: &str, ) -> Result<Vec<(String, String, i32)>, BridgeError>
Sourcepub async fn load_round_machines(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
owner_type: &str,
) -> Result<Vec<(String, XOnlyPublicKey, i32)>, BridgeError>
pub async fn load_round_machines( &self, tx: Option<DatabaseTransaction<'_, '_>>, owner_type: &str, ) -> Result<Vec<(String, XOnlyPublicKey, i32)>, BridgeError>
Source§impl Database
impl Database
Sourcepub async fn confirm_transactions(
&self,
tx: DatabaseTransaction<'_, '_>,
block_id: u32,
) -> Result<(), BridgeError>
pub async fn confirm_transactions( &self, tx: DatabaseTransaction<'_, '_>, block_id: u32, ) -> Result<(), BridgeError>
Set all transactions’ seen_block_id
to the given block id. This will
be called once a block is confirmed on the Bitcoin side.
Sourcepub async fn unconfirm_transactions(
&self,
tx: DatabaseTransaction<'_, '_>,
block_id: u32,
) -> Result<(), BridgeError>
pub async fn unconfirm_transactions( &self, tx: DatabaseTransaction<'_, '_>, block_id: u32, ) -> Result<(), BridgeError>
Unassigns seen_block_id
from all transactions in the given block id.
By default, all transactions’ seen_block_id
is set to NULL. And they
get assigned a block id when they are confirmed on Bitcoin side. If a
reorg happens, block ids must be unassigned from all transactions.
Sourcepub async fn save_fee_payer_tx(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
bumped_id: u32,
fee_payer_txid: Txid,
vout: u32,
amount: Amount,
replacement_of_id: Option<u32>,
) -> Result<(), BridgeError>
pub async fn save_fee_payer_tx( &self, tx: Option<DatabaseTransaction<'_, '_>>, bumped_id: u32, fee_payer_txid: Txid, vout: u32, amount: Amount, replacement_of_id: Option<u32>, ) -> Result<(), BridgeError>
Saves a fee payer transaction to the database.
§Arguments
bumped_id
- The id of the bumped transactionfee_payer_txid
- The txid of the fee payer transactionvout
- The output index of the UTXOscript_pubkey
- The script pubkey of the UTXOamount
- The amount in satoshis
Sourcepub async fn get_unconfirmed_fee_payer_txs(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
bumped_id: u32,
) -> Result<Vec<(u32, Txid, u32, Amount)>, BridgeError>
pub async fn get_unconfirmed_fee_payer_txs( &self, tx: Option<DatabaseTransaction<'_, '_>>, bumped_id: u32, ) -> Result<Vec<(u32, Txid, u32, Amount)>, BridgeError>
pub async fn get_confirmed_fee_payer_utxos( &self, tx: Option<DatabaseTransaction<'_, '_>>, id: u32, ) -> Result<Vec<(Txid, u32, Amount)>, BridgeError>
Sourcepub async fn check_if_tx_exists_on_txsender(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
txid: Txid,
) -> Result<Option<u32>, BridgeError>
pub async fn check_if_tx_exists_on_txsender( &self, tx: Option<DatabaseTransaction<'_, '_>>, txid: Txid, ) -> Result<Option<u32>, BridgeError>
Returns the id of the tx in tx_sender_try_to_send_txs
if it exists.
Used to avoid adding duplicate transactions to the txsender.
pub async fn save_tx( &self, tx: Option<DatabaseTransaction<'_, '_>>, tx_metadata: Option<TxMetadata>, raw_tx: &Transaction, fee_paying_type: FeePayingType, txid: Txid, rbf_signing_info: Option<RbfSigningInfo>, ) -> Result<u32, BridgeError>
pub async fn save_rbf_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, id: u32, txid: Txid, ) -> Result<(), BridgeError>
pub async fn get_last_rbf_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, id: u32, ) -> Result<Option<Txid>, BridgeError>
pub async fn save_cancelled_outpoint( &self, tx: Option<DatabaseTransaction<'_, '_>>, cancelled_id: u32, outpoint: OutPoint, ) -> Result<(), BridgeError>
pub async fn save_cancelled_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, cancelled_id: u32, txid: Txid, ) -> Result<(), BridgeError>
pub async fn save_activated_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, activated_id: u32, prerequisite_tx: &ActivatedWithTxid, ) -> Result<(), BridgeError>
pub async fn save_activated_outpoint( &self, tx: Option<DatabaseTransaction<'_, '_>>, activated_id: u32, activated_outpoint: &ActivatedWithOutpoint, ) -> Result<(), BridgeError>
Sourcepub async fn get_sendable_txs(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
fee_rate: FeeRate,
current_tip_height: u32,
) -> Result<Vec<u32>, BridgeError>
pub async fn get_sendable_txs( &self, tx: Option<DatabaseTransaction<'_, '_>>, fee_rate: FeeRate, current_tip_height: u32, ) -> Result<Vec<u32>, BridgeError>
Returns unconfirmed try-to-send transactions that satisfy all activation conditions for sending:
- Not in the non-active list
- Not in the cancelled list
- Transaction itself is not already confirmed
- Transaction and UTXO timelocks must be passed
- Fee rate is lower than the provided fee rate or null (deprecated)
§Parameters
tx
: Optional database transactionfee_rate
: Maximum fee rate for the transactions to be sendablecurrent_tip_height
: The current tip height of the Bitcoin blockchain for checking timelocks
§Returns
Vec<u32>
: A vector of transaction ids (db id) that are sendable.
pub async fn update_effective_fee_rate( &self, tx: Option<DatabaseTransaction<'_, '_>>, id: u32, effective_fee_rate: FeeRate, ) -> Result<(), BridgeError>
pub async fn get_try_to_send_tx( &self, tx: Option<DatabaseTransaction<'_, '_>>, id: u32, ) -> Result<(Option<TxMetadata>, Transaction, FeePayingType, Option<u32>, Option<RbfSigningInfo>), BridgeError>
Sourcepub async fn save_tx_debug_submission_error(
&self,
tx_id: u32,
error_message: &str,
) -> Result<(), BridgeError>
pub async fn save_tx_debug_submission_error( &self, tx_id: u32, error_message: &str, ) -> Result<(), BridgeError>
Saves a TX submission error to the debug table
Sourcepub async fn update_tx_debug_sending_state(
&self,
tx_id: u32,
state: &str,
activated: bool,
) -> Result<(), BridgeError>
pub async fn update_tx_debug_sending_state( &self, tx_id: u32, state: &str, activated: bool, ) -> Result<(), BridgeError>
Updates or inserts the TX’s sending state in the debug table
Does not support a Transaction because it’s for debugging purposes. Make sure that tx_id exists (i.e. creation is committed) before use
Sourcepub async fn get_tx_debug_info(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
tx_id: u32,
) -> Result<Option<String>, BridgeError>
pub async fn get_tx_debug_info( &self, tx: Option<DatabaseTransaction<'_, '_>>, tx_id: u32, ) -> Result<Option<String>, BridgeError>
Gets the current debug state of a TX
Sourcepub async fn get_tx_debug_submission_errors(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
tx_id: u32,
) -> Result<Vec<(String, String)>, BridgeError>
pub async fn get_tx_debug_submission_errors( &self, tx: Option<DatabaseTransaction<'_, '_>>, tx_id: u32, ) -> Result<Vec<(String, String)>, BridgeError>
Gets all TX submission errors
Sourcepub async fn get_tx_debug_fee_payer_utxos(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
tx_id: u32,
) -> Result<Vec<(Txid, u32, Amount, bool)>, BridgeError>
pub async fn get_tx_debug_fee_payer_utxos( &self, tx: Option<DatabaseTransaction<'_, '_>>, tx_id: u32, ) -> Result<Vec<(Txid, u32, Amount, bool)>, BridgeError>
Gets all fee payer UTXOs for a TX with their confirmation status
Sourcepub async fn purge_tx_debug_info(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
tx_id: u32,
) -> Result<(), BridgeError>
pub async fn purge_tx_debug_info( &self, tx: Option<DatabaseTransaction<'_, '_>>, tx_id: u32, ) -> Result<(), BridgeError>
Purges debug information for a successfully sent TX
Source§impl Database
impl Database
Sourcepub async fn get_last_deposit_idx(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
) -> Result<Option<u32>, BridgeError>
pub async fn get_last_deposit_idx( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<u32>, BridgeError>
Returns the last deposit index. If no deposits exist, returns None
Sourcepub async fn get_last_withdrawal_idx(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
) -> Result<Option<u32>, BridgeError>
pub async fn get_last_withdrawal_idx( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<u32>, BridgeError>
Returns the last withdrawal index where withdrawal_utxo_txid exists. If no withdrawals with UTXOs exist, returns None.
pub async fn upsert_move_to_vault_txid_from_citrea_deposit( &self, tx: Option<DatabaseTransaction<'_, '_>>, citrea_idx: u32, move_to_vault_txid: &Txid, ) -> Result<(), BridgeError>
pub async fn get_move_to_vault_txid_from_citrea_deposit( &self, tx: Option<DatabaseTransaction<'_, '_>>, citrea_idx: u32, ) -> Result<Option<Txid>, BridgeError>
pub async fn update_replacement_deposit_move_txid( &self, tx: DatabaseTransaction<'_, '_>, idx: u32, new_move_txid: Txid, ) -> Result<(), BridgeError>
pub async fn update_withdrawal_utxo_from_citrea_withdrawal( &self, tx: Option<DatabaseTransaction<'_, '_>>, citrea_idx: u32, withdrawal_utxo: OutPoint, withdrawal_batch_proof_bitcoin_block_height: u32, ) -> Result<(), BridgeError>
Sourcepub async fn get_withdrawal_utxo_from_citrea_withdrawal(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
citrea_idx: u32,
) -> Result<OutPoint, BridgeError>
pub async fn get_withdrawal_utxo_from_citrea_withdrawal( &self, tx: Option<DatabaseTransaction<'_, '_>>, citrea_idx: u32, ) -> Result<OutPoint, BridgeError>
For the given deposit index, returns the withdrawal utxo associated with it If there is no withdrawal utxo set for the deposit, an error is returned
Sourcepub async fn get_payout_txs_for_withdrawal_utxos(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
block_id: u32,
) -> Result<Vec<(u32, Txid)>, BridgeError>
pub async fn get_payout_txs_for_withdrawal_utxos( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_id: u32, ) -> Result<Vec<(u32, Txid)>, BridgeError>
Returns the withdrawal indexes and their spending txid for the given block id.
Sourcepub async fn update_payout_txs_and_payer_operator_xonly_pk(
&self,
tx: Option<DatabaseTransaction<'_, '_>>,
payout_txs_and_payer_operator_xonly_pk: Vec<(u32, Txid, Option<XOnlyPublicKey>, BlockHash)>,
) -> Result<(), BridgeError>
pub async fn update_payout_txs_and_payer_operator_xonly_pk( &self, tx: Option<DatabaseTransaction<'_, '_>>, payout_txs_and_payer_operator_xonly_pk: Vec<(u32, Txid, Option<XOnlyPublicKey>, BlockHash)>, ) -> Result<(), BridgeError>
Sets the given payout txs’ txid and operator index for the given index.
pub async fn get_payout_info_from_move_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, move_to_vault_txid: Txid, ) -> Result<Option<(Option<XOnlyPublicKey>, BlockHash, Txid, i32)>, BridgeError>
pub async fn get_first_unhandled_payout_by_operator_xonly_pk( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, ) -> Result<Option<(u32, Txid, BlockHash)>, BridgeError>
pub async fn get_payer_xonly_pk_blockhash_and_kickoff_txid_from_deposit_id( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_id: u32, ) -> Result<(Option<XOnlyPublicKey>, Option<BlockHash>, Option<Txid>), BridgeError>
pub async fn mark_payout_handled( &self, tx: Option<DatabaseTransaction<'_, '_>>, citrea_idx: u32, kickoff_txid: Txid, ) -> Result<(), BridgeError>
pub async fn get_handled_payout_kickoff_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, payout_txid: Txid, ) -> Result<Option<Txid>, BridgeError>
Source§impl Database
impl Database
Sourcepub async fn new(config: &BridgeConfig) -> Result<Self, BridgeError>
pub async fn new(config: &BridgeConfig) -> Result<Self, BridgeError>
Establishes a new connection to a PostgreSQL database with given configuration.
§Errors
Returns a BridgeError
if database is not accessible.
pub fn get_pool(&self) -> Pool<Postgres>
pub async fn is_pgmq_installed( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<bool, BridgeError>
Sourcepub async fn run_schema_script(
config: &BridgeConfig,
is_verifier: bool,
) -> Result<(), BridgeError>
pub async fn run_schema_script( config: &BridgeConfig, is_verifier: bool, ) -> Result<(), BridgeError>
Runs the schema script on a database for the given configuration.
§Errors
Will return BridgeError
if there was a problem with database
connection.
Sourcepub fn get_postgresql_url(config: &BridgeConfig) -> String
pub fn get_postgresql_url(config: &BridgeConfig) -> String
Prepares a valid PostgreSQL URL.
URL contains user, password, host and port fields, which are picked from the given configuration.
Sourcepub fn get_postgresql_database_url(config: &BridgeConfig) -> String
pub fn get_postgresql_database_url(config: &BridgeConfig) -> String
Prepares a valid PostgreSQL URL to a specific database.
URL contains user, password, host, port and database name fields, which are picked from the given configuration.
Sourcepub async fn begin_transaction(
&self,
) -> Result<Transaction<'_, Postgres>, BridgeError>
pub async fn begin_transaction( &self, ) -> Result<Transaction<'_, Postgres>, BridgeError>
Starts a database transaction.
Return value can be used for committing changes. If not committed, database will rollback every operation done after that call.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
fn exact_from(value: T) -> U
§impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
fn exact_into(self) -> U
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
] or
a color-specific method, such as [OwoColorize::green
], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
] or
a color-specific method, such as [OwoColorize::on_yellow
], Read more§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)
§impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
fn saturating_into(self) -> U
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.