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§

source

fn new_node( &self, node_id: &PublicKey, config: &NodeConfig, state: &NodeState ) -> Result<(), Error>

Create a new node

source

fn update_node( &self, node_id: &PublicKey, state: &NodeState ) -> Result<(), Error>

Update node enforcement state

source

fn delete_node(&self, node_id: &PublicKey) -> Result<(), Error>

Delete a node and all of its channels. Used in test mode.

source

fn new_channel( &self, node_id: &PublicKey, stub: &ChannelStub ) -> Result<(), Error>

Will error if exists

source

fn new_chain_tracker( &self, node_id: &PublicKey, tracker: &ChainTracker<ChainMonitor> ) -> Result<(), Error>

Create a new tracker

source

fn update_tracker( &self, node_id: &PublicKey, tracker: &ChainTracker<ChainMonitor> ) -> Result<(), Error>

Update the tracker

source

fn get_tracker( &self, node_id: PublicKey, validator_factory: Arc<dyn ValidatorFactory> ) -> Result<ChainTracker<ChainMonitor>, Error>

Get the tracker

source

fn update_channel( &self, node_id: &PublicKey, channel: &Channel ) -> Result<(), Error>

Will error if doesn’t exist.

source

fn get_channel( &self, node_id: &PublicKey, channel_id: &ChannelId ) -> Result<ChannelEntry, Error>

Get a channel from store

source

fn get_node_channels( &self, node_id: &PublicKey ) -> Result<Vec<(ChannelId, ChannelEntry)>, Error>

Get all channels for a node from store

source

fn update_node_allowlist( &self, node_id: &PublicKey, allowlist: Vec<String> ) -> Result<(), Error>

Persist the allowlist to the store.

source

fn get_node_allowlist(&self, node_id: &PublicKey) -> Result<Vec<String>, Error>

Get the allowlist from the store.

source

fn get_nodes(&self) -> Result<Vec<(PublicKey, NodeEntry)>, Error>

Get all nodes from store

source

fn clear_database(&self) -> Result<(), Error>

Clears the database. Not for production use.

Provided Methods§

source

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.

Implementors§