Package org.ldk.batteries
Class ChannelManagerConstructor
- java.lang.Object
-
- org.ldk.batteries.ChannelManagerConstructor
-
public class ChannelManagerConstructor extends Object
A simple utility class which assists in constructing a fresh or deserializing from disk a ChannelManager and one or more ChannelMonitors. Also constructs a PeerManager and spawns a background thread to monitor for and notify you of relevant Events.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ChannelManagerConstructor.ChannelManagerPersister
Abstract interface which should handle Events and persist the ChannelManager.static class
ChannelManagerConstructor.InvalidSerializedDataException
An Exception that indicates the serialized data is invalid and has been corrupted on disk.
-
Field Summary
Fields Modifier and Type Field Description ChannelManager
channel_manager
The ChannelManager either deserialized or newly-constructed.byte[]
channel_manager_latest_block_hash
The latest block has the channel manager saw.TwoTuple<ChannelMonitor,byte[]>[]
channel_monitors
A list of ChannelMonitors and the last block they each saw.NioPeerHandler
nio_peer_handler
A NioPeerHandler which manages a background thread to handle socket events and pass them to the peer_manager.PeerManager
peer_manager
A PeerManager which is constructed to pass messages and handle connections to peers.
-
Constructor Summary
Constructors Constructor Description ChannelManagerConstructor(byte[] channel_manager_serialized, byte[][] channel_monitors_serialized, KeysInterface keys_interface, FeeEstimator fee_estimator, ChainMonitor chain_monitor, Filter filter, NetGraphMsgHandler router, BroadcasterInterface tx_broadcaster, Logger logger)
Deserializes a channel manager and a set of channel monitors from the given serialized copies and interface implementationsChannelManagerConstructor(Network network, UserConfig config, byte[] current_blockchain_tip_hash, int current_blockchain_tip_height, KeysInterface keys_interface, FeeEstimator fee_estimator, ChainMonitor chain_monitor, NetGraphMsgHandler router, BroadcasterInterface tx_broadcaster, Logger logger)
Constructs a channel manager from the given interface implementations
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
chain_sync_completed(ChannelManagerConstructor.ChannelManagerPersister persister)
Utility which adds all of the deserialized ChannelMonitors to the chain watch so that further updates from the ChannelManager are processed as normal.void
interrupt()
Interrupt the background thread, stopping the background handling of events.
-
-
-
Field Detail
-
channel_manager
public final ChannelManager channel_manager
The ChannelManager either deserialized or newly-constructed.
-
channel_manager_latest_block_hash
public final byte[] channel_manager_latest_block_hash
The latest block has the channel manager saw. If this is non-null it is a 32-byte block hash. You should sync the blockchain starting with the block that builds on this block.
-
channel_monitors
public final TwoTuple<ChannelMonitor,byte[]>[] channel_monitors
A list of ChannelMonitors and the last block they each saw. You should sync the blockchain on each individually starting with the block that builds on the hash given. After doing so (and syncing the blockchain on the channel manager as well), you should call chain_sync_completed() and then continue to normal application operation.
-
peer_manager
public final PeerManager peer_manager
A PeerManager which is constructed to pass messages and handle connections to peers.
-
nio_peer_handler
public final NioPeerHandler nio_peer_handler
A NioPeerHandler which manages a background thread to handle socket events and pass them to the peer_manager.
-
-
Constructor Detail
-
ChannelManagerConstructor
public ChannelManagerConstructor(byte[] channel_manager_serialized, byte[][] channel_monitors_serialized, KeysInterface keys_interface, FeeEstimator fee_estimator, ChainMonitor chain_monitor, @Nullable Filter filter, @Nullable NetGraphMsgHandler router, BroadcasterInterface tx_broadcaster, Logger logger) throws ChannelManagerConstructor.InvalidSerializedDataException
Deserializes a channel manager and a set of channel monitors from the given serialized copies and interface implementations- Parameters:
filter
- If provided, the outputs which were previously registered to be monitored for will be loaded into the filter. Note that if the provided Watch is a ChainWatch and has an associated filter, the previously registered outputs will be loaded when chain_sync_completed is called.- Throws:
ChannelManagerConstructor.InvalidSerializedDataException
-
ChannelManagerConstructor
public ChannelManagerConstructor(Network network, UserConfig config, byte[] current_blockchain_tip_hash, int current_blockchain_tip_height, KeysInterface keys_interface, FeeEstimator fee_estimator, ChainMonitor chain_monitor, @Nullable NetGraphMsgHandler router, BroadcasterInterface tx_broadcaster, Logger logger)
Constructs a channel manager from the given interface implementations
-
-
Method Detail
-
chain_sync_completed
public void chain_sync_completed(ChannelManagerConstructor.ChannelManagerPersister persister)
Utility which adds all of the deserialized ChannelMonitors to the chain watch so that further updates from the ChannelManager are processed as normal. This also spawns a background thread which will call the appropriate methods on the provided ChannelManagerPersister as required.
-
interrupt
public void interrupt()
Interrupt the background thread, stopping the background handling of events.
-
-