Documentation ¶
Index ¶
- Variables
- func DecodePayloadV2(message *pb.WakuMessage) (*noise.PayloadV2, error)
- func DecodeWakuMessage(message *pb.WakuMessage, keyInfo *KeyInfo) error
- func EncodePayloadV2(payload2 *noise.PayloadV2) (*pb.WakuMessage, error)
- func EncodeWakuMessage(message *pb.WakuMessage, keyInfo *KeyInfo) error
- type ConnStatus
- type ConnectionNotifier
- func (c ConnectionNotifier) Close()
- func (c ConnectionNotifier) ClosedStream(n network.Network, s network.Stream)
- func (c ConnectionNotifier) Connected(n network.Network, cc network.Conn)
- func (c ConnectionNotifier) Disconnected(n network.Network, cc network.Conn)
- func (c ConnectionNotifier) Listen(n network.Network, m ma.Multiaddr)
- func (c ConnectionNotifier) ListenClose(n network.Network, m ma.Multiaddr)
- func (c ConnectionNotifier) OpenedStream(n network.Network, s network.Stream)
- type DecodedPayload
- type KeyInfo
- type KeyKind
- type MembershipKeyPair
- type Payload
- type Peer
- type PeerStats
- type RLNRelay
- type WakuNode
- func (w *WakuNode) AddPeer(address ma.Multiaddr, protocols ...string) (*peer.ID, error)
- func (w *WakuNode) Broadcaster() v2.Broadcaster
- func (w *WakuNode) ClosePeerByAddress(address string) error
- func (w *WakuNode) ClosePeerById(id peer.ID) error
- func (w *WakuNode) DialPeer(ctx context.Context, address string) error
- func (w *WakuNode) DialPeerByID(ctx context.Context, peerID peer.ID) error
- func (w *WakuNode) DialPeerWithMultiAddress(ctx context.Context, address ma.Multiaddr) error
- func (w *WakuNode) DiscV5() *discv5.DiscoveryV5
- func (w *WakuNode) ENR() *enode.Node
- func (w *WakuNode) Filter() *filter.WakuFilter
- func (w *WakuNode) Host() host.Host
- func (w *WakuNode) ID() string
- func (w *WakuNode) Lightpush() *lightpush.WakuLightPush
- func (w *WakuNode) ListenAddresses() []ma.Multiaddr
- func (w *WakuNode) PeerCount() int
- func (w *WakuNode) PeerStats() PeerStats
- func (w *WakuNode) Peers() ([]*Peer, error)
- func (w *WakuNode) Publish(ctx context.Context, msg *pb.WakuMessage) error
- func (w *WakuNode) RLNRelay() RLNRelay
- func (w *WakuNode) Relay() *relay.WakuRelay
- func (w *WakuNode) Start() error
- func (w *WakuNode) Status() (isOnline bool, hasHistory bool)
- func (w *WakuNode) Stop()
- func (w *WakuNode) Store() store.Store
- type WakuNodeOption
- func WithAdvertiseAddress(address *net.TCPAddr) WakuNodeOption
- func WithConnectionStatusChannel(connStatus chan ConnStatus) WakuNodeOption
- func WithDiscoveryV5(udpPort int, bootnodes []*enode.Node, autoUpdate bool, ...) WakuNodeOption
- func WithDns4Domain(dns4Domain string) WakuNodeOption
- func WithHostAddress(hostAddr *net.TCPAddr) WakuNodeOption
- func WithKeepAlive(t time.Duration) WakuNodeOption
- func WithLibP2POptions(opts ...libp2p.Option) WakuNodeOption
- func WithLightPush() WakuNodeOption
- func WithLogger(l *zap.Logger) WakuNodeOption
- func WithMessageProvider(s store.MessageProvider) WakuNodeOption
- func WithMultiaddress(addresses []multiaddr.Multiaddr) WakuNodeOption
- func WithPrivateKey(privKey *ecdsa.PrivateKey) WakuNodeOption
- func WithRendezvous(discoverOpts ...pubsub.DiscoverOpt) WakuNodeOption
- func WithRendezvousServer(storage rendezvous.Storage) WakuNodeOption
- func WithSecureWebsockets(address string, port int, certPath string, keyPath string) WakuNodeOption
- func WithWakuFilter(fullNode bool, filterOpts ...filter.Option) WakuNodeOption
- func WithWakuRelay(opts ...pubsub.Option) WakuNodeOption
- func WithWakuRelayAndMinPeers(minRelayPeersToPublish int, opts ...pubsub.Option) WakuNodeOption
- func WithWakuStore(shouldStoreMessages bool, shouldResume bool) WakuNodeOption
- func WithWakuStoreFactory(factory storeFactory) WakuNodeOption
- func WithWakuSwap(mode int, disconnectThreshold, paymentThreshold int) WakuNodeOption
- func WithWebsockets(address string, port int) WakuNodeOption
- type WakuNodeParameters
Constants ¶
This section is empty.
Variables ¶
var DefaultLibP2POptions = []libp2p.Option{ libp2p.ChainOptions( libp2p.Transport(tcp.NewTCPTransport), libp2p.Transport(quic.NewTransport), ), libp2p.UserAgent(clientId), 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
var DefaultWakuNodeOptions = []WakuNodeOption{ WithLogger(utils.Logger()), WithWakuRelay(), }
Default options used in the libp2p node
var GitCommit string
GitCommit is a commit hash.
var Version string
Version is the version of go-waku at the time of compilation
Functions ¶
func DecodePayloadV2 ¶ added in v0.2.0
func DecodePayloadV2(message *pb.WakuMessage) (*noise.PayloadV2, error)
Decodes a WakuMessage to a PayloadV2 Currently, this is just a wrapper over deserializePayloadV2 and encryption/decryption is done on top (no KeyInfo)
func DecodeWakuMessage ¶
func DecodeWakuMessage(message *pb.WakuMessage, keyInfo *KeyInfo) error
func EncodePayloadV2 ¶ added in v0.2.0
func EncodePayloadV2(payload2 *noise.PayloadV2) (*pb.WakuMessage, error)
Encodes a PayloadV2 to a WakuMessage Currently, this is just a wrapper over serializePayloadV2 and encryption/decryption is done on top (no KeyInfo)
func EncodeWakuMessage ¶
func EncodeWakuMessage(message *pb.WakuMessage, keyInfo *KeyInfo) error
Types ¶
type ConnStatus ¶
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 (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 ma.Multiaddr)
Listen is called when network starts listening on an addr
func (ConnectionNotifier) ListenClose ¶
func (c ConnectionNotifier) ListenClose(n network.Network, m ma.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 DecodedPayload ¶
type DecodedPayload struct { Data []byte // Decoded message payload Padding []byte // Used to align data size, since data size alone might reveal important metainformation. PubKey *ecdsa.PublicKey // The public key that signed the payload Signature []byte }
DecodedPayload contains the data of the received message after decrypting it
func DecodePayload ¶
func DecodePayload(message *pb.WakuMessage, keyInfo *KeyInfo) (*DecodedPayload, error)
DecodePayload decodes a WakuMessage depending on the version parameter. 0 for raw unencrypted data, and 1 for using WakuV1 decoding
type KeyInfo ¶
type KeyInfo struct { Kind KeyKind // Indicates the type of encryption to use SymKey []byte // If the encryption is Symmetric, a Symmetric key must be specified PubKey ecdsa.PublicKey // If the encryption is Asymmetric, the public key of the message receptor must be specified PrivKey *ecdsa.PrivateKey // Set a privkey if the message requires a signature }
type MembershipKeyPair ¶ added in v0.2.0
type Payload ¶
type Payload struct { Data []byte // Raw message payload Padding []byte // Used to align data size, since data size alone might reveal important metainformation. Key *KeyInfo // Contains the type of encryption to apply and the private key to use for signing the message }
Payload contains the data of the message to encode
type RLNRelay ¶ added in v0.2.0
type RLNRelay interface { MembershipKeyPair() MembershipKeyPair MembershipIndex() uint AppendRLNProof(msg *pb.WakuMessage, senderEpochTime time.Time) error Stop() }
type WakuNode ¶
type WakuNode struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, opts ...WakuNodeOption) (*WakuNode, error)
New is used to instantiate a WakuNode using a set of WakuNodeOptions
func (*WakuNode) AddPeer ¶
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 ¶
ClosePeerByAddress is used to disconnect from a peer using its multiaddress
func (*WakuNode) ClosePeerById ¶
ClosePeerById is used to close a connection to a peer
func (*WakuNode) DialPeer ¶
DialPeer is used to connect to a peer using a string containing a multiaddress
func (*WakuNode) DialPeerByID ¶
DialPeerByID is used to connect to an already known peer
func (*WakuNode) DialPeerWithMultiAddress ¶
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) Filter ¶
func (w *WakuNode) Filter() *filter.WakuFilter
Filter is used to access any operation related to Waku Filter protocol
func (*WakuNode) Lightpush ¶
func (w *WakuNode) Lightpush() *lightpush.WakuLightPush
Lightpush is used to access any operation related to Waku Lightpush protocol
func (*WakuNode) ListenAddresses ¶
ListenAddresses returns all the multiaddresses used by the host
func (*WakuNode) Peers ¶
Peers return the list of peers, addresses, protocols supported and connection status
func (*WakuNode) Publish ¶
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) Status ¶
Status returns the current status of the node (online or not) and if the node has access to history nodes or not
type WakuNodeOption ¶
type WakuNodeOption func(*WakuNodeParameters) error
func WithAdvertiseAddress ¶
func WithAdvertiseAddress(address *net.TCPAddr) WakuNodeOption
WithAdvertiseAddress 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 WithDiscoveryV5 ¶
func WithDiscoveryV5(udpPort int, bootnodes []*enode.Node, autoUpdate bool, discoverOpts ...pubsub.DiscoverOpt) 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 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 WithPrivateKey ¶
func WithPrivateKey(privKey *ecdsa.PrivateKey) WakuNodeOption
WithPrivateKey is used to set an ECDSA private key in a libp2p node
func WithRendezvous ¶
func WithRendezvous(discoverOpts ...pubsub.DiscoverOpt) WakuNodeOption
WithRendezvous is a WakuOption used to enable go-waku-rendezvous discovery. It accepts an optional list of DiscoveryOpt options
func WithRendezvousServer ¶
func WithRendezvousServer(storage rendezvous.Storage) WakuNodeOption
WithRendezvousServer is a WakuOption used to set the node as a rendezvous point, using an specific storage for the peer information
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 V2 Filter protocol. This WakuNodeOption accepts a list of WakuFilter gossipsub options to setup the protocol
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(shouldStoreMessages bool, shouldResume bool) WakuNodeOption
WithWakuStore enables the Waku V2 Store protocol and if the messages should be stored or not in a message provider
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 ¶ added in v0.2.2
func (w WakuNodeParameters) TLSConfig() *tls.Config
TLSConfig returns the TLS config used for setting up secure websockets