Struct lightning_background_processor::BackgroundProcessor[][src]

pub struct BackgroundProcessor { /* fields omitted */ }
Expand description

BackgroundProcessor takes care of tasks that (1) need to happen periodically to keep Rust-Lightning running properly, and (2) either can or should be run in the background. Its responsibilities are:

  • Monitoring whether the ChannelManager needs to be re-persisted to disk, and if so, writing it to disk/backups by invoking the callback given to it at startup. ChannelManager persistence should be done in the background.
  • Calling ChannelManager::timer_tick_occurred() and PeerManager::timer_tick_occurred() every minute (can be done in the background).

Note that if ChannelManager persistence fails and the persisted manager becomes out-of-date, then there is a risk of channels force-closing on startup when the manager realizes it’s outdated. However, as long as ChannelMonitor backups are sound, no funds besides those used for unilateral chain closure fees are at risk.

Implementations

Start a background thread that takes care of responsibilities enumerated in the top-level documentation.

The thread runs indefinitely unless the object is dropped, stop is called, or persist_manager returns an error. In case of an error, the error is retrieved by calling either join or stop.

Typically, users should either implement ChannelManagerPersister to never return an error or call join and handle any error that may arise. For the latter case, the BackgroundProcessor must be restarted by calling start again after handling the error.

persist_manager is responsible for writing out the ChannelManager to disk, and/or uploading to one or more backup services. See ChannelManager::write for writing out a ChannelManager. See FilesystemPersister::persist_manager for Rust-Lightning’s provided implementation.

Join BackgroundProcessor’s thread, returning any error that occurred while persisting ChannelManager.

Panics

This function panics if the background thread has panicked such as while persisting or handling events.

Stop BackgroundProcessor’s thread, returning any error that occurred while persisting ChannelManager.

Panics

This function panics if the background thread has panicked such as while persisting or handling events.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.