Class 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. Note that you must ensure you hold a reference to any constructed ChannelManagerConstructor objects to ensure you continue to receive events generated by the background thread which will be stopped if this object is garbage collected.
    • 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_BlockHashChannelMonitorZ[] 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 PeerManager peer_manager
        A PeerManager which is constructed to pass messages and handle connections to peers. This is `null` until `chain_sync_completed` is called.
      • nio_peer_handler

        public NioPeerHandler nio_peer_handler
        A NioPeerHandler which manages a background thread to handle socket events and pass them to the peer_manager. This is `null` until `chain_sync_completed` is called.
      • net_graph

        public final NetworkGraph net_graph
        The `NetworkGraph` deserialized from the byte given to the constructor when deserializing or the `NetworkGraph` given explicitly to the new-object constructor.
    • Method Detail

      • get_locked_scorer

        public ChannelManagerConstructor.ScorerWrapper get_locked_scorer()
        Gets the `ProbabilisticScorer` which backs the public lockable `scorer`. Don't forget to `close` the lock when you're done with it.
      • chain_sync_completed

        public void chain_sync_completed​(ChannelManagerConstructor.EventHandler event_handler,
                                         boolean use_p2p_graph_sync)
        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 EventHandler as required.
        Parameters:
        use_p2p_graph_sync - determines if we will sync the network graph from peers over the standard (but inefficient) lightning P2P protocol. Note that doing so currently requires trusting peers as no DoS mechanism is enforced to ensure we don't accept bogus gossip. Alternatively, you may sync the net_graph exposed in this object via Rapid Gossip Sync.
      • interrupt

        public void interrupt()
        Interrupt the background thread, stopping the background handling of events.