node

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 59 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLibP2POptions = []libp2p.Option{
	libp2p.ChainOptions(
		libp2p.Transport(tcp.NewTCPTransport),
		libp2p.Transport(quic.NewTransport),
	),
	libp2p.UserAgent(userAgent),
	libp2p.ChainOptions(
		libp2p.Muxer("/yamux/1.0.0", yamux.DefaultTransport),
		libp2p.Muxer("/mplex/6.7.0", mplex.DefaultTransport),
	),
	libp2p.EnableNATService(),
	libp2p.ConnectionManager(newConnManager(200, 300, connmgr.WithGracePeriod(0))),
}

Default options used in the libp2p node

View Source
var DefaultWakuNodeOptions = []WakuNodeOption{
	WithDiscoverParams(150),
}

Default options used in the libp2p node

View Source
var GitCommit string

GitCommit is a commit hash.

View Source
var Version string

Version is the version of go-waku at the time of compilation

Functions

This section is empty.

Types

type ConnStatus

type ConnStatus struct {
	IsOnline   bool
	HasHistory bool
	Peers      PeerStats
}

ConnStatus is used to indicate if the node is online, has access to history and also see the list of peers the node is aware of

type ConnectionNotifier

type ConnectionNotifier struct {
	DisconnectChan chan peer.ID
	// contains filtered or unexported fields
}

ConnectionNotifier is a custom Notifier to be used to display when a peer connects or disconnects to the node

func NewConnectionNotifier

func NewConnectionNotifier(ctx context.Context, h host.Host, log *zap.Logger) ConnectionNotifier

func (ConnectionNotifier) Close

func (c ConnectionNotifier) Close()

Close quits the ConnectionNotifier

func (ConnectionNotifier) ClosedStream

func (c ConnectionNotifier) ClosedStream(n network.Network, s network.Stream)

ClosedStream is called when a stream closed

func (ConnectionNotifier) Connected

func (c ConnectionNotifier) Connected(n network.Network, cc network.Conn)

Connected is called when a connection is opened

func (ConnectionNotifier) Disconnected

func (c ConnectionNotifier) Disconnected(n network.Network, cc network.Conn)

Disconnected is called when a connection closed

func (ConnectionNotifier) Listen

func (c ConnectionNotifier) Listen(n network.Network, m multiaddr.Multiaddr)

Listen is called when network starts listening on an addr

func (ConnectionNotifier) ListenClose

func (c ConnectionNotifier) ListenClose(n network.Network, m multiaddr.Multiaddr)

ListenClose is called when network stops listening on an address

func (ConnectionNotifier) OpenedStream

func (c ConnectionNotifier) OpenedStream(n network.Network, s network.Stream)

OpenedStream is called when a stream opened

type MembershipKeyPair

type MembershipKeyPair = struct {
	IDKey        [32]byte `json:"idKey"`
	IDCommitment [32]byte `json:"idCommitment"`
}

type Peer

type Peer struct {
	ID        peer.ID        `json:"peerID"`
	Protocols []protocol.ID  `json:"protocols"`
	Addrs     []ma.Multiaddr `json:"addrs"`
	Connected bool           `json:"connected"`
}

type PeerConnectorService added in v0.4.0

type PeerConnectorService interface {
	Service
	PeerChannel() chan<- peer.AddrInfo
}

type PeerStats

type PeerStats map[peer.ID][]protocol.ID

PeerStatis is a map of peer IDs to supported protocols

type RLNRelay

type RLNRelay interface {
	MembershipKeyPair() *MembershipKeyPair
	MembershipIndex() uint
	MembershipContractAddress() common.Address
	AppendRLNProof(msg *pb.WakuMessage, senderEpochTime time.Time) error
	Stop()
}

type ReceptorService added in v0.4.0

type ReceptorService interface {
	Service
	MessageChannel() chan *protocol.Envelope
}

type Service added in v0.4.0

type Service interface {
	Start(ctx context.Context) error
	Stop()
}

type VersionInfo

type VersionInfo struct {
	Version string
	Commit  string
	System  string
	Golang  string
}

func GetVersionInfo

func GetVersionInfo() VersionInfo

func (VersionInfo) String

func (v VersionInfo) String() string

type WakuNode

type WakuNode struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...WakuNodeOption) (*WakuNode, error)

New is used to instantiate a WakuNode using a set of WakuNodeOptions

func (*WakuNode) AddPeer

func (w *WakuNode) AddPeer(address ma.Multiaddr, protocols ...protocol.ID) (peer.ID, error)

AddPeer is used to add a peer and the protocols it support to the node peerstore

func (*WakuNode) Broadcaster

func (w *WakuNode) Broadcaster() v2.Broadcaster

Broadcaster is used to access the message broadcaster that is used to push messages to different protocols

func (*WakuNode) ClosePeerByAddress

func (w *WakuNode) ClosePeerByAddress(address string) error

ClosePeerByAddress is used to disconnect from a peer using its multiaddress

func (*WakuNode) ClosePeerById

func (w *WakuNode) ClosePeerById(id peer.ID) error

ClosePeerById is used to close a connection to a peer

func (*WakuNode) DialPeer

func (w *WakuNode) DialPeer(ctx context.Context, address string) error

DialPeer is used to connect to a peer using a string containing a multiaddress

func (*WakuNode) DialPeerByID

func (w *WakuNode) DialPeerByID(ctx context.Context, peerID peer.ID) error

DialPeerByID is used to connect to an already known peer

func (*WakuNode) DialPeerWithMultiAddress

func (w *WakuNode) DialPeerWithMultiAddress(ctx context.Context, address ma.Multiaddr) error

DialPeerWithMultiAddress is used to connect to a peer using a multiaddress

func (*WakuNode) DiscV5

func (w *WakuNode) DiscV5() *discv5.DiscoveryV5

DiscV5 is used to access any operation related to DiscoveryV5

func (*WakuNode) ENR

func (w *WakuNode) ENR() *enode.Node

ENR returns the ENR address of the node

func (*WakuNode) Filter

func (w *WakuNode) Filter() *filter.WakuFilter

Filter is used to access any operation related to Waku Filter protocol

func (*WakuNode) FilterV2 added in v0.5.0

func (w *WakuNode) FilterV2() *filterv2.WakuFilterLightnode

FilterV2 is used to access any operation related to Waku Filter protocol

func (*WakuNode) Host

func (w *WakuNode) Host() host.Host

Host returns the libp2p Host used by the WakuNode

func (*WakuNode) ID

func (w *WakuNode) ID() string

ID returns the base58 encoded ID from the host

func (*WakuNode) Lightpush

func (w *WakuNode) Lightpush() *lightpush.WakuLightPush

Lightpush is used to access any operation related to Waku Lightpush protocol

func (*WakuNode) ListenAddresses

func (w *WakuNode) ListenAddresses() []ma.Multiaddr

ListenAddresses returns all the multiaddresses used by the host

func (*WakuNode) PeerCount

func (w *WakuNode) PeerCount() int

PeerCount return the number of connected peers

func (*WakuNode) PeerExchange

func (w *WakuNode) PeerExchange() *peer_exchange.WakuPeerExchange

PeerExchange is used to access any operation related to Peer Exchange

func (*WakuNode) PeerStats

func (w *WakuNode) PeerStats() PeerStats

PeerStats returns a list of peers and the protocols supported by them

func (*WakuNode) Peers

func (w *WakuNode) Peers() ([]*Peer, error)

Peers return the list of peers, addresses, protocols supported and connection status

func (*WakuNode) Publish

func (w *WakuNode) Publish(ctx context.Context, msg *pb.WakuMessage) error

Publish will attempt to publish a message via WakuRelay if there are enough peers available, otherwise it will attempt to publish via Lightpush protocol

func (*WakuNode) RLNRelay

func (w *WakuNode) RLNRelay() RLNRelay

func (*WakuNode) Relay

