Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeHexString(input string) ([]byte, error)
- func EcdsaPrivKeyToSecp256k1PrivKey(privKey *ecdsa.PrivateKey) *crypto.Secp256k1PrivateKey
- func EcdsaPubKeyToSecp256k1PublicKey(pubKey *ecdsa.PublicKey) *crypto.Secp256k1PublicKey
- func EnodeToPeerInfo(node *enode.Node) (*peer.AddrInfo, error)
- func GetENRandIP(addrs []multiaddr.Multiaddr, wakuFlags WakuEnrBitfield, ...) (*enode.Node, error)
- func GetNTPMetadata() (*ntp.Response, error)
- func GetNTPTime() (time.Time, error)
- func GetTimeOffset() (time.Duration, error)
- func GetUnixEpoch(timesource ...Timesource) int64
- func GetUnixEpochFrom(now time.Time) int64
- func InitLogger(encoding string, output string)
- func Logger() *zap.Logger
- func Multiaddress(node *enode.Node) ([]multiaddr.Multiaddr, error)
- func SelectPeer(host host.Host, protocolId string, specificPeers []peer.ID, log *zap.Logger) (peer.ID, error)
- func SelectPeerWithLowestRTT(ctx context.Context, host host.Host, protocolId string, ...) (peer.ID, error)
- type Timesource
- 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
var NTPServer = "pool.ntp.org"
Functions ¶
func DecodeHexString ¶
func EcdsaPrivKeyToSecp256k1PrivKey ¶
func EcdsaPrivKeyToSecp256k1PrivKey(privKey *ecdsa.PrivateKey) *crypto.Secp256k1PrivateKey
EcdsaPubKeyToSecp256k1PublicKey converts an `ecdsa.PrivateKey` into a libp2p `crypto.Secp256k1PrivateKey“
func EcdsaPubKeyToSecp256k1PublicKey ¶
func EcdsaPubKeyToSecp256k1PublicKey(pubKey *ecdsa.PublicKey) *crypto.Secp256k1PublicKey
EcdsaPubKeyToSecp256k1PublicKey converts an `ecdsa.PublicKey` into a libp2p `crypto.Secp256k1PublicKey“
func EnodeToPeerInfo ¶
EnodeToPeerInfo extracts the peer ID and multiaddresses defined in an ENR
func GetENRandIP ¶
func GetENRandIP(addrs []multiaddr.Multiaddr, wakuFlags WakuEnrBitfield, privK *ecdsa.PrivateKey) (*enode.Node, error)
GetENRandIP returns a enr Node and TCP address obtained from a multiaddress. priv key and protocols supported
func GetNTPMetadata ¶
func GetNTPTime ¶
func GetTimeOffset ¶
func GetUnixEpoch ¶
func GetUnixEpoch(timesource ...Timesource) int64
GetUnixEpoch returns the current time in unix timestamp with the integer part representing seconds and the decimal part representing subseconds. Optionally receives a timesource to obtain the time from
func GetUnixEpochFrom ¶
GetUnixEpochFrom converts a time into a unix timestamp with nanoseconds
func InitLogger ¶
InitLogger initializes a global logger using an specific encoding
func Multiaddress ¶
Multiaddress is used to extract all the multiaddresses that are part of a ENR record
func SelectPeer ¶
func SelectPeer(host host.Host, protocolId string, specificPeers []peer.ID, log *zap.Logger) (peer.ID, error)
SelectPeer is used to return a random peer that supports a given protocol. If a list of specific peers is passed, the peer will be chosen from that list assuming it supports the chosen protocol, otherwise it will chose a peer from the node peerstore
func SelectPeerWithLowestRTT ¶
func SelectPeerWithLowestRTT(ctx context.Context, host host.Host, protocolId string, specificPeers []peer.ID, log *zap.Logger) (peer.ID, error)
SelectPeerWithLowestRTT will select a peer that supports a specific protocol with the lowest reply time If a list of specific peers is passed, the peer will be chosen from that list assuming it supports the chosen protocol, otherwise it will chose a peer from the node peerstore
Types ¶
type Timesource ¶
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