Documentation ¶
Index ¶
- func AddPeer(address string, protocolID string) (string, error)
- func Connect(address string, ms int) error
- func ConnectPeerID(peerID string, ms int) error
- func ContentTopic(applicationName string, applicationVersion string, contentTopicName string, ...) string
- func DNSDiscovery(url string, nameserver string, ms int) (string, error)
- func DecodeAsymmetric(messageJSON string, privateKey string) (string, error)
- func DecodeSymmetric(messageJSON string, symmetricKey string) (string, error)
- func DefaultPubsubTopic() string
- func Disconnect(peerID string) error
- func EncodeAsymmetric(messageJSON string, publicKey string, optionalSigningKey string) (string, error)
- func EncodeSymmetric(messageJSON string, symmetricKey string, optionalSigningKey string) (string, error)
- func FilterPing(peerID string, ms int) error
- func FilterSubscribe(filterJSON string, peerID string, ms int) (string, error)
- func FilterUnsubscribe(filterJSON string, peerID string, ms int) error
- func FilterUnsubscribeAll(peerID string, ms int) (string, error)
- func IsStarted() bool
- func LegacyFilterSubscribe(filterJSON string, peerID string, ms int) error
- func LegacyFilterUnsubscribe(filterJSON string, ms int) error
- func LightpushPublish(messageJSON string, pubsubTopic string, peerID string, ms int) (string, error)
- func ListenAddresses() (string, error)
- func NewNode(configJSON string) error
- func PeerCnt() (int, error)
- func PeerID() (string, error)
- func Peers() (string, error)
- func RelayEnoughPeers(topic string) (bool, error)
- func RelayPublish(messageJSON string, topic string, ms int) (string, error)
- func RelaySubscribe(contentFilterJSON string) error
- func RelayTopics() (string, error)
- func RelayUnsubscribe(contentFilterJSON string) error
- func SetBootnodes(bootnodes string) error
- func SetEventCallback(cb unsafe.Pointer)
- func SetMobileSignalHandler(m MobileSignalHandler)
- func Start() error
- func StartDiscoveryV5() error
- func Stop() error
- func StopDiscoveryV5() error
- func StoreLocalQuery(queryJSON string) (string, error)
- func StoreQuery(queryJSON string, peerID string, ms int) (string, error)
- type GossipSubParams
- type MobileSignalHandler
- type WakuConfig
- type WakuState
- type WebsocketConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
Connect is used to connect to a peer at multiaddress. if ms > 0, cancel the function execution if it takes longer than N milliseconds
func ConnectPeerID ¶
ConnectPeerID is usedd to connect to a known peer by peerID. if ms > 0, cancel the function execution if it takes longer than N milliseconds
func ContentTopic ¶
func ContentTopic(applicationName string, applicationVersion string, contentTopicName string, encoding string) string
ContentTopic creates a content topic string according to RFC 23
func DNSDiscovery ¶
DNSDiscovery executes dns discovery on an url and returns a list of nodes
func DecodeAsymmetric ¶
DecodeAsymmetric decodes a waku message using a secp256k1 private key. The key must be a hex encoded string with "0x" prefix
func DecodeSymmetric ¶
DecodeSymmetric decodes a waku message using a 32 bytes symmetric key. The key must be a hex encoded string with "0x" prefix
func DefaultPubsubTopic ¶
func DefaultPubsubTopic() string
DefaultPubsubTopic returns the default pubsub topic used in waku2: /waku/2/default-waku/proto
func Disconnect ¶
Disconnect closes a connection to a known peer by peerID
func EncodeAsymmetric ¶
func EncodeSymmetric ¶
func FilterPing ¶
FilterPing is used to determine if a peer has an active subscription
func FilterSubscribe ¶
FilterSubscribe is used to create a subscription to a filter node to receive messages
func FilterUnsubscribe ¶
FilterUnsubscribe is used to remove a filter criteria from an active subscription with a filter node
func FilterUnsubscribeAll ¶
FilterUnsubscribeAll is used to remove an active subscription to a peer. If no peerID is defined, it will stop all active filter subscriptions
func LegacyFilterSubscribe ¶
LegacyFilterSubscribe is used to create a subscription to a filter node to receive messages Deprecated: Use FilterSubscribe instead
func LegacyFilterUnsubscribe ¶
LegacyFilterUnsubscribe is used to remove a filter criteria from an active subscription with a filter node Deprecated: Use FilterUnsubscribe or FilterUnsubscribeAll instead
func LightpushPublish ¶
func LightpushPublish(messageJSON string, pubsubTopic string, peerID string, ms int) (string, error)
LightpushPublish is used to publish a WakuMessage in a pubsub topic using Lightpush protocol
func ListenAddresses ¶
ListenAddresses returns the multiaddresses the wakunode is listening to
func NewNode ¶
NewNode initializes a waku node. Receives a JSON string containing the configuration, and use default values for those config items not specified
func RelayEnoughPeers ¶
RelayEnoughPeers determines if there are enough peers to publish a message on a topic
func RelayPublish ¶
RelayPublish publishes a message using waku relay and returns the message ID
func RelaySubscribe ¶
RelaySubscribe subscribes to a WakuRelay topic.
func RelayTopics ¶
RelayTopics returns a list of pubsub topics the node is subscribed to in WakuRelay
func RelayUnsubscribe ¶
RelayUnsubscribe closes the pubsub subscription to a pubsub topic
func SetBootnodes ¶
SetBootnodes is used to update the bootnodes receiving a JSON array of ENRs
func SetEventCallback ¶
SetEventCallback is to set a callback in order to receive application signals which are used to react to asynchronous events in waku.
func SetMobileSignalHandler ¶
func SetMobileSignalHandler(m MobileSignalHandler)
SetMobileSignalHandler sets the callback to be executed when a signal is received in a mobile device
func StoreLocalQuery ¶
StoreLocalQuery is used to retrieve historic messages stored in the localDB using waku store protocol.
Types ¶
type GossipSubParams ¶
type GossipSubParams struct { // D sets the optimal degree for a GossipSub topic mesh. For example, if D == 6, // each peer will want to have about six peers in their mesh for each topic they're subscribed to. // D should be set somewhere between Dlo and Dhi. D *int `json:"d,omitempty"` // Dlo sets the lower bound on the number of peers we keep in a GossipSub topic mesh. // If we have fewer than Dlo peers, we will attempt to graft some more into the mesh at // the next heartbeat. Dlo *int `json:"d_low,omitempty"` // Dhi sets the upper bound on the number of peers we keep in a GossipSub topic mesh. // If we have more than Dhi peers, we will select some to prune from the mesh at the next heartbeat. Dhi *int `json:"d_high,omitempty"` // Dscore affects how peers are selected when pruning a mesh due to over subscription. // At least Dscore of the retained peers will be high-scoring, while the remainder are // chosen randomly. Dscore *int `json:"d_score,omitempty"` // Dout sets the quota for the number of outbound connections to maintain in a topic mesh. // When the mesh is pruned due to over subscription, we make sure that we have outbound connections // to at least Dout of the survivor peers. This prevents sybil attackers from overwhelming // our mesh with incoming connections. // // Dout must be set below Dlo, and must not exceed D / 2. Dout *int `json:"dOut,omitempty"` // HistoryLength controls the size of the message cache used for gossip. // The message cache will remember messages for HistoryLength heartbeats. HistoryLength *int `json:"historyLength,omitempty"` // HistoryGossip controls how many cached message ids we will advertise in // IHAVE gossip messages. When asked for our seen message IDs, we will return // only those from the most recent HistoryGossip heartbeats. The slack between // HistoryGossip and HistoryLength allows us to avoid advertising messages // that will be expired by the time they're requested. // // HistoryGossip must be less than or equal to HistoryLength to // avoid a runtime panic. HistoryGossip *int `json:"historyGossip,omitempty"` // Dlazy affects how many peers we will emit gossip to at each heartbeat. // We will send gossip to at least Dlazy peers outside our mesh. The actual // number may be more, depending on GossipFactor and how many peers we're // connected to. Dlazy *int `json:"dLazy,omitempty"` // GossipFactor affects how many peers we will emit gossip to at each heartbeat. // We will send gossip to GossipFactor * (total number of non-mesh peers), or // Dlazy, whichever is greater. GossipFactor *float64 `json:"gossipFactor,omitempty"` // GossipRetransmission controls how many times we will allow a peer to request // the same message id through IWANT gossip before we start ignoring them. This is designed // to prevent peers from spamming us with requests and wasting our resources. GossipRetransmission *int `json:"gossipRetransmission,omitempty"` // HeartbeatInitialDelayMs is the short delay before the heartbeat timer begins // after the router is initialized. HeartbeatInitialDelayMs *int `json:"heartbeatInitialDelayMs,omitempty"` // HeartbeatIntervalSeconds controls the time between heartbeats. HeartbeatIntervalSeconds *int `json:"heartbeatIntervalSeconds,omitempty"` // SlowHeartbeatWarning is the duration threshold for heartbeat processing before emitting // a warning; this would be indicative of an overloaded peer. SlowHeartbeatWarning *float64 `json:"slowHeartbeatWarning,omitempty"` // FanoutTTLSeconds controls how long we keep track of the fanout state. If it's been // FanoutTTLSeconds since we've published to a topic that we're not subscribed to, // we'll delete the fanout map for that topic. FanoutTTLSeconds *int `json:"fanoutTTLSeconds,omitempty"` // PrunePeers controls the number of peers to include in prune Peer eXchange. // When we prune a peer that's eligible for PX (has a good score, etc), we will try to // send them signed peer records for up to PrunePeers other peers that we // know of. PrunePeers *int `json:"prunePeers,omitempty"` // PruneBackoffSeconds controls the backoff time for pruned peers. This is how long // a peer must wait before attempting to graft into our mesh again after being pruned. // When pruning a peer, we send them our value of PruneBackoff so they know // the minimum time to wait. Peers running older versions may not send a backoff time, // so if we receive a prune message without one, we will wait at least PruneBackoff // before attempting to re-graft. PruneBackoffSeconds *int `json:"pruneBackoffSeconds,omitempty"` // UnsubscribeBackoffSeconds controls the backoff time to use when unsuscribing // from a topic. A peer should not resubscribe to this topic before this // duration. UnsubscribeBackoffSeconds *int `json:"unsubscribeBackoffSeconds,omitempty"` // Connectors controls the number of active connection attempts for peers obtained through PX. Connectors *int `json:"connectors,omitempty"` // MaxPendingConnections sets the maximum number of pending connections for peers attempted through px. MaxPendingConnections *int `json:"maxPendingConnections,omitempty"` // ConnectionTimeoutSeconds controls the timeout for connection attempts. ConnectionTimeoutSeconds *int `json:"connectionTimeoutSeconds,omitempty"` // DirectConnectTicks is the number of heartbeat ticks for attempting to reconnect direct peers // that are not currently connected. DirectConnectTicks *uint64 `json:"directConnectTicks,omitempty"` // DirectConnectInitialDelaySeconds is the initial delay before opening connections to direct peers DirectConnectInitialDelaySeconds *int `json:"directConnectInitialDelaySeconds,omitempty"` // OpportunisticGraftTicks is the number of heartbeat ticks for attempting to improve the mesh // with opportunistic grafting. Every OpportunisticGraftTicks we will attempt to select some // high-scoring mesh peers to replace lower-scoring ones, if the median score of our mesh peers falls // below a threshold (see https://godoc.org/github.com/libp2p/go-libp2p-pubsub#PeerScoreThresholds). OpportunisticGraftTicks *uint64 `json:"opportunisticGraftTicks,omitempty"` // OpportunisticGraftPeers is the number of peers to opportunistically graft. OpportunisticGraftPeers *int `json:"opportunisticGraftPeers,omitempty"` // If a GRAFT comes before GraftFloodThresholdSeconds has elapsed since the last PRUNE, // then there is an extra score penalty applied to the peer through P7. GraftFloodThresholdSeconds *int `json:"graftFloodThresholdSeconds,omitempty"` // MaxIHaveLength is the maximum number of messages to include in an IHAVE message. // Also controls the maximum number of IHAVE ids we will accept and request with IWANT from a // peer within a heartbeat, to protect from IHAVE floods. You should adjust this value from the // default if your system is pushing more than 5000 messages in HistoryGossip heartbeats; // with the defaults this is 1666 messages/s. MaxIHaveLength *int `json:"maxIHaveLength,omitempty"` // MaxIHaveMessages is the maximum number of IHAVE messages to accept from a peer within a heartbeat. MaxIHaveMessages *int `json:"maxIHaveMessages,omitempty"` // Time to wait for a message requested through IWANT following an IHAVE advertisement. // If the message is not received within this window, a broken promise is declared and // the router may apply bahavioural penalties. IWantFollowupTimeSeconds *int `json:"iWantFollowupTimeSeconds,omitempty"` // configures when a previously seen message ID can be forgotten about SeenMessagesTTLSeconds *int `json:"seenMessagesTTLSeconds"` }
GossipSubParams defines all the gossipsub specific parameters.
type MobileSignalHandler ¶
type MobileSignalHandler func([]byte)
MobileSignalHandler is a simple callback function that gets called when any signal is received
type WakuConfig ¶
type WakuConfig struct { Host *string `json:"host,omitempty"` Port *int `json:"port,omitempty"` AdvertiseAddress *string `json:"advertiseAddr,omitempty"` NodeKey *string `json:"nodeKey,omitempty"` LogLevel *string `json:"logLevel,omitempty"` KeepAliveInterval *int `json:"keepAliveInterval,omitempty"` EnableRelay *bool `json:"relay"` RelayTopics []string `json:"relayTopics,omitempty"` GossipSubParams *GossipSubParams `json:"gossipsubParams,omitempty"` EnableLegacyFilter *bool `json:"legacyFilter,omitempty"` MinPeersToPublish *int `json:"minPeersToPublish,omitempty"` DNSDiscoveryURLs []string `json:"dnsDiscoveryURLs,omitempty"` DNSDiscoveryNameServer string `json:"dnsDiscoveryNameServer,omitempty"` EnableDiscV5 *bool `json:"discV5,omitempty"` DiscV5BootstrapNodes []string `json:"discV5BootstrapNodes,omitempty"` DiscV5UDPPort *uint `json:"discV5UDPPort,omitempty"` EnableStore *bool `json:"store,omitempty"` DatabaseURL *string `json:"databaseURL,omitempty"` RetentionMaxMessages *int `json:"storeRetentionMaxMessages,omitempty"` RetentionTimeSeconds *int `json:"storeRetentionTimeSeconds,omitempty"` DNS4DomainName string `json:"dns4DomainName,omitempty"` Websockets *WebsocketConfig `json:"websockets,omitempty"` }
WakuConfig contains all the configuration settings exposed to users of mobile and c libraries
type WakuState ¶
type WakuState struct {
// contains filtered or unexported fields
}
WakuState represents the state of the waku node
type WebsocketConfig ¶
type WebsocketConfig struct { Enabled bool `json:"enabled,omitempty"` Host string `json:"host,omitempty"` Port *int `json:"port,omitempty"` Secure bool `json:"secure,omitempty"` CertPath string `json:"certPath"` KeyPath string `json:"keyPath"` }
WebsocketConfig contains all the settings required to setup websocket support in waku
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Set of functions that are exported when go-waku is built as a static/dynamic library
|
Set of functions that are exported when go-waku is built as a static/dynamic library |
Package gowaku implements gomobile bindings for go-waku.
|
Package gowaku implements gomobile bindings for go-waku. |