Trait dlc_manager::Storage

source ·
pub trait Storage {
Show 16 methods // Required methods fn get_contract(&self, id: &ContractId) -> Result<Option<Contract>, Error>; fn get_contracts(&self) -> Result<Vec<Contract>, Error>; fn create_contract(&self, contract: &OfferedContract) -> Result<(), Error>; fn delete_contract(&self, id: &ContractId) -> Result<(), Error>; fn update_contract(&self, contract: &Contract) -> Result<(), Error>; fn get_contract_offers(&self) -> Result<Vec<OfferedContract>, Error>; fn get_signed_contracts(&self) -> Result<Vec<SignedContract>, Error>; fn get_confirmed_contracts(&self) -> Result<Vec<SignedContract>, Error>; fn get_preclosed_contracts(&self) -> Result<Vec<PreClosedContract>, Error>; fn upsert_channel(
&self,
channel: Channel,
contract: Option<Contract>
) -> Result<(), Error>; fn delete_channel(&self, channel_id: &ChannelId) -> Result<(), Error>; fn get_channel(
&self,
channel_id: &ChannelId
) -> Result<Option<Channel>, Error>; fn get_signed_channels(
&self,
channel_state: Option<SignedChannelStateType>
) -> Result<Vec<SignedChannel>, Error>; fn get_offered_channels(&self) -> Result<Vec<OfferedChannel>, Error>; fn persist_chain_monitor(&self, monitor: &ChainMonitor) -> Result<(), Error>; fn get_chain_monitor(&self) -> Result<Option<ChainMonitor>, Error>;
}
Expand description

Storage trait provides functionalities to store and retrieve DLCs.

Required Methods§

source

fn get_contract(&self, id: &ContractId) -> Result<Option<Contract>, Error>

Returns the contract with given id if found.

source

fn get_contracts(&self) -> Result<Vec<Contract>, Error>

Return all contracts

source

fn create_contract(&self, contract: &OfferedContract) -> Result<(), Error>

Create a record for the given contract.

source

fn delete_contract(&self, id: &ContractId) -> Result<(), Error>

Delete the record for the contract with the given id.

source

fn update_contract(&self, contract: &Contract) -> Result<(), Error>

Update the given contract.

source

fn get_contract_offers(&self) -> Result<Vec<OfferedContract>, Error>

Returns the set of contracts in offered state.

source

fn get_signed_contracts(&self) -> Result<Vec<SignedContract>, Error>

Returns the set of contracts in signed state.

source

fn get_confirmed_contracts(&self) -> Result<Vec<SignedContract>, Error>

Returns the set of confirmed contracts.

source

fn get_preclosed_contracts(&self) -> Result<Vec<PreClosedContract>, Error>

Returns the set of contracts whos broadcasted cet has not been verified to be confirmed on blockchain

source

fn upsert_channel(
&self,
channel: Channel,
contract: Option<Contract>
) -> Result<(), Error>

Update the state of the channel and optionally its associated contract atomically.

source

fn delete_channel(&self, channel_id: &ChannelId) -> Result<(), Error>

Delete the channel with given ChannelId if any.

source

fn get_channel(&self, channel_id: &ChannelId) -> Result<Option<Channel>, Error>

Returns the channel with given ChannelId if any.

source

fn get_signed_channels(
&self,
channel_state: Option<SignedChannelStateType>
) -> Result<Vec<SignedChannel>, Error>

Returns the set of SignedChannel in the store. Returns only the one with matching channel_state if set.

source

fn get_offered_channels(&self) -> Result<Vec<OfferedChannel>, Error>

Returns the set of channels in offer state.

source

fn persist_chain_monitor(&self, monitor: &ChainMonitor) -> Result<(), Error>

Writes the ChainMonitor data to the store.

source

fn get_chain_monitor(&self) -> Result<Option<ChainMonitor>, Error>

Returns the latest ChainMonitor in the store if any.

Implementors§