Trait lightning_signer::persist::Persist
source · pub trait Persist: SendSync {
Show 15 methods
// Required methods
fn new_node(
&self,
node_id: &PublicKey,
config: &NodeConfig,
state: &NodeState
) -> Result<(), Error>;
fn update_node(
&self,
node_id: &PublicKey,
state: &NodeState
) -> Result<(), Error>;
fn delete_node(&self, node_id: &PublicKey) -> Result<(), Error>;
fn new_channel(
&self,
node_id: &PublicKey,
stub: &ChannelStub
) -> Result<(), Error>;
fn new_chain_tracker(
&self,
node_id: &PublicKey,
tracker: &ChainTracker<ChainMonitor>
) -> Result<(), Error>;
fn update_tracker(
&self,
node_id: &PublicKey,
tracker: &ChainTracker<ChainMonitor>
) -> Result<(), Error>;
fn get_tracker(
&self,
node_id: PublicKey,
validator_factory: Arc<dyn ValidatorFactory>
) -> Result<ChainTracker<ChainMonitor>, Error>;
fn update_channel(
&self,
node_id: &PublicKey,
channel: &Channel
) -> Result<(), Error>;
fn get_channel(
&self,
node_id: &PublicKey,
channel_id: &ChannelId
) -> Result<ChannelEntry, Error>;
fn get_node_channels(
&self,
node_id: &PublicKey
) -> Result<Vec<(ChannelId, ChannelEntry)>, Error>;
fn update_node_allowlist(
&self,
node_id: &PublicKey,
allowlist: Vec<String>
) -> Result<(), Error>;
fn get_node_allowlist(
&self,
node_id: &PublicKey
) -> Result<Vec<String>, Error>;
fn get_nodes(&self) -> Result<Vec<(PublicKey, NodeEntry)>, Error>;
fn clear_database(&self) -> Result<(), Error>;
// Provided method
fn enter(
&self,
_state: Arc<Mutex<OrderedMap<String, (u64, Vec<u8>)>>>
) -> Box<dyn Context> { ... }
}
Expand description
Persister of nodes and channels
A Node will call the relevant methods here as needed.
There are two types of persisters:
-
Memorizing persisters, which only store the mutations in memory, for later retrieval and storage by the caller. This is used in embedded environments to return the mutations to the host system.
-
Real persisters, which store the mutations directly, for example to disk. This is used in non-embedded environments. This kind of persister should persist durably before returning, for safety.
Required Methods§
sourcefn new_node(
&self,
node_id: &PublicKey,
config: &NodeConfig,
state: &NodeState
) -> Result<(), Error>
fn new_node( &self, node_id: &PublicKey, config: &NodeConfig, state: &NodeState ) -> Result<(), Error>
Create a new node
sourcefn update_node(
&self,
node_id: &PublicKey,
state: &NodeState
) -> Result<(), Error>
fn update_node( &self, node_id: &PublicKey, state: &NodeState ) -> Result<(), Error>
Update node enforcement state
sourcefn delete_node(&self, node_id: &PublicKey) -> Result<(), Error>
fn delete_node(&self, node_id: &PublicKey) -> Result<(), Error>
Delete a node and all of its channels. Used in test mode.
sourcefn new_channel(
&self,
node_id: &PublicKey,
stub: &ChannelStub
) -> Result<(), Error>
fn new_channel( &self, node_id: &PublicKey, stub: &ChannelStub ) -> Result<(), Error>
Will error if exists
sourcefn new_chain_tracker(
&self,
node_id: &PublicKey,
tracker: &ChainTracker<ChainMonitor>
) -> Result<(), Error>
fn new_chain_tracker( &self, node_id: &PublicKey, tracker: &ChainTracker<ChainMonitor> ) -> Result<(), Error>
Create a new tracker
sourcefn update_tracker(
&self,
node_id: &PublicKey,
tracker: &ChainTracker<ChainMonitor>
) -> Result<(), Error>
fn update_tracker( &self, node_id: &PublicKey, tracker: &ChainTracker<ChainMonitor> ) -> Result<(), Error>
Update the tracker
sourcefn get_tracker(
&self,
node_id: PublicKey,
validator_factory: Arc<dyn ValidatorFactory>
) -> Result<ChainTracker<ChainMonitor>, Error>
fn get_tracker( &self, node_id: PublicKey, validator_factory: Arc<dyn ValidatorFactory> ) -> Result<ChainTracker<ChainMonitor>, Error>
Get the tracker
sourcefn update_channel(
&self,
node_id: &PublicKey,
channel: &Channel
) -> Result<(), Error>
fn update_channel( &self, node_id: &PublicKey, channel: &Channel ) -> Result<(), Error>
Will error if doesn’t exist.
id0
original channel ID supplied toPersist::new_channel()
id
an optional additional permanent channel ID
sourcefn get_channel(
&self,
node_id: &PublicKey,
channel_id: &ChannelId
) -> Result<ChannelEntry, Error>
fn get_channel( &self, node_id: &PublicKey, channel_id: &ChannelId ) -> Result<ChannelEntry, Error>
Get a channel from store
sourcefn get_node_channels(
&self,
node_id: &PublicKey
) -> Result<Vec<(ChannelId, ChannelEntry)>, Error>
fn get_node_channels( &self, node_id: &PublicKey ) -> Result<Vec<(ChannelId, ChannelEntry)>, Error>
Get all channels for a node from store
sourcefn update_node_allowlist(
&self,
node_id: &PublicKey,
allowlist: Vec<String>
) -> Result<(), Error>
fn update_node_allowlist( &self, node_id: &PublicKey, allowlist: Vec<String> ) -> Result<(), Error>
Persist the allowlist to the store.
sourcefn get_node_allowlist(&self, node_id: &PublicKey) -> Result<Vec<String>, Error>
fn get_node_allowlist(&self, node_id: &PublicKey) -> Result<Vec<String>, Error>
Get the allowlist from the store.
sourcefn clear_database(&self) -> Result<(), Error>
fn clear_database(&self) -> Result<(), Error>
Clears the database. Not for production use.
Provided Methods§
sourcefn enter(
&self,
_state: Arc<Mutex<OrderedMap<String, (u64, Vec<u8>)>>>
) -> Box<dyn Context>
fn enter( &self, _state: Arc<Mutex<OrderedMap<String, (u64, Vec<u8>)>>> ) -> Box<dyn Context>
Enter a persistence context
Entering while the thread is already in a context will panic
Returns a Context
object, which can be used to retrieve the
modified entries and exit the context.
If this is not a memorizing context, the returned object will always have an empty list of modified entries.