func (w *WakuNode) Relay() *relay.WakuRelay

Relay is used to access any operation related to Waku Relay protocol

func (*WakuNode) SetDiscV5Bootnodes

func (w *WakuNode) SetDiscV5Bootnodes(nodes []*enode.Node) error

Set the bootnodes on discv5

func (*WakuNode) Start

func (w *WakuNode) Start(ctx context.Context) error

Start initializes all the protocols that were setup in the WakuNode

func (*WakuNode) Status

func (w *WakuNode) Status() (isOnline bool, hasHistory bool)

Status returns the current status of the node (online or not) and if the node has access to history nodes or not

func (*WakuNode) Stop

func (w *WakuNode) Stop()

Stop stops the WakuNode and closess all connections to the host

func (*WakuNode) Store

func (w *WakuNode) Store() store.Store

Store is used to access any operation related to Waku Store protocol

func (*WakuNode) Timesource

func (w *WakuNode) Timesource() timesource.Timesource

Timesource returns the timesource used by this node to obtain the current wall time Depending on the configuration it will be the local time or a ntp syncd time

type WakuNodeOption

type WakuNodeOption func(*WakuNodeParameters) error

func NoDefaultWakuTopic added in v0.5.0

func NoDefaultWakuTopic() WakuNodeOption

NoDefaultWakuTopic will stop the node from subscribing to the default pubsub topic automatically

func WithAdvertiseAddresses added in v0.5.0

func WithAdvertiseAddresses(advertiseAddrs ...ma.Multiaddr) WakuNodeOption

WithAdvertiseAddresses is a WakuNodeOption that allows overriding the address used in the waku node with custom value

func WithConnectionStatusChannel

func WithConnectionStatusChannel(connStatus chan ConnStatus) WakuNodeOption

WithConnectionStatusChannel is a WakuNodeOption used to set a channel where the connection status changes will be pushed to. It's useful to identify when peer connections and disconnections occur

func WithDiscoverParams added in v0.4.0

func WithDiscoverParams(minPeers int) WakuNodeOption

func WithDiscoveryV5

func WithDiscoveryV5(udpPort uint, bootnodes []*enode.Node, autoUpdate bool) WakuNodeOption

WithDiscoveryV5 is a WakuOption used to enable DiscV5 peer discovery

func WithDns4Domain

func WithDns4Domain(dns4Domain string) WakuNodeOption

WithDns4Domain is a WakuNodeOption that adds a custom domain name to listen

func WithHostAddress

func WithHostAddress(hostAddr *net.TCPAddr) WakuNodeOption

WithHostAddress is a WakuNodeOption that configures libp2p to listen on a specific address

func WithKeepAlive

func WithKeepAlive(t time.Duration) WakuNodeOption

WithKeepAlive is a WakuNodeOption used to set the interval of time when each peer will be ping to keep the TCP connection alive

func WithLibP2POptions

func WithLibP2POptions(opts ...libp2p.Option) WakuNodeOption

WithLibP2POptions is a WakuNodeOption used to configure the libp2p node. This can potentially override any libp2p config that was set with other WakuNodeOption

func WithLightPush

func WithLightPush() WakuNodeOption

WithLightPush is a WakuNodeOption that enables the lightpush protocol

func WithLogLevel added in v0.5.0

func WithLogLevel(lvl zapcore.Level) WakuNodeOption

WithLogLevel is a WakuNodeOption that sets the log level for go-waku

func WithLogger

func WithLogger(l *zap.Logger) WakuNodeOption

WithLogger is a WakuNodeOption that adds a custom logger

func WithMessageProvider

func WithMessageProvider(s store.MessageProvider) WakuNodeOption

WithMessageProvider is a WakuNodeOption that sets the MessageProvider used to store and retrieve persisted messages

func WithMultiaddress

func WithMultiaddress(addresses []multiaddr.Multiaddr) WakuNodeOption

WithMultiaddress is a WakuNodeOption that configures libp2p to listen on a list of multiaddresses

func WithNTP

func WithNTP(ntpURLs ...string) WakuNodeOption

WithNTP is used to use ntp for any operation that requires obtaining time A list of ntp servers can be passed but if none is specified, some defaults will be used

func WithPeerExchange

func WithPeerExchange() WakuNodeOption

WithPeerExchange is a WakuOption used to enable Peer Exchange

func WithPrivateKey

func WithPrivateKey(privKey *ecdsa.PrivateKey) WakuNodeOption

WithPrivateKey is used to set an ECDSA private key in a libp2p node

func WithSecureWebsockets

func WithSecureWebsockets(address string, port int, certPath string, keyPath string) WakuNodeOption

WithSecureWebsockets is a WakuNodeOption used to enable secure websockets support

func WithWakuFilter

func WithWakuFilter(fullNode bool, filterOpts ...filter.Option) WakuNodeOption

WithWakuFilter enables the Waku Filter protocol. This WakuNodeOption accepts a list of WakuFilter gossipsub options to setup the protocol

func WithWakuFilterV2FullNode added in v0.5.0

func WithWakuFilterV2FullNode(filterOpts ...filter.Option) WakuNodeOption

WithWakuFilterV2FullNode enables the Waku Filter V2 protocol full node functionality. This WakuNodeOption accepts a list of WakuFilter options to setup the protocol

func WithWakuFilterV2LightNode added in v0.5.0

func WithWakuFilterV2LightNode() WakuNodeOption

WithWakuFilterV2 enables the Waku Filter V2 protocol for lightnode functionality

func WithWakuRelay

func WithWakuRelay(opts ...pubsub.Option) WakuNodeOption

WithWakuRelay enables the Waku V2 Relay protocol. This WakuNodeOption accepts a list of WakuRelay gossipsub option to setup the protocol

func WithWakuRelayAndMinPeers

func WithWakuRelayAndMinPeers(minRelayPeersToPublish int, opts ...pubsub.Option) WakuNodeOption

WithWakuRelayAndMinPeers enables the Waku V2 Relay protocol. This WakuNodeOption accepts a min peers require to publish and a list of WakuRelay gossipsub option to setup the protocol

func WithWakuStore

func WithWakuStore(resumeNodes ...multiaddr.Multiaddr) WakuNodeOption

WithWakuStore enables the Waku V2 Store protocol and if the messages should be stored or not in a message provider. If resumeNodes are specified, the store will attempt to resume message history using those nodes

func WithWakuStoreFactory

func WithWakuStoreFactory(factory storeFactory) WakuNodeOption

WithWakuStoreFactory is used to replace the default WakuStore with a custom implementation that implements the store.Store interface

func WithWakuSwap

func WithWakuSwap(mode int, disconnectThreshold, paymentThreshold int) WakuNodeOption

WithWakuSwap set the option of the Waku V2 Swap protocol

func WithWebsockets

func WithWebsockets(address string, port int) WakuNodeOption

WithWebsockets is a WakuNodeOption used to enable websockets support

type WakuNodeParameters

type WakuNodeParameters struct {
	// contains filtered or unexported fields
}

func (WakuNodeParameters) AddressFactory

func (w WakuNodeParameters) AddressFactory() basichost.AddrsFactory

AddressFactory returns the address factory used by the node's host

func (*WakuNodeParameters) GetPrivKey

func (w *WakuNodeParameters) GetPrivKey() *crypto.PrivKey

GetPrivKey returns the private key used in the node

func (WakuNodeParameters) Identity

func (w WakuNodeParameters) Identity() config.Option

Identity returns a libp2p option containing the identity used by the node

func (WakuNodeParameters) MultiAddresses

func (w WakuNodeParameters) MultiAddresses() []multiaddr.Multiaddr

MultiAddresses return the list of multiaddresses configured in the node

func (WakuNodeParameters) TLSConfig

func (w WakuNodeParameters) TLSConfig() *tls.Config

TLSConfig returns the TLS config used for setting up secure websockets

Jump to

Keyboard shortcuts

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