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(addr ma.Multiaddr, wakuFlags WakuEnrBitfield, privK *ecdsa.PrivateKey) (*enode.Node, *net.TCPAddr, error)
- func GetUnixEpoch() int64
- func GetUnixEpochFrom(now time.Time) int64
- func InitLogger(encoding string)
- func Logger() *zap.Logger
- func Multiaddress(node *enode.Node) ([]ma.Multiaddr, error)
- func SelectPeer(host host.Host, protocolId string, log *zap.Logger) (*peer.ID, error)
- func SelectPeerWithLowestRTT(ctx context.Context, host host.Host, protocolId string, log *zap.Logger) (*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 DecodeHexString ¶ added in v0.2.2
func EcdsaPrivKeyToSecp256k1PrivKey ¶ added in v0.1.0
func EcdsaPrivKeyToSecp256k1PrivKey(privKey *ecdsa.PrivateKey) *crypto.Secp256k1PrivateKey
EcdsaPubKeyToSecp256k1PublicKey converts an `ecdsa.PrivateKey` into a libp2p `crypto.Secp256k1PrivateKey“
func EcdsaPubKeyToSecp256k1PublicKey ¶ added in v0.1.0
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(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 InitLogger ¶ added in v0.1.0
func InitLogger(encoding string)
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 ¶
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