Documentation ¶
Index ¶
- Constants
- Variables
- func CreateMailServerEvent(nodeID enode.ID, payload []byte) (*common.EnvelopeEvent, error)
- func CreateMailServerRequestCompletedPayload(requestID, lastEnvelopeHash gethcommon.Hash, cursor []byte) []byte
- func CreateMailServerRequestFailedPayload(requestID gethcommon.Hash, err error) []byte
- func FormatPeerStats(wakuNode *node.WakuNode, peers node.PeerStats) map[string]types.WakuV2Peer
- type BandwidthTelemetryClient
- type Config
- type Criteria
- type Info
- type MailServer
- type MailServerResponse
- type Message
- type NewMessage
- type PublicWakuAPI
- func (api *PublicWakuAPI) AddPrivateKey(ctx context.Context, privateKey hexutil.Bytes) (string, error)
- func (api *PublicWakuAPI) AddSymKey(ctx context.Context, key hexutil.Bytes) (string, error)
- func (api *PublicWakuAPI) BloomFilter() []byte
- func (api *PublicWakuAPI) DeleteKeyPair(ctx context.Context, key string) (bool, error)
- func (api *PublicWakuAPI) DeleteMessageFilter(id string) (bool, error)
- func (api *PublicWakuAPI) DeleteSymKey(ctx context.Context, id string) bool
- func (api *PublicWakuAPI) GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error)
- func (api *PublicWakuAPI) GetFilterMessages(id string) ([]*Message, error)
- func (api *PublicWakuAPI) GetPrivateKey(ctx context.Context, id string) (hexutil.Bytes, error)
- func (api *PublicWakuAPI) GetPublicKey(ctx context.Context, id string) (hexutil.Bytes, error)
- func (api *PublicWakuAPI) GetSymKey(ctx context.Context, id string) (hexutil.Bytes, error)
- func (api *PublicWakuAPI) HasKeyPair(ctx context.Context, id string) bool
- func (api *PublicWakuAPI) HasSymKey(ctx context.Context, id string) bool
- func (api *PublicWakuAPI) Info(ctx context.Context) Info
- func (api *PublicWakuAPI) Messages(ctx context.Context, crit Criteria) (*rpc.Subscription, error)
- func (api *PublicWakuAPI) NewKeyPair(ctx context.Context) (string, error)
- func (api *PublicWakuAPI) NewMessageFilter(req Criteria) (string, error)
- func (api *PublicWakuAPI) NewSymKey(ctx context.Context) (string, error)
- func (api *PublicWakuAPI) Post(ctx context.Context, req NewMessage) (hexutil.Bytes, error)
- func (api *PublicWakuAPI) UninstallFilter(id string)
- func (api *PublicWakuAPI) Unsubscribe(id string)
- type Waku
- func (w *Waku) APIs() []rpc.API
- func (w *Waku) AddKeyPair(key *ecdsa.PrivateKey) (string, error)
- func (w *Waku) AddRelayPeer(address string) (peer.ID, error)
- func (w *Waku) AddStorePeer(address string) (peer.ID, error)
- func (w *Waku) AddSymKey(id string, key []byte) (string, error)
- func (w *Waku) AddSymKeyDirect(key []byte) (string, error)
- func (w *Waku) AddSymKeyFromPassword(password string) (string, error)
- func (w *Waku) ConfirmationsEnabled() bool
- func (w *Waku) ConnectionChanged(state connection.State)
- func (w *Waku) CurrentTime() time.Time
- func (w *Waku) DeleteKeyPair(key string) bool
- func (w *Waku) DeleteKeyPairs() error
- func (w *Waku) DeleteSymKey(id string) bool
- func (w *Waku) DialPeer(address string) error
- func (w *Waku) DialPeerByID(peerID string) error
- func (w *Waku) DropPeer(peerID string) error
- func (w *Waku) Envelopes() []*common.ReceivedMessage
- func (w *Waku) GenerateSymKey() (string, error)
- func (w *Waku) GetEnvelope(hash gethcommon.Hash) *common.ReceivedMessage
- func (w *Waku) GetFilter(id string) *common.Filter
- func (w *Waku) GetPrivateKey(id string) (*ecdsa.PrivateKey, error)
- func (w *Waku) GetStats() types.StatsSummary
- func (w *Waku) GetSymKey(id string) ([]byte, error)
- func (w *Waku) HasKeyPair(id string) bool
- func (w *Waku) HasSymKey(id string) bool
- func (w *Waku) IsEnvelopeCached(hash gethcommon.Hash) bool
- func (w *Waku) ListenAddresses() []string
- func (w *Waku) MarkP2PMessageAsProcessed(hash gethcommon.Hash)
- func (w *Waku) MaxMessageSize() uint32
- func (w *Waku) NewKeyPair() (string, error)
- func (w *Waku) OnNewEnvelopes(envelope *protocol.Envelope, msgType common.MessageType) ([]common.EnvelopeError, error)
- func (w *Waku) PeerCount() int
- func (w *Waku) Peers() map[string]types.WakuV2Peer
- func (w *Waku) ProcessingP2PMessages() bool
- func (w *Waku) Protocols() []p2p.Protocol
- func (w *Waku) Query(ctx context.Context, peerID peer.ID, topics []common.TopicType, from uint64, ...) (cursor *storepb.Index, err error)
- func (w *Waku) SelectKeyPair(key *ecdsa.PrivateKey) error
- func (w *Waku) Send(msg *pb.WakuMessage) ([]byte, error)
- func (w *Waku) SendEnvelopeEvent(event common.EnvelopeEvent) int
- func (w *Waku) Start() error
- func (w *Waku) StartDiscV5() error
- func (w *Waku) Stop() error
- func (w *Waku) StopDiscV5() error
- func (w *Waku) Subscribe(f *common.Filter) (string, error)
- func (w *Waku) SubscribeEnvelopeEvents(events chan<- common.EnvelopeEvent) event.Subscription
- func (w *Waku) SubscribeToConnStatusChanges() *types.ConnStatusSubscription
- func (w *Waku) Unsubscribe(id string) error
- func (w *Waku) UnsubscribeMany(ids []string) error
Constants ¶
const ( Version = uint64(2) // Peer version number VersionStr = "2" // The same, as a string Name = "waku" // Nickname of the protocol )
Waku protocol parameters
Variables ¶
var ( ErrSymAsym = errors.New("specify either a symmetric or an asymmetric key") ErrInvalidSymmetricKey = errors.New("invalid symmetric key") ErrInvalidPublicKey = errors.New("invalid public key") ErrInvalidSigningPubKey = errors.New("invalid signing public key") ErrTooLowPoW = errors.New("message rejected, PoW too low") ErrNoTopics = errors.New("missing topic(s)") )
List of errors
var DefaultConfig = Config{ MaxMessageSize: common.DefaultMaxMessageSize, Host: "0.0.0.0", Port: 0, KeepAliveInterval: 10, DiscoveryLimit: 40, MinPeersForRelay: 1, MinPeersForFilter: 1, AutoUpdate: false, }
Functions ¶
func CreateMailServerEvent ¶
CreateMailServerEvent returns EnvelopeEvent with correct data if payload corresponds to any of the know mailserver events: * request completed successfully * request failed If the payload is unknown/unparseable, it returns `nil`
func CreateMailServerRequestCompletedPayload ¶
func CreateMailServerRequestCompletedPayload(requestID, lastEnvelopeHash gethcommon.Hash, cursor []byte) []byte
CreateMailServerRequestCompletedPayload creates a payload representing a successful request to mailserver
func CreateMailServerRequestFailedPayload ¶
func CreateMailServerRequestFailedPayload(requestID gethcommon.Hash, err error) []byte
CreateMailServerRequestFailedPayload creates a payload representing a failed request to a mailserver
func FormatPeerStats ¶ added in v0.88.4
Types ¶
type BandwidthTelemetryClient ¶ added in v0.128.0
type BandwidthTelemetryClient struct {
// contains filtered or unexported fields
}
func NewBandwidthTelemetryClient ¶ added in v0.128.0
func NewBandwidthTelemetryClient(logger *zap.Logger, serverURL string) *BandwidthTelemetryClient
func (*BandwidthTelemetryClient) PushProtocolStats ¶ added in v0.128.0
func (c *BandwidthTelemetryClient) PushProtocolStats(relayStats metrics.Stats, storeStats metrics.Stats)
type Config ¶
type Config struct { MaxMessageSize uint32 `toml:",omitempty"` Host string `toml:",omitempty"` Port int `toml:",omitempty"` PeerExchange bool `toml:",omitempty"` KeepAliveInterval int `toml:",omitempty"` MinPeersForRelay int `toml:",omitempty"` MinPeersForFilter int `toml:",omitempty"` LightClient bool `toml:",omitempty"` WakuNodes []string `toml:",omitempty"` Rendezvous bool `toml:",omitempty"` DiscV5BootstrapNodes []string `toml:",omitempty"` Nameserver string `toml:",omitempty"` EnableDiscV5 bool `toml:",omitempty"` DiscoveryLimit int `toml:",omitempty"` AutoUpdate bool `toml:",omitempty"` UDPPort int `toml:",omitempty"` EnableStore bool `toml:",omitempty"` StoreCapacity int `toml:",omitempty"` StoreSeconds int `toml:",omitempty"` TelemetryServerURL string `toml:",omitempty"` }
Config represents the configuration state of a waku node.
type Criteria ¶
type Criteria struct { SymKeyID string `json:"symKeyID"` PrivateKeyID string `json:"privateKeyID"` Sig []byte `json:"sig"` Topics []common.TopicType `json:"topics"` }
Criteria holds various filter options for inbound messages.
type Info ¶
type Info struct { Messages int `json:"messages"` // Number of floating messages. MaxMessageSize uint32 `json:"maxMessageSize"` // Maximum accepted message size }
Info contains diagnostic information.
type MailServer ¶
type MailServer interface { Archive(env *common.Envelope) DeliverMail(peerID []byte, request *common.Envelope) // DEPRECATED; use Deliver() Deliver(peerID []byte, request common.MessagesRequest) }
MailServer represents a mail server, capable of archiving the old messages for subsequent delivery to the peers. Any implementation must ensure that both functions are thread-safe. Also, they must return ASAP. DeliverMail should use p2pMessageCode for delivery, in order to bypass the expiry checks.
type MailServerResponse ¶
type MailServerResponse struct { LastEnvelopeHash gethcommon.Hash Cursor []byte Error error }
MailServerResponse is the response payload sent by the mailserver.
type Message ¶
type Message struct { Sig []byte `json:"sig,omitempty"` Timestamp uint32 `json:"timestamp"` Topic common.TopicType `json:"topic"` Payload []byte `json:"payload"` Padding []byte `json:"padding"` Hash []byte `json:"hash"` Dst []byte `json:"recipientPublicKey,omitempty"` }
Message is the RPC representation of a waku message.
func ToWakuMessage ¶
func ToWakuMessage(message *common.ReceivedMessage) *Message
ToWakuMessage converts an internal message into an API version.
type NewMessage ¶
type NewMessage struct { SymKeyID string `json:"symKeyID"` PublicKey []byte `json:"pubKey"` Sig string `json:"sig"` Topic common.TopicType `json:"topic"` Payload []byte `json:"payload"` Padding []byte `json:"padding"` TargetPeer string `json:"targetPeer"` Ephemeral bool `json:"ephemeral"` }
NewMessage represents a new waku message that is posted through the RPC.
type PublicWakuAPI ¶
type PublicWakuAPI struct {
// contains filtered or unexported fields
}
PublicWakuAPI provides the waku RPC service that can be use publicly without security implications.
func NewPublicWakuAPI ¶
func NewPublicWakuAPI(w *Waku) *PublicWakuAPI
NewPublicWakuAPI create a new RPC waku service.
func (*PublicWakuAPI) AddPrivateKey ¶
func (api *PublicWakuAPI) AddPrivateKey(ctx context.Context, privateKey hexutil.Bytes) (string, error)
AddPrivateKey imports the given private key.
func (*PublicWakuAPI) AddSymKey ¶
AddSymKey import a symmetric key. It returns an ID that can be used to refer to the key. Can be used encrypting and decrypting messages where the key is known to both parties.
func (*PublicWakuAPI) BloomFilter ¶ added in v0.85.0
func (api *PublicWakuAPI) BloomFilter() []byte
func (*PublicWakuAPI) DeleteKeyPair ¶
DeleteKeyPair removes the key with the given key if it exists.
func (*PublicWakuAPI) DeleteMessageFilter ¶
func (api *PublicWakuAPI) DeleteMessageFilter(id string) (bool, error)
DeleteMessageFilter deletes a filter.
func (*PublicWakuAPI) DeleteSymKey ¶
func (api *PublicWakuAPI) DeleteSymKey(ctx context.Context, id string) bool
DeleteSymKey deletes the symmetric key that is associated with the given id.
func (*PublicWakuAPI) GenerateSymKeyFromPassword ¶
func (api *PublicWakuAPI) GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error)
GenerateSymKeyFromPassword derive a key from the given password, stores it, and returns its ID.
func (*PublicWakuAPI) GetFilterMessages ¶
func (api *PublicWakuAPI) GetFilterMessages(id string) ([]*Message, error)
GetFilterMessages returns the messages that match the filter criteria and are received between the last poll and now.
func (*PublicWakuAPI) GetPrivateKey ¶
GetPrivateKey returns the private key associated with the given key. The key is the hex encoded representation of a key in the form specified in section 4.3.6 of ANSI X9.62.
func (*PublicWakuAPI) GetPublicKey ¶
GetPublicKey returns the public key associated with the given key. The key is the hex encoded representation of a key in the form specified in section 4.3.6 of ANSI X9.62.
func (*PublicWakuAPI) HasKeyPair ¶
func (api *PublicWakuAPI) HasKeyPair(ctx context.Context, id string) bool
HasKeyPair returns an indication if the node has a key pair that is associated with the given id.
func (*PublicWakuAPI) HasSymKey ¶
func (api *PublicWakuAPI) HasSymKey(ctx context.Context, id string) bool
HasSymKey returns an indication if the node has a symmetric key associated with the given key.
func (*PublicWakuAPI) Info ¶
func (api *PublicWakuAPI) Info(ctx context.Context) Info
Info returns diagnostic information about the waku node.
func (*PublicWakuAPI) Messages ¶
func (api *PublicWakuAPI) Messages(ctx context.Context, crit Criteria) (*rpc.Subscription, error)
Messages set up a subscription that fires events when messages arrive that match the given set of criteria.
func (*PublicWakuAPI) NewKeyPair ¶
func (api *PublicWakuAPI) NewKeyPair(ctx context.Context) (string, error)
NewKeyPair generates a new public and private key pair for message decryption and encryption. It returns an ID that can be used to refer to the keypair.
func (*PublicWakuAPI) NewMessageFilter ¶
func (api *PublicWakuAPI) NewMessageFilter(req Criteria) (string, error)
NewMessageFilter creates a new filter that can be used to poll for (new) messages that satisfy the given criteria.
func (*PublicWakuAPI) NewSymKey ¶
func (api *PublicWakuAPI) NewSymKey(ctx context.Context) (string, error)
NewSymKey generate a random symmetric key. It returns an ID that can be used to refer to the key. Can be used encrypting and decrypting messages where the key is known to both parties.
func (*PublicWakuAPI) Post ¶
func (api *PublicWakuAPI) Post(ctx context.Context, req NewMessage) (hexutil.Bytes, error)
Post posts a message on the Waku network. returns the hash of the message in case of success.
func (*PublicWakuAPI) UninstallFilter ¶
func (api *PublicWakuAPI) UninstallFilter(id string)
UninstallFilter is alias for Unsubscribe
func (*PublicWakuAPI) Unsubscribe ¶
func (api *PublicWakuAPI) Unsubscribe(id string)
Unsubscribe disables and removes an existing filter.
type Waku ¶
type Waku struct {
// contains filtered or unexported fields
}
Waku represents a dark communication interface through the Ethereum network, using its very own P2P communication layer.
func New ¶
func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *sql.DB, ts *timesource.NTPTimeSource) (*Waku, error)
New creates a WakuV2 client ready to communicate through the LibP2P network.
func (*Waku) AddKeyPair ¶
func (w *Waku) AddKeyPair(key *ecdsa.PrivateKey) (string, error)
AddKeyPair imports a asymmetric private key and returns it identifier.
func (*Waku) AddRelayPeer ¶ added in v0.88.4
func (*Waku) AddStorePeer ¶ added in v0.88.4
func (*Waku) AddSymKeyDirect ¶
AddSymKeyDirect stores the key, and returns its id.
func (*Waku) AddSymKeyFromPassword ¶
AddSymKeyFromPassword generates the key from password, stores it, and returns its id.
func (*Waku) ConfirmationsEnabled ¶
ConfirmationsEnabled returns true if message confirmations are enabled.
func (*Waku) ConnectionChanged ¶ added in v0.117.1
func (w *Waku) ConnectionChanged(state connection.State)
func (*Waku) DeleteKeyPair ¶
DeleteKeyPair deletes the specified key if it exists.
func (*Waku) DeleteKeyPairs ¶
DeleteKeyPairs removes all cryptographic identities known to the node
func (*Waku) DeleteSymKey ¶
DeleteSymKey deletes the key associated with the name string if it exists.
func (*Waku) DialPeerByID ¶ added in v0.88.4
func (*Waku) Envelopes ¶
func (w *Waku) Envelopes() []*common.ReceivedMessage
Envelopes retrieves all the messages currently pooled by the node.
func (*Waku) GenerateSymKey ¶
GenerateSymKey generates a random symmetric key and stores it under id, which is then returned. Will be used in the future for session key exchange.
func (*Waku) GetEnvelope ¶
func (w *Waku) GetEnvelope(hash gethcommon.Hash) *common.ReceivedMessage
GetEnvelope retrieves an envelope from the message queue by its hash. It returns nil if the envelope can not be found.
func (*Waku) GetPrivateKey ¶
func (w *Waku) GetPrivateKey(id string) (*ecdsa.PrivateKey, error)
GetPrivateKey retrieves the private key of the specified identity.
func (*Waku) GetStats ¶ added in v0.83.8
func (w *Waku) GetStats() types.StatsSummary
func (*Waku) HasKeyPair ¶
HasKeyPair checks if the waku node is configured with the private key of the specified public pair.
func (*Waku) HasSymKey ¶
HasSymKey returns true if there is a key associated with the given id. Otherwise returns false.
func (*Waku) IsEnvelopeCached ¶
func (w *Waku) IsEnvelopeCached(hash gethcommon.Hash) bool
isEnvelopeCached checks if envelope with specific hash has already been received and cached.
func (*Waku) ListenAddresses ¶ added in v0.115.4
func (*Waku) MarkP2PMessageAsProcessed ¶ added in v0.91.13
func (w *Waku) MarkP2PMessageAsProcessed(hash gethcommon.Hash)
func (*Waku) MaxMessageSize ¶
MaxMessageSize returns the maximum accepted message size.
func (*Waku) NewKeyPair ¶
NewKeyPair generates a new cryptographic identity for the client, and injects it into the known identities for message decryption. Returns ID of the new key pair.
func (*Waku) OnNewEnvelopes ¶
func (w *Waku) OnNewEnvelopes(envelope *protocol.Envelope, msgType common.MessageType) ([]common.EnvelopeError, error)
func (*Waku) ProcessingP2PMessages ¶ added in v0.91.13
func (*Waku) SelectKeyPair ¶
func (w *Waku) SelectKeyPair(key *ecdsa.PrivateKey) error
SelectKeyPair adds cryptographic identity, and makes sure that it is the only private key known to the node.
func (*Waku) Send ¶
func (w *Waku) Send(msg *pb.WakuMessage) ([]byte, error)
Send injects a message into the waku send queue, to be distributed in the network in the coming cycles.
func (*Waku) SendEnvelopeEvent ¶
func (w *Waku) SendEnvelopeEvent(event common.EnvelopeEvent) int
func (*Waku) Start ¶
Start implements node.Service, starting the background data propagation thread of the Waku protocol.
func (*Waku) StartDiscV5 ¶ added in v0.91.8
func (*Waku) Stop ¶
Stop implements node.Service, stopping the background data propagation thread of the Waku protocol.
func (*Waku) StopDiscV5 ¶ added in v0.91.8
func (*Waku) Subscribe ¶
Subscribe installs a new message handler used for filtering, decrypting and subsequent storing of incoming messages.
func (*Waku) SubscribeEnvelopeEvents ¶
func (w *Waku) SubscribeEnvelopeEvents(events chan<- common.EnvelopeEvent) event.Subscription
SubscribeEnvelopeEvents subscribes to envelopes feed. In order to prevent blocking waku producers events must be amply buffered.
func (*Waku) SubscribeToConnStatusChanges ¶ added in v0.93.2
func (w *Waku) SubscribeToConnStatusChanges() *types.ConnStatusSubscription
func (*Waku) Unsubscribe ¶
Unsubscribe removes an installed message handler.
func (*Waku) UnsubscribeMany ¶
Unsubscribe removes an installed message handler.