discovery

package
v0.4.2-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2018 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func MultiSourceBootstrap

func MultiSourceBootstrap(ignore map[autopilot.NodeID]struct{}, numAddrs uint32,
	bootStrappers ...NetworkPeerBootstrapper) ([]*lnwire.NetAddress, error)

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.

func SignAnnouncement

func SignAnnouncement(signer lnwallet.MessageSigner, pubKey *btcec.PublicKey,
	msg lnwire.Message) (*btcec.Signature, error)

SignAnnouncement is a helper function which is used to sign any outgoing channel node node announcement messages.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

func ValidateChannelAnn

func ValidateChannelAnn(a *lnwire.ChannelAnnouncement) error

ValidateChannelAnn validates the channel announcement message and checks that node signatures covers the announcement message, and that the bitcoin signatures covers the node keys.

func ValidateChannelUpdateAnn

func ValidateChannelUpdateAnn(pubKey *btcec.PublicKey,
	a *lnwire.ChannelUpdate) error

ValidateChannelUpdateAnn validates the channel update announcement by checking that the included signature covers he announcement and has been signed by the node's private key.

func ValidateNodeAnn

func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error

ValidateNodeAnn validates the node announcement by ensuring that the attached signature is needed a signature of the node announcement under the specified node public key.

Types

type AuthenticatedGossiper

type AuthenticatedGossiper struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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, error)

New creates a new AuthenticatedGossiper instance, initialized with the passed configuration parameters.

func (*AuthenticatedGossiper) ProcessLocalAnnouncement

func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message,
	src *btcec.PublicKey) chan error

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,
	src *btcec.PublicKey) chan error

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(
	newSchema routing.ChannelPolicy, chanPoints ...wire.OutPoint) error

PropagateChanPolicyUpdate signals the AuthenticatedGossiper to update the channel forwarding policies for the specified channels. If no channels are specified, then the update will be applied to all outgoing channels from the source node. Policy 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.

func (*AuthenticatedGossiper) Start

func (d *AuthenticatedGossiper) Start() error

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) SynchronizeNode

func (d *AuthenticatedGossiper) SynchronizeNode(pub *btcec.PublicKey) error

SynchronizeNode sends a message to the service indicating it should synchronize lightning topology state with the target node. This method is to be utilized when a node connections for the first time to provide it with the latest topology update state. In order to accomplish this, (currently) the entire network graph is read from disk, then serialized to the format defined within the current wire protocol. This cache of graph data is then sent directly to the target node.

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, error)

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 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

	// 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[routing.Vertex]struct{},
		msg ...lnwire.Message) error

	// SendToPeer is a function which allows the service to send a set of
	// messages to a particular peer identified by the target public key.
	SendToPeer func(target *btcec.PublicKey, msg ...lnwire.Message) error

	// 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.
	NotifyWhenOnline func(peer *btcec.PublicKey, connectedChan chan<- struct{})

	// 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

	// RetransmitDelay is the period of a timer which indicates that we
	// should check if we need re-broadcast any of our personal channels.
	RetransmitDelay time.Duration

	// DB is a global boltdb instance which is needed to pass it in waiting
	// proof storage to make waiting proofs persistent.
	DB *channeldb.DB

	// 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
}

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, error)

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 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, error)

	// 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, lookupHost func(string) ([]string, error),
	lookupSRV func(string, string, string) (string, []*net.SRV, error)) (
	NetworkPeerBootstrapper, error)

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, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL