Documentation ¶
Index ¶
- Constants
- Variables
- func EnodeToPeerInfo(node *enode.Node) (*peer.AddrInfo, error)
- func GetENRandIP(addr ma.Multiaddr, wakuFlags WakuEnrBitfield, privK *ecdsa.PrivateKey) (*enode.Node, *net.TCPAddr, error)
- func GetUnixEpoch() int64
- func GetUnixEpochFrom(now time.Time) int64
- func Logger() *zap.SugaredLogger
- func Multiaddress(node *enode.Node) ([]ma.Multiaddr, error)
- func SelectPeer(host host.Host, protocolId string, log *zap.SugaredLogger) (*peer.ID, error)
- func SelectPeerWithLowestRTT(ctx context.Context, host host.Host, protocolId string, log *zap.SugaredLogger) (*peer.ID, error)
- func SetLogLevel(level string) error
- type WakuEnrBitfield
Constants ¶
const MultiaddrENRField = "multiaddrs"
MultiaddrENRField is the name of the ENR field that will contain multiaddresses that cannot be described using the already available ENR fields (i.e. in the case of websocket connections)
const WakuENRField = "waku2"
WakuENRField is the name of the ENR field that contains information about which protocols are supported by the node
Variables ¶
var ErrNoPeersAvailable = errors.New("no suitable peers found")
ErrNoPeersAvailable is emitted when no suitable peers are found for some protocol
Functions ¶
func GetENRandIP ¶
func GetENRandIP(addr ma.Multiaddr, wakuFlags WakuEnrBitfield, privK *ecdsa.PrivateKey) (*enode.Node, *net.TCPAddr, error)
GetENRandIP returns a enr Node and TCP address obtained from a multiaddress. priv key and protocols supported
func GetUnixEpoch ¶
func GetUnixEpoch() int64
GetUnixEpoch returns the current time in unix timestamp with the integer part representing seconds and the decimal part representing subseconds
func GetUnixEpochFrom ¶
GetUnixEpochFrom converts a time into a unix timestamp with nanoseconds
func Logger ¶
func Logger() *zap.SugaredLogger
Logger creates a zap.Logger with some reasonable defaults
func Multiaddress ¶
Multiaddress is used to extract all the multiaddresses that are part of a ENR record
func SelectPeer ¶
SelectPeer is used to return a random peer that supports a given protocol.
Types ¶
type WakuEnrBitfield ¶
type WakuEnrBitfield = uint8
WakuEnrBitfield is a8-bit flag field to indicate Waku capabilities. Only the 4 LSBs are currently defined according to RFC31 (https://rfc.vac.dev/spec/31/).
func NewWakuEnrBitfield ¶
func NewWakuEnrBitfield(lightpush, filter, store, relay bool) WakuEnrBitfield
NewWakuEnrBitfield creates a WakuEnrBitField whose value will depend on which protocols are enabled in the node