Documentation ¶
Index ¶
- Constants
- type HandleFuncType
- type Message
- type MessageProcessor
- type NetSettings
- type NewListeningPortEvent
- type NewPeerEvent
- type ParseFuncType
- type Peer
- func (p *Peer) GetIdx() uint32
- func (p *Peer) GetLnAddr() lncore.LnAddr
- func (p *Peer) GetNickname() string
- func (p *Peer) GetPrettyName() string
- func (p *Peer) GetPubkey() koblitz.PublicKey
- func (p *Peer) GetRemoteAddr() string
- func (p *Peer) IntoPeerInfo() lncore.PeerInfo
- func (p *Peer) SendImmediateMessage(msg Message) error
- func (p *Peer) SendQueuedMessage(msg Message) error
- func (p *Peer) SetNickname(name string)
- type PeerDisconnectEvent
- type PeerManager
- func (pm *PeerManager) DisconnectPeer(peer *Peer) error
- func (pm *PeerManager) GetExternalAddress() string
- func (pm *PeerManager) GetListeningAddrs() []string
- func (pm *PeerManager) GetMessageProcessor() *MessageProcessor
- func (pm *PeerManager) GetPeer(lnaddr lncore.LnAddr) *Peer
- func (pm *PeerManager) GetPeerByIdx(id int32) *Peer
- func (pm *PeerManager) GetPeerIdx(peer *Peer) uint32
- func (pm *PeerManager) ListenOnPort(port int) error
- func (pm *PeerManager) StartSending() error
- func (pm *PeerManager) StopListening(port int) error
- func (pm *PeerManager) StopSending() error
- func (pm *PeerManager) TmpHintPeerIdx(peer *Peer, idx uint32) error
- func (pm *PeerManager) TryConnectAddress(addr string) (*Peer, error)
- type StopListeningPortEvent
Constants ¶
const MaxNodeCount = 1024
MaxNodeCount is the size of the peerIdx->LnAddr array. TEMP This shouldn't be necessary.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandleFuncType ¶
HandleFuncType is the type of a Message handler function, handling for a particular peer.
type MessageProcessor ¶
type MessageProcessor struct {
// contains filtered or unexported fields
}
MessageProcessor is can be given messages and figures out how to parse them and which function to call.
func NewMessageProcessor ¶
func NewMessageProcessor() MessageProcessor
NewMessageProcessor processes messages coming in from over the network.
func (*MessageProcessor) Activate ¶
func (mp *MessageProcessor) Activate()
Activate sets the MessageProcessor to be "active"
func (*MessageProcessor) DefineMessage ¶
func (mp *MessageProcessor) DefineMessage(mtype uint8, pfunc ParseFuncType, hfunc HandleFuncType)
DefineMessage defines processing routines for a particular message type.
func (*MessageProcessor) HandleMessage ¶
func (mp *MessageProcessor) HandleMessage(peer *Peer, buf []byte) error
HandleMessage runs through the normal handling procedure for the message, returning any errors.
func (*MessageProcessor) IsActive ¶
func (mp *MessageProcessor) IsActive() bool
IsActive returns the activiation state for the MessageProcessor.
type NetSettings ¶
type NetSettings struct { NatMode *string `json:"natmode"` ProxyAddr *string `json:"proxyserv"` ProxyAuth *string `json:"proxyauth"` }
NetSettings is a container struct for misc network settings like NAT holepunching and proxies.
type NewListeningPortEvent ¶
type NewListeningPortEvent struct {
ListenPort int
}
NewListeningPortEvent .
type NewPeerEvent ¶
type NewPeerEvent struct { Addr lncore.LnAddr Peer *Peer RemoteInitiated bool // TODO REFACTORING: Remove these RemotePub *koblitz.PublicKey Conn *lndc.Conn }
NewPeerEvent is fired when a new peer is registered.
type ParseFuncType ¶
ParseFuncType is the type of a Message parser function.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
A Peer is a remote client that's somehow connected to us.
func (*Peer) GetNickname ¶
GetNickname returns the nickname, or an empty string if unset.
func (*Peer) GetPrettyName ¶
GetPrettyName returns a more human-readable name, such as the nickname if available or a trucated version of the LN address otherwise.
func (*Peer) IntoPeerInfo ¶
IntoPeerInfo generates the PeerInfo DB struct for the Peer.
func (*Peer) SendImmediateMessage ¶
SendImmediateMessage adds a message to the queue but waits for the message to be sent before returning, also returning errors that might have occurred when sending the message, like the peer disconnecting.
func (*Peer) SendQueuedMessage ¶
SendQueuedMessage adds the message to the queue to be sent to this peer. This queue is shared across all peers.
func (*Peer) SetNickname ¶
SetNickname sets the peer's nickname.
type PeerDisconnectEvent ¶
PeerDisconnectEvent is fired when a peer is disconnected.
type PeerManager ¶
type PeerManager struct {
// contains filtered or unexported fields
}
PeerManager .
func NewPeerManager ¶
func NewPeerManager(rootkey *hdkeychain.ExtendedKey, pdb lncore.LitPeerStorage, trackerURL string, bus *eventbus.EventBus, ns *NetSettings) (*PeerManager, error)
NewPeerManager creates a peer manager from a root key
func (*PeerManager) DisconnectPeer ¶
func (pm *PeerManager) DisconnectPeer(peer *Peer) error
DisconnectPeer disconnects a peer from ourselves and does relevant cleanup.
func (*PeerManager) GetExternalAddress ¶
func (pm *PeerManager) GetExternalAddress() string
GetExternalAddress returns the human-readable LN address
func (*PeerManager) GetListeningAddrs ¶
func (pm *PeerManager) GetListeningAddrs() []string
GetListeningAddrs returns the listening addresses.
func (*PeerManager) GetMessageProcessor ¶
func (pm *PeerManager) GetMessageProcessor() *MessageProcessor
GetMessageProcessor gets the message processor for this peer manager that's passed incoming messasges from peers.
func (*PeerManager) GetPeer ¶
func (pm *PeerManager) GetPeer(lnaddr lncore.LnAddr) *Peer
GetPeer returns the peer with the given lnaddr.
func (*PeerManager) GetPeerByIdx ¶
func (pm *PeerManager) GetPeerByIdx(id int32) *Peer
GetPeerByIdx is a compatibility function for getting a peer by its "peer id".
func (*PeerManager) GetPeerIdx ¶
func (pm *PeerManager) GetPeerIdx(peer *Peer) uint32
GetPeerIdx is a convenience function for working with older code.
func (*PeerManager) ListenOnPort ¶
func (pm *PeerManager) ListenOnPort(port int) error
ListenOnPort attempts to start a goroutine lisening on the port.
func (*PeerManager) StartSending ¶
func (pm *PeerManager) StartSending() error
StartSending starts a goroutine to start sending queued messages out to peers.
func (*PeerManager) StopListening ¶
func (pm *PeerManager) StopListening(port int) error
StopListening closes the socket listened on the given address, stopping the goroutine.
func (*PeerManager) StopSending ¶
func (pm *PeerManager) StopSending() error
StopSending has us stop sending new messages to peers.
func (*PeerManager) TmpHintPeerIdx ¶
func (pm *PeerManager) TmpHintPeerIdx(peer *Peer, idx uint32) error
TmpHintPeerIdx sets the peer idx hint for a particular peer. TEMP This should be removed at some point in the future.
func (*PeerManager) TryConnectAddress ¶
func (pm *PeerManager) TryConnectAddress(addr string) (*Peer, error)
TryConnectAddress attempts to connect to the specified LN address.
type StopListeningPortEvent ¶
StopListeningPortEvent .