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§
sourcefn get_contract(&self, id: &ContractId) -> Result<Option<Contract>, Error>
fn get_contract(&self, id: &ContractId) -> Result<Option<Contract>, Error>
Returns the contract with given id if found.
sourcefn create_contract(&self, contract: &OfferedContract) -> Result<(), Error>
fn create_contract(&self, contract: &OfferedContract) -> Result<(), Error>
Create a record for the given contract.
sourcefn delete_contract(&self, id: &ContractId) -> Result<(), Error>
fn delete_contract(&self, id: &ContractId) -> Result<(), Error>
Delete the record for the contract with the given id.
sourcefn get_contract_offers(&self) -> Result<Vec<OfferedContract>, Error>
fn get_contract_offers(&self) -> Result<Vec<OfferedContract>, Error>
Returns the set of contracts in offered state.
sourcefn get_signed_contracts(&self) -> Result<Vec<SignedContract>, Error>
fn get_signed_contracts(&self) -> Result<Vec<SignedContract>, Error>
Returns the set of contracts in signed state.
sourcefn get_confirmed_contracts(&self) -> Result<Vec<SignedContract>, Error>
fn get_confirmed_contracts(&self) -> Result<Vec<SignedContract>, Error>
Returns the set of confirmed contracts.
sourcefn get_preclosed_contracts(&self) -> Result<Vec<PreClosedContract>, Error>
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
sourcefn upsert_channel(
&self,
channel: Channel,
contract: Option<Contract>
) -> Result<(), Error>
fn upsert_channel(
&self,
channel: Channel,
contract: Option<Contract>
) -> Result<(), Error>
Update the state of the channel and optionally its associated contract atomically.
sourcefn delete_channel(&self, channel_id: &ChannelId) -> Result<(), Error>
fn delete_channel(&self, channel_id: &ChannelId) -> Result<(), Error>
Delete the channel with given ChannelId
if any.
sourcefn get_channel(&self, channel_id: &ChannelId) -> Result<Option<Channel>, Error>
fn get_channel(&self, channel_id: &ChannelId) -> Result<Option<Channel>, Error>
Returns the channel with given ChannelId
if any.
sourcefn get_signed_channels(
&self,
channel_state: Option<SignedChannelStateType>
) -> Result<Vec<SignedChannel>, Error>
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.
sourcefn get_offered_channels(&self) -> Result<Vec<OfferedChannel>, Error>
fn get_offered_channels(&self) -> Result<Vec<OfferedChannel>, Error>
Returns the set of channels in offer state.
sourcefn persist_chain_monitor(&self, monitor: &ChainMonitor) -> Result<(), Error>
fn persist_chain_monitor(&self, monitor: &ChainMonitor) -> Result<(), Error>
Writes the ChainMonitor
data to the store.
sourcefn get_chain_monitor(&self) -> Result<Option<ChainMonitor>, Error>
fn get_chain_monitor(&self) -> Result<Option<ChainMonitor>, Error>
Returns the latest ChainMonitor
in the store if any.