Struct lightning_background_processor::BackgroundProcessor [−][src]
pub struct BackgroundProcessor { pub thread_handle: JoinHandle<Result<(), Error>>, // some 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()
andPeerManager::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.
Fields
thread_handle: JoinHandle<Result<(), Error>>
May be used to retrieve and handle the error if BackgroundProcessor
’s thread
exits due to an error while persisting.
Implementations
pub fn start<Signer: 'static + Sign, CF: 'static + Deref + Send + Sync, CW: 'static + Deref + Send + Sync, T: 'static + Deref + Send + Sync, K: 'static + Deref + Send + Sync, F: 'static + Deref + Send + Sync, L: 'static + Deref + Send + Sync, P: 'static + Deref + Send + Sync, Descriptor: 'static + SocketDescriptor + Send + Sync, CMH: 'static + Deref + Send + Sync, RMH: 'static + Deref + Send + Sync, EH: 'static + EventHandler + Send + Sync, CMP: 'static + Send + ChannelManagerPersister<Signer, CW, T, K, F, L>, M: 'static + Deref<Target = ChainMonitor<Signer, CF, T, F, L, P>> + Send + Sync, CM: 'static + Deref<Target = ChannelManager<Signer, CW, T, K, F, L>> + Send + Sync, PM: 'static + Deref<Target = PeerManager<Descriptor, CMH, RMH, L>> + Send + Sync>(
persister: CMP,
event_handler: EH,
chain_monitor: M,
channel_manager: CM,
peer_manager: PM,
logger: L
) -> Self where
CF::Target: 'static + Filter,
CW::Target: 'static + Watch<Signer>,
T::Target: 'static + BroadcasterInterface,
K::Target: 'static + KeysInterface<Signer = Signer>,
F::Target: 'static + FeeEstimator,
L::Target: 'static + Logger,
P::Target: 'static + Persist<Signer>,
CMH::Target: 'static + ChannelMessageHandler,
RMH::Target: 'static + RoutingMessageHandler,
pub fn start<Signer: 'static + Sign, CF: 'static + Deref + Send + Sync, CW: 'static + Deref + Send + Sync, T: 'static + Deref + Send + Sync, K: 'static + Deref + Send + Sync, F: 'static + Deref + Send + Sync, L: 'static + Deref + Send + Sync, P: 'static + Deref + Send + Sync, Descriptor: 'static + SocketDescriptor + Send + Sync, CMH: 'static + Deref + Send + Sync, RMH: 'static + Deref + Send + Sync, EH: 'static + EventHandler + Send + Sync, CMP: 'static + Send + ChannelManagerPersister<Signer, CW, T, K, F, L>, M: 'static + Deref<Target = ChainMonitor<Signer, CF, T, F, L, P>> + Send + Sync, CM: 'static + Deref<Target = ChannelManager<Signer, CW, T, K, F, L>> + Send + Sync, PM: 'static + Deref<Target = PeerManager<Descriptor, CMH, RMH, L>> + Send + Sync>(
persister: CMP,
event_handler: EH,
chain_monitor: M,
channel_manager: CM,
peer_manager: PM,
logger: L
) -> Self where
CF::Target: 'static + Filter,
CW::Target: 'static + Watch<Signer>,
T::Target: 'static + BroadcasterInterface,
K::Target: 'static + KeysInterface<Signer = Signer>,
F::Target: 'static + FeeEstimator,
L::Target: 'static + Logger,
P::Target: 'static + Persist<Signer>,
CMH::Target: 'static + ChannelMessageHandler,
RMH::Target: 'static + RoutingMessageHandler,
Start a background thread that takes care of responsibilities enumerated in the top-level documentation.
If persist_manager
returns an error, then this thread will return said error (and
start()
will need to be called again to restart the BackgroundProcessor
). Users should
wait on thread_handle
’s join()
method to be able to tell if and when an error is
returned, or implement persist_manager
such that an error is never returned to the
BackgroundProcessor
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.
Auto Trait Implementations
impl !RefUnwindSafe for BackgroundProcessor
impl Send for BackgroundProcessor
impl Sync for BackgroundProcessor
impl Unpin for BackgroundProcessor
impl !UnwindSafe for BackgroundProcessor