lnp2p

package
v0.0.0-...-f379a71 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

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

type HandleFuncType func(*Peer, Message) error

HandleFuncType is the type of a Message handler function, handling for a particular peer.

type Message

type Message interface {
	Type() uint8
	Bytes() []byte
}

Message is any kind of message that can go over the network.

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 .

func (NewListeningPortEvent) Flags

func (e NewListeningPortEvent) Flags() uint8

Flags .

func (NewListeningPortEvent) Name

func (e NewListeningPortEvent) Name() string

Name .

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.

func (NewPeerEvent) Flags

func (e NewPeerEvent) Flags() uint8

Flags .

func (NewPeerEvent) Name

func (e NewPeerEvent) Name() string

Name .

type ParseFuncType

type ParseFuncType func([]byte) (Message, error)

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

func (p *Peer) GetIdx() uint32

GetIdx is a compatibility function.

func (*Peer) GetLnAddr

func (p *Peer) GetLnAddr() lncore.LnAddr

GetLnAddr returns the lightning network address for this peer.

func (*Peer) GetNickname

func (p *Peer) GetNickname() string

GetNickname returns the nickname, or an empty string if unset.

func (*Peer) GetPrettyName

func (p *Peer) GetPrettyName() string

GetPrettyName returns a more human-readable name, such as the nickname if available or a trucated version of the LN address otherwise.

func (*Peer) GetPubkey

func (p *Peer) GetPubkey() koblitz.PublicKey

GetPubkey gets the public key for the user.

func (*Peer) GetRemoteAddr

func (p *Peer) GetRemoteAddr() string

GetRemoteAddr does something.

func (*Peer) IntoPeerInfo

func (p *Peer) IntoPeerInfo() lncore.PeerInfo

IntoPeerInfo generates the PeerInfo DB struct for the Peer.

func (*Peer) SendImmediateMessage

func (p *Peer) SendImmediateMessage(msg Message) error

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

func (p *Peer) SendQueuedMessage(msg Message) error

SendQueuedMessage adds the message to the queue to be sent to this peer. This queue is shared across all peers.

func (*Peer) SetNickname

func (p *Peer) SetNickname(name string)

SetNickname sets the peer's nickname.

type PeerDisconnectEvent

type PeerDisconnectEvent struct {
	Peer   *Peer
	Reason string
}

PeerDisconnectEvent is fired when a peer is disconnected.

func (PeerDisconnectEvent) Flags

func (e PeerDisconnectEvent) Flags() uint8

Flags .

func (PeerDisconnectEvent) Name

func (e PeerDisconnectEvent) Name() string

Name .

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

type StopListeningPortEvent struct {
	Port   int
	Reason string
}

StopListeningPortEvent .

func (StopListeningPortEvent) Flags

func (e StopListeningPortEvent) Flags() uint8

Flags .

func (StopListeningPortEvent) Name

func (e StopListeningPortEvent) Name() string

Name .

Jump to

Keyboard shortcuts

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