Documentation ¶
Index ¶
- Constants
- Variables
- func MultiSourceBootstrap(ignore map[autopilot.NodeID]struct{}, numAddrs uint32, ...) ([]*lnwire.NetAddress, er.R)
- type AuthenticatedGossiper
- func (d *AuthenticatedGossiper) InitSyncState(syncPeer lnpeer.Peer)
- func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message, source *btcec.PublicKey, ...) chan er.R
- func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message, peer lnpeer.Peer) chan er.R
- func (d *AuthenticatedGossiper) PropagateChanPolicyUpdate(edgesToUpdate []EdgeWithInfo) er.R
- func (d *AuthenticatedGossiper) PruneSyncState(peer route.Vertex)
- func (d *AuthenticatedGossiper) Start() er.R
- func (d *AuthenticatedGossiper) Stop()
- func (d *AuthenticatedGossiper) SyncManager() *SyncManager
- type ChanSeries
- func (c *ChanSeries) FetchChanAnns(chain chainhash.Hash, shortChanIDs []lnwire.ShortChannelID) ([]lnwire.Message, er.R)
- func (c *ChanSeries) FetchChanUpdates(chain chainhash.Hash, shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, er.R)
- func (c *ChanSeries) FilterChannelRange(chain chainhash.Hash, startHeight, endHeight uint32) ([]lnwire.ShortChannelID, er.R)
- func (c *ChanSeries) FilterKnownChanIDs(chain chainhash.Hash, superSet []lnwire.ShortChannelID) ([]lnwire.ShortChannelID, er.R)
- func (c *ChanSeries) HighestChanID(chain chainhash.Hash) (*lnwire.ShortChannelID, er.R)
- func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash, startTime time.Time, endTime time.Time) ([]lnwire.Message, er.R)
- type ChannelGraphBootstrapper
- type ChannelGraphTimeSeries
- type Config
- type DNSSeedBootstrapper
- type EdgeWithInfo
- type GossipMessageStore
- type GossipSyncer
- func (g *GossipSyncer) ApplyGossipFilter(filter *lnwire.GossipTimestampRange) er.R
- func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders)
- func (g *GossipSyncer) ProcessQueryMsg(msg lnwire.Message, peerQuit <-chan struct{})
- func (g *GossipSyncer) ProcessSyncTransition(newSyncType SyncerType) er.R
- func (g *GossipSyncer) ResetSyncedSignal() chan struct{}
- func (g *GossipSyncer) Start()
- func (g *GossipSyncer) Stop()
- func (g *GossipSyncer) SyncType() SyncerType
- type MessageStore
- func (s *MessageStore) AddMessage(msg lnwire.Message, peerPubKey [33]byte) er.R
- func (s *MessageStore) DeleteMessage(msg lnwire.Message, peerPubKey [33]byte) er.R
- func (s *MessageStore) Messages() (map[[33]byte][]lnwire.Message, er.R)
- func (s *MessageStore) MessagesForPeer(peerPubKey [33]byte) ([]lnwire.Message, er.R)
- func (s *MessageStore) Peers() (map[[33]byte]struct{}, er.R)
- type NetworkPeerBootstrapper
- type OptionalMsgField
- type SyncManager
- func (m *SyncManager) GossipSyncer(peer route.Vertex) (*GossipSyncer, bool)
- func (m *SyncManager) GossipSyncers() map[route.Vertex]*GossipSyncer
- func (m *SyncManager) InitSyncState(peer lnpeer.Peer) er.R
- func (m *SyncManager) IsGraphSynced() bool
- func (m *SyncManager) PruneSyncState(peer route.Vertex)
- func (m *SyncManager) Start()
- func (m *SyncManager) Stop()
- type SyncManagerCfg
- type SyncerType
Constants ¶
const ( // DefaultSyncerRotationInterval is the default interval in which we'll // rotate a single active syncer. DefaultSyncerRotationInterval = 20 * time.Minute // DefaultHistoricalSyncInterval is the default interval in which we'll // force a historical sync to ensure we have as much of the public // network as possible. DefaultHistoricalSyncInterval = time.Hour )
const ( // DefaultMaxUndelayedQueryReplies specifies how many gossip queries we // will respond to immediately before starting to delay responses. DefaultMaxUndelayedQueryReplies = 10 // DefaultDelayedQueryReplyInterval is the length of time we will wait // before responding to gossip queries after replying to // maxUndelayedQueryReplies queries. DefaultDelayedQueryReplyInterval = 5 * time.Second )
Variables ¶
var ( Err = er.NewErrorType("lnd.discovery") // ErrGossiperShuttingDown is an error that is returned if the gossiper // is in the process of being shut down. ErrGossiperShuttingDown = Err.CodeWithDetail("ErrGossiperShuttingDown", "gossiper is shutting down") // ErrGossipSyncerNotFound signals that we were unable to find an active // gossip syncer corresponding to a gossip query message received from // the remote peer. ErrGossipSyncerNotFound = Err.CodeWithDetail("ErrGossipSyncerNotFound", "gossip syncer not found") )
var ( // ErrUnsupportedMessage is an error returned when we attempt to add a // message to the store that is not supported. ErrUnsupportedMessage = Err.CodeWithDetail("ErrUnsupportedMessage", "unsupported message type") // ErrCorruptedMessageStore indicates that the on-disk bucketing // structure has altered since the gossip message store instance was // initialized. ErrCorruptedMessageStore = Err.CodeWithDetail("ErrCorruptedMessageStore", "gossip message store has been "+ "corrupted") )
var ( // ErrGossipSyncerExiting signals that the syncer has been killed. ErrGossipSyncerExiting = Err.CodeWithDetail("ErrGossipSyncerExiting", "gossip syncer exiting") // ErrSyncTransitionTimeout is an error returned when we've timed out // attempting to perform a sync transition. ErrSyncTransitionTimeout = Err.CodeWithDetail("ErrSyncTransitionTimeout", "timed out attempting to "+ "transition sync type") )
var ( // ErrSyncManagerExiting is an error returned when we attempt to // start/stop a gossip syncer for a connected/disconnected peer, but the // SyncManager has already been stopped. ErrSyncManagerExiting = Err.CodeWithDetail("ErrSyncManagerExiting", "sync manager exiting") )
Functions ¶
func MultiSourceBootstrap ¶
func MultiSourceBootstrap(ignore map[autopilot.NodeID]struct{}, numAddrs uint32, bootstrappers ...NetworkPeerBootstrapper) ([]*lnwire.NetAddress, er.R)
MultiSourceBootstrap attempts to utilize a set of NetworkPeerBootstrapper passed in to return the target (numAddrs) number of peer addresses that can be used to bootstrap a peer just joining the Lightning Network. Each bootstrapper will be queried successively until the target amount is met. If the ignore map is populated, then the bootstrappers will be instructed to skip those nodes.
Types ¶
type AuthenticatedGossiper ¶
AuthenticatedGossiper is a subsystem which is responsible for receiving announcements, validating them and applying the changes to router, syncing lightning network with newly connected nodes, broadcasting announcements after validation, negotiating the channel announcement proofs exchange and handling the premature announcements. All outgoing announcements are expected to be properly signed as dictated in BOLT#7, additionally, all incoming message are expected to be well formed and signed. Invalid messages will be rejected by this struct.
func New ¶
func New(cfg Config, selfKey *btcec.PublicKey) *AuthenticatedGossiper
New creates a new AuthenticatedGossiper instance, initialized with the passed configuration parameters.
func (*AuthenticatedGossiper) InitSyncState ¶
func (d *AuthenticatedGossiper) InitSyncState(syncPeer lnpeer.Peer)
InitSyncState is called by outside sub-systems when a connection is established to a new peer that understands how to perform channel range queries. We'll allocate a new gossip syncer for it, and start any goroutines needed to handle new queries.
func (*AuthenticatedGossiper) ProcessLocalAnnouncement ¶
func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message, source *btcec.PublicKey, optionalFields ...OptionalMsgField) chan er.R
ProcessLocalAnnouncement sends a new remote announcement message along with the peer that sent the routing message. The announcement will be processed then added to a queue for batched trickled announcement to all connected peers. Local channel announcements don't contain the announcement proof and will not be fully validated. Once the channel proofs are received, the entire channel announcement and update messages will be re-constructed and broadcast to the rest of the network.
func (*AuthenticatedGossiper) ProcessRemoteAnnouncement ¶
func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message, peer lnpeer.Peer) chan er.R
ProcessRemoteAnnouncement sends a new remote announcement message along with the peer that sent the routing message. The announcement will be processed then added to a queue for batched trickled announcement to all connected peers. Remote channel announcements should contain the announcement proof and be fully validated.
func (*AuthenticatedGossiper) PropagateChanPolicyUpdate ¶
func (d *AuthenticatedGossiper) PropagateChanPolicyUpdate( edgesToUpdate []EdgeWithInfo) er.R
PropagateChanPolicyUpdate signals the AuthenticatedGossiper to perform the specified edge updates. Updates are done in two stages: first, the AuthenticatedGossiper ensures the update has been committed by dependent sub-systems, then it signs and broadcasts new updates to the network. A mapping between outpoints and updated channel policies is returned, which is used to update the forwarding policies of the underlying links.
func (*AuthenticatedGossiper) PruneSyncState ¶
func (d *AuthenticatedGossiper) PruneSyncState(peer route.Vertex)
PruneSyncState is called by outside sub-systems once a peer that we were previously connected to has been disconnected. In this case we can stop the existing GossipSyncer assigned to the peer and free up resources.
func (*AuthenticatedGossiper) Start ¶
func (d *AuthenticatedGossiper) Start() er.R
Start spawns network messages handler goroutine and registers on new block notifications in order to properly handle the premature announcements.
func (*AuthenticatedGossiper) Stop ¶
func (d *AuthenticatedGossiper) Stop()
Stop signals any active goroutines for a graceful closure.
func (*AuthenticatedGossiper) SyncManager ¶
func (d *AuthenticatedGossiper) SyncManager() *SyncManager
SyncManager returns the gossiper's SyncManager instance.
type ChanSeries ¶
type ChanSeries struct {
// contains filtered or unexported fields
}
ChanSeries is an implementation of the ChannelGraphTimeSeries interface backed by the channeldb ChannelGraph database. We'll provide this implementation to the AuthenticatedGossiper so it can properly use the in-protocol channel range queries to quickly and efficiently synchronize our channel state with all peers.
func NewChanSeries ¶
func NewChanSeries(graph *channeldb.ChannelGraph) *ChanSeries
NewChanSeries constructs a new ChanSeries backed by a channeldb.ChannelGraph. The returned ChanSeries implements the ChannelGraphTimeSeries interface.
func (*ChanSeries) FetchChanAnns ¶
func (c *ChanSeries) FetchChanAnns(chain chainhash.Hash, shortChanIDs []lnwire.ShortChannelID) ([]lnwire.Message, er.R)
FetchChanAnns returns a full set of channel announcements as well as their updates that match the set of specified short channel ID's. We'll use this to reply to a QueryShortChanIDs message sent by a remote peer. The response will contain a unique set of ChannelAnnouncements, the latest ChannelUpdate for each of the announcements, and a unique set of NodeAnnouncements.
NOTE: This is part of the ChannelGraphTimeSeries interface.
func (*ChanSeries) FetchChanUpdates ¶
func (c *ChanSeries) FetchChanUpdates(chain chainhash.Hash, shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, er.R)
FetchChanUpdates returns the latest channel update messages for the specified short channel ID. If no channel updates are known for the channel, then an empty slice will be returned.
NOTE: This is part of the ChannelGraphTimeSeries interface.
func (*ChanSeries) FilterChannelRange ¶
func (c *ChanSeries) FilterChannelRange(chain chainhash.Hash, startHeight, endHeight uint32) ([]lnwire.ShortChannelID, er.R)
FilterChannelRange returns the set of channels that we created between the start height and the end height. We'll use this respond to a remote peer's QueryChannelRange message.
NOTE: This is part of the ChannelGraphTimeSeries interface.
func (*ChanSeries) FilterKnownChanIDs ¶
func (c *ChanSeries) FilterKnownChanIDs(chain chainhash.Hash, superSet []lnwire.ShortChannelID) ([]lnwire.ShortChannelID, er.R)
FilterKnownChanIDs takes a target chain, and a set of channel ID's, and returns a filtered set of chan ID's. This filtered set of chan ID's represents the ID's that we don't know of which were in the passed superSet.
NOTE: This is part of the ChannelGraphTimeSeries interface.
func (*ChanSeries) HighestChanID ¶
func (c *ChanSeries) HighestChanID(chain chainhash.Hash) (*lnwire.ShortChannelID, er.R)
HighestChanID should return is the channel ID of the channel we know of that's furthest in the target chain. This channel will have a block height that's close to the current tip of the main chain as we know it. We'll use this to start our QueryChannelRange dance with the remote node.
NOTE: This is part of the ChannelGraphTimeSeries interface.
func (*ChanSeries) UpdatesInHorizon ¶
func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash, startTime time.Time, endTime time.Time) ([]lnwire.Message, er.R)
UpdatesInHorizon returns all known channel and node updates with an update timestamp between the start time and end time. We'll use this to catch up a remote node to the set of channel updates that they may have missed out on within the target chain.
NOTE: This is part of the ChannelGraphTimeSeries interface.
type ChannelGraphBootstrapper ¶
type ChannelGraphBootstrapper struct {
// contains filtered or unexported fields
}
ChannelGraphBootstrapper is an implementation of the NetworkPeerBootstrapper which attempts to retrieve advertised peers directly from the active channel graph. This instance requires a backing autopilot.ChannelGraph instance in order to operate properly.
func (*ChannelGraphBootstrapper) Name ¶
func (c *ChannelGraphBootstrapper) Name() string
Name returns a human readable string which names the concrete implementation of the NetworkPeerBootstrapper.
NOTE: Part of the NetworkPeerBootstrapper interface.
func (*ChannelGraphBootstrapper) SampleNodeAddrs ¶
func (c *ChannelGraphBootstrapper) SampleNodeAddrs(numAddrs uint32, ignore map[autopilot.NodeID]struct{}) ([]*lnwire.NetAddress, er.R)
SampleNodeAddrs uniformly samples a set of specified address from the network peer bootstrapper source. The num addrs field passed in denotes how many valid peer addresses to return.
NOTE: Part of the NetworkPeerBootstrapper interface.
type ChannelGraphTimeSeries ¶
type ChannelGraphTimeSeries interface { // HighestChanID should return the channel ID of the channel we know of // that's furthest in the target chain. This channel will have a block // height that's close to the current tip of the main chain as we // know it. We'll use this to start our QueryChannelRange dance with // the remote node. HighestChanID(chain chainhash.Hash) (*lnwire.ShortChannelID, er.R) // UpdatesInHorizon returns all known channel and node updates with an // update timestamp between the start time and end time. We'll use this // to catch up a remote node to the set of channel updates that they // may have missed out on within the target chain. UpdatesInHorizon(chain chainhash.Hash, startTime time.Time, endTime time.Time) ([]lnwire.Message, er.R) // FilterKnownChanIDs takes a target chain, and a set of channel ID's, // and returns a filtered set of chan ID's. This filtered set of chan // ID's represents the ID's that we don't know of which were in the // passed superSet. FilterKnownChanIDs(chain chainhash.Hash, superSet []lnwire.ShortChannelID) ([]lnwire.ShortChannelID, er.R) // FilterChannelRange returns the set of channels that we created // between the start height and the end height. We'll use this to to a // remote peer's QueryChannelRange message. FilterChannelRange(chain chainhash.Hash, startHeight, endHeight uint32) ([]lnwire.ShortChannelID, er.R) // FetchChanAnns returns a full set of channel announcements as well as // their updates that match the set of specified short channel ID's. // We'll use this to reply to a QueryShortChanIDs message sent by a // remote peer. The response will contain a unique set of // ChannelAnnouncements, the latest ChannelUpdate for each of the // announcements, and a unique set of NodeAnnouncements. FetchChanAnns(chain chainhash.Hash, shortChanIDs []lnwire.ShortChannelID) ([]lnwire.Message, er.R) // FetchChanUpdates returns the latest channel update messages for the // specified short channel ID. If no channel updates are known for the // channel, then an empty slice will be returned. FetchChanUpdates(chain chainhash.Hash, shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, er.R) }
ChannelGraphTimeSeries is an interface that provides time and block based querying into our view of the channel graph. New channels will have monotonically increasing block heights, and new channel updates will have increasing timestamps. Once we connect to a peer, we'll use the methods in this interface to determine if we're already in sync, or need to request some new information from them.
type Config ¶
type Config struct { // ChainHash is a hash that indicates which resident chain of the // AuthenticatedGossiper. Any announcements that don't match this // chain hash will be ignored. // // TODO(roasbeef): eventually make into map so can de-multiplex // incoming announcements // * also need to do same for Notifier ChainHash chainhash.Hash // Router is the subsystem which is responsible for managing the // topology of lightning network. After incoming channel, node, channel // updates announcements are validated they are sent to the router in // order to be included in the LN graph. Router routing.ChannelGraphSource // ChanSeries is an interfaces that provides access to a time series // view of the current known channel graph. Each GossipSyncer enabled // peer will utilize this in order to create and respond to channel // graph time series queries. ChanSeries ChannelGraphTimeSeries // Notifier is used for receiving notifications of incoming blocks. // With each new incoming block found we process previously premature // announcements. // // TODO(roasbeef): could possibly just replace this with an epoch // channel. Notifier chainntnfs.ChainNotifier // Broadcast broadcasts a particular set of announcements to all peers // that the daemon is connected to. If supplied, the exclude parameter // indicates that the target peer should be excluded from the // broadcast. Broadcast func(skips map[route.Vertex]struct{}, msg ...lnwire.Message) er.R // NotifyWhenOnline is a function that allows the gossiper to be // notified when a certain peer comes online, allowing it to // retry sending a peer message. // // NOTE: The peerChan channel must be buffered. NotifyWhenOnline func(peerPubKey [33]byte, peerChan chan<- lnpeer.Peer) // NotifyWhenOffline is a function that allows the gossiper to be // notified when a certain peer disconnects, allowing it to request a // notification for when it reconnects. NotifyWhenOffline func(peerPubKey [33]byte) <-chan struct{} // SelfNodeAnnouncement is a function that fetches our own current node // announcement, for use when determining whether we should update our // peers about our presence on the network. If the refresh is true, a // new and updated announcement will be returned. SelfNodeAnnouncement func(refresh bool) (lnwire.NodeAnnouncement, er.R) // ProofMatureDelta the number of confirmations which is needed before // exchange the channel announcement proofs. ProofMatureDelta uint32 // TrickleDelay the period of trickle timer which flushes to the // network the pending batch of new announcements we've received since // the last trickle tick. TrickleDelay time.Duration // RetransmitTicker is a ticker that ticks with a period which // indicates that we should check if we need re-broadcast any of our // personal channels. RetransmitTicker ticker.Ticker // RebroadcastInterval is the maximum time we wait between sending out // channel updates for our active channels and our own node // announcement. We do this to ensure our active presence on the // network is known, and we are not being considered a zombie node or // having zombie channels. RebroadcastInterval time.Duration // WaitingProofStore is a persistent storage of partial channel proof // announcement messages. We use it to buffer half of the material // needed to reconstruct a full authenticated channel announcement. // Once we receive the other half the channel proof, we'll be able to // properly validate it and re-broadcast it out to the network. // // TODO(wilmer): make interface to prevent channeldb dependency. WaitingProofStore *channeldb.WaitingProofStore // MessageStore is a persistent storage of gossip messages which we will // use to determine which messages need to be resent for a given peer. MessageStore GossipMessageStore // AnnSigner is an instance of the MessageSigner interface which will // be used to manually sign any outgoing channel updates. The signer // implementation should be backed by the public key of the backing // Lightning node. // // TODO(roasbeef): extract ann crafting + sign from fundingMgr into // here? AnnSigner lnwallet.MessageSigner // NumActiveSyncers is the number of peers for which we should have // active syncers with. After reaching NumActiveSyncers, any future // gossip syncers will be passive. NumActiveSyncers int // RotateTicker is a ticker responsible for notifying the SyncManager // when it should rotate its active syncers. A single active syncer with // a chansSynced state will be exchanged for a passive syncer in order // to ensure we don't keep syncing with the same peers. RotateTicker ticker.Ticker // HistoricalSyncTicker is a ticker responsible for notifying the // syncManager when it should attempt a historical sync with a gossip // sync peer. HistoricalSyncTicker ticker.Ticker // ActiveSyncerTimeoutTicker is a ticker responsible for notifying the // syncManager when it should attempt to start the next pending // activeSyncer due to the current one not completing its state machine // within the timeout. ActiveSyncerTimeoutTicker ticker.Ticker // MinimumBatchSize is minimum size of a sub batch of announcement // messages. MinimumBatchSize int // SubBatchDelay is the delay between sending sub batches of // gossip messages. SubBatchDelay time.Duration // IgnoreHistoricalFilters will prevent syncers from replying with // historical data when the remote peer sets a gossip_timestamp_range. // This prevents ranges with old start times from causing us to dump the // graph on connect. IgnoreHistoricalFilters bool }
Config defines the configuration for the service. ALL elements within the configuration MUST be non-nil for the service to carry out its duties.
type DNSSeedBootstrapper ¶
type DNSSeedBootstrapper struct {
// contains filtered or unexported fields
}
DNSSeedBootstrapper as an implementation of the NetworkPeerBootstrapper interface which implements peer bootstrapping via a special DNS seed as defined in BOLT-0010. For further details concerning Lightning's current DNS boot strapping protocol, see this link:
func (*DNSSeedBootstrapper) Name ¶
func (d *DNSSeedBootstrapper) Name() string
Name returns a human readable string which names the concrete implementation of the NetworkPeerBootstrapper.
func (*DNSSeedBootstrapper) SampleNodeAddrs ¶
func (d *DNSSeedBootstrapper) SampleNodeAddrs(numAddrs uint32, ignore map[autopilot.NodeID]struct{}) ([]*lnwire.NetAddress, er.R)
SampleNodeAddrs uniformly samples a set of specified address from the network peer bootstrapper source. The num addrs field passed in denotes how many valid peer addresses to return. The set of DNS seeds are used successively to retrieve eligible target nodes.
type EdgeWithInfo ¶
type EdgeWithInfo struct { // Info describes the channel. Info *channeldb.ChannelEdgeInfo // Edge describes the policy in one direction of the channel. Edge *channeldb.ChannelEdgePolicy }
EdgeWithInfo contains the information that is required to update an edge.
type GossipMessageStore ¶
type GossipMessageStore interface { // AddMessage adds a message to the store for this peer. AddMessage(lnwire.Message, [33]byte) er.R // DeleteMessage deletes a message from the store for this peer. DeleteMessage(lnwire.Message, [33]byte) er.R // Messages returns the total set of messages that exist within the // store for all peers. Messages() (map[[33]byte][]lnwire.Message, er.R) // Peers returns the public key of all peers with messages within the // store. Peers() (map[[33]byte]struct{}, er.R) // MessagesForPeer returns the set of messages that exists within the // store for the given peer. MessagesForPeer([33]byte) ([]lnwire.Message, er.R) }
GossipMessageStore is a store responsible for storing gossip messages which we should reliably send to our peers.
type GossipSyncer ¶
GossipSyncer is a struct that handles synchronizing the channel graph state with a remote peer. The GossipSyncer implements a state machine that will progressively ensure we're synchronized with the channel state of the remote node. Once both nodes have been synchronized, we'll use an update filter to filter out which messages should be sent to a remote peer based on their update horizon. If the update horizon isn't specified, then we won't send them any channel updates at all.
func (*GossipSyncer) ApplyGossipFilter ¶
func (g *GossipSyncer) ApplyGossipFilter(filter *lnwire.GossipTimestampRange) er.R
ApplyGossipFilter applies a gossiper filter sent by the remote node to the state machine. Once applied, we'll ensure that we don't forward any messages to the peer that aren't within the time range of the filter.
func (*GossipSyncer) FilterGossipMsgs ¶
func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders)
FilterGossipMsgs takes a set of gossip messages, and only send it to a peer iff the message is within the bounds of their set gossip filter. If the peer doesn't have a gossip filter set, then no messages will be forwarded.
func (*GossipSyncer) ProcessQueryMsg ¶
func (g *GossipSyncer) ProcessQueryMsg(msg lnwire.Message, peerQuit <-chan struct{})
ProcessQueryMsg is used by outside callers to pass new channel time series queries to the internal processing goroutine.
func (*GossipSyncer) ProcessSyncTransition ¶
func (g *GossipSyncer) ProcessSyncTransition(newSyncType SyncerType) er.R
ProcessSyncTransition sends a request to the gossip syncer to transition its sync type to a new one.
NOTE: This can only be done once the gossip syncer has reached its final chansSynced state.
func (*GossipSyncer) ResetSyncedSignal ¶
func (g *GossipSyncer) ResetSyncedSignal() chan struct{}
ResetSyncedSignal returns a channel that will be closed in order to serve as a signal for when the GossipSyncer has reached its chansSynced state.
func (*GossipSyncer) Start ¶
func (g *GossipSyncer) Start()
Start starts the GossipSyncer and any goroutines that it needs to carry out its duties.
func (*GossipSyncer) Stop ¶
func (g *GossipSyncer) Stop()
Stop signals the GossipSyncer for a graceful exit, then waits until it has exited.
func (*GossipSyncer) SyncType ¶
func (g *GossipSyncer) SyncType() SyncerType
SyncType returns the current SyncerType of the target GossipSyncer.
type MessageStore ¶
type MessageStore struct {
// contains filtered or unexported fields
}
MessageStore is an implementation of the GossipMessageStore interface backed by a channeldb instance. By design, this store will only keep the latest version of a message (like in the case of multiple ChannelUpdate's) for a channel with a peer.
func NewMessageStore ¶
func NewMessageStore(db *channeldb.DB) (*MessageStore, er.R)
NewMessageStore creates a new message store backed by a channeldb instance.
func (*MessageStore) AddMessage ¶
AddMessage adds a message to the store for this peer.
func (*MessageStore) DeleteMessage ¶
DeleteMessage deletes a message from the store for this peer.
func (*MessageStore) Messages ¶
Messages returns the total set of messages that exist within the store for all peers.
func (*MessageStore) MessagesForPeer ¶
MessagesForPeer returns the set of messages that exists within the store for the given peer.
type NetworkPeerBootstrapper ¶
type NetworkPeerBootstrapper interface { // SampleNodeAddrs uniformly samples a set of specified address from // the network peer bootstrapper source. The num addrs field passed in // denotes how many valid peer addresses to return. The passed set of // node nodes allows the caller to ignore a set of nodes perhaps // because they already have connections established. SampleNodeAddrs(numAddrs uint32, ignore map[autopilot.NodeID]struct{}) ([]*lnwire.NetAddress, er.R) // Name returns a human readable string which names the concrete // implementation of the NetworkPeerBootstrapper. Name() string }
NetworkPeerBootstrapper is an interface that represents an initial peer bootstrap mechanism. This interface is to be used to bootstrap a new peer to the connection by providing it with the pubkey+address of a set of existing peers on the network. Several bootstrap mechanisms can be implemented such as DNS, in channel graph, DHT's, etc.
func NewDNSSeedBootstrapper ¶
func NewDNSSeedBootstrapper( seeds [][2]string, net tor.Net, timeout time.Duration) NetworkPeerBootstrapper
NewDNSSeedBootstrapper returns a new instance of the DNSSeedBootstrapper. The set of passed seeds should point to DNS servers that properly implement Lightning's DNS peer bootstrapping protocol as defined in BOLT-0010. The set of passed DNS seeds should come in pairs, with the second host name to be used as a fallback for manual TCP resolution in the case of an error receiving the UDP response. The second host should return a single A record with the IP address of the authoritative name server.
func NewGraphBootstrapper ¶
func NewGraphBootstrapper(cg autopilot.ChannelGraph) (NetworkPeerBootstrapper, er.R)
NewGraphBootstrapper returns a new instance of a ChannelGraphBootstrapper backed by an active autopilot.ChannelGraph instance. This type of network peer bootstrapper will use the authenticated nodes within the known channel graph to bootstrap connections.
type OptionalMsgField ¶
type OptionalMsgField func(*optionalMsgFields)
OptionalMsgField is a functional option parameter that can be used to provide external information that is not included within a network message but serves useful when processing it.
func ChannelCapacity ¶
func ChannelCapacity(capacity btcutil.Amount) OptionalMsgField
ChannelCapacity is an optional field that lets the gossiper know of the capacity of a channel.
func ChannelPoint ¶
func ChannelPoint(op wire.OutPoint) OptionalMsgField
ChannelPoint is an optional field that lets the gossiper know of the outpoint of a channel.
type SyncManager ¶
type SyncManager struct {
// contains filtered or unexported fields
}
SyncManager is a subsystem of the gossiper that manages the gossip syncers for peers currently connected. When a new peer is connected, the manager will create its accompanying gossip syncer and determine whether it should have an ActiveSync or PassiveSync sync type based on how many other gossip syncers are currently active. Any ActiveSync gossip syncers are started in a round-robin manner to ensure we're not syncing with multiple peers at the same time. The first GossipSyncer registered with the SyncManager will attempt a historical sync to ensure we have as much of the public channel graph as possible.
func (*SyncManager) GossipSyncer ¶
func (m *SyncManager) GossipSyncer(peer route.Vertex) (*GossipSyncer, bool)
GossipSyncer returns the associated gossip syncer of a peer. The boolean returned signals whether there exists a gossip syncer for the peer.
func (*SyncManager) GossipSyncers ¶
func (m *SyncManager) GossipSyncers() map[route.Vertex]*GossipSyncer
GossipSyncers returns all of the currently initialized gossip syncers.
func (*SyncManager) InitSyncState ¶
func (m *SyncManager) InitSyncState(peer lnpeer.Peer) er.R
InitSyncState is called by outside sub-systems when a connection is established to a new peer that understands how to perform channel range queries. We'll allocate a new GossipSyncer for it, and start any goroutines needed to handle new queries. The first GossipSyncer registered with the SyncManager will attempt a historical sync to ensure we have as much of the public channel graph as possible.
TODO(wilmer): Only mark as ActiveSync if this isn't a channel peer.
func (*SyncManager) IsGraphSynced ¶
func (m *SyncManager) IsGraphSynced() bool
IsGraphSynced determines whether we've completed our initial historical sync. The initial historical sync is done to ensure we've ingested as much of the public graph as possible.
func (*SyncManager) PruneSyncState ¶
func (m *SyncManager) PruneSyncState(peer route.Vertex)
PruneSyncState is called by outside sub-systems once a peer that we were previously connected to has been disconnected. In this case we can stop the existing GossipSyncer assigned to the peer and free up resources.
func (*SyncManager) Start ¶
func (m *SyncManager) Start()
Start starts the SyncManager in order to properly carry out its duties.
func (*SyncManager) Stop ¶
func (m *SyncManager) Stop()
Stop stops the SyncManager from performing its duties.
type SyncManagerCfg ¶
type SyncManagerCfg struct { // ChainHash is a hash that indicates the specific network of the active // chain. ChainHash chainhash.Hash // ChanSeries is an interface that provides access to a time series view // of the current known channel graph. Each GossipSyncer enabled peer // will utilize this in order to create and respond to channel graph // time series queries. ChanSeries ChannelGraphTimeSeries // NumActiveSyncers is the number of peers for which we should have // active syncers with. After reaching NumActiveSyncers, any future // gossip syncers will be passive. NumActiveSyncers int // RotateTicker is a ticker responsible for notifying the SyncManager // when it should rotate its active syncers. A single active syncer with // a chansSynced state will be exchanged for a passive syncer in order // to ensure we don't keep syncing with the same peers. RotateTicker ticker.Ticker // HistoricalSyncTicker is a ticker responsible for notifying the // SyncManager when it should attempt a historical sync with a gossip // sync peer. HistoricalSyncTicker ticker.Ticker // IgnoreHistoricalFilters will prevent syncers from replying with // historical data when the remote peer sets a gossip_timestamp_range. // This prevents ranges with old start times from causing us to dump the // graph on connect. IgnoreHistoricalFilters bool }
SyncManagerCfg contains all of the dependencies required for the SyncManager to carry out its duties.
type SyncerType ¶
type SyncerType uint8
SyncerType encapsulates the different types of syncing mechanisms for a gossip syncer.
const ( // ActiveSync denotes that a gossip syncer: // // 1. Should not attempt to synchronize with the remote peer for // missing channels. // 2. Should respond to queries from the remote peer. // 3. Should receive new updates from the remote peer. // // They are started in a chansSynced state in order to accomplish their // responsibilities above. ActiveSync SyncerType = iota // PassiveSync denotes that a gossip syncer: // // 1. Should not attempt to synchronize with the remote peer for // missing channels. // 2. Should respond to queries from the remote peer. // 3. Should not receive new updates from the remote peer. // // They are started in a chansSynced state in order to accomplish their // responsibilities above. PassiveSync )
func (SyncerType) String ¶
func (t SyncerType) String() string
String returns a human readable string describing the target SyncerType.