gowaku

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2023 License: MIT Imports: 37 Imported by: 0

README

Mobile

Package mobile implements gomobile bindings for go-waku.

Usage

For properly using this package, please refer to Makefile in the root of go-waku directory.

To manually build library, run following commands:

iOS
gomobile init
gomobile bind -v -target=ios -ldflags="-s -w" github.com/waku-org/go-waku/mobile

This will produce gowaku.framework file in the current directory, which can be used in iOS project.

Android
export ANDROID_NDK_HOME=/path/to/android/ndk
export ANDROID_HOME=/path/to/android/sdk/
gomobile init
gomobile bind -v -target=android -ldflags="-s -w" github.com/waku-org/go-waku/mobile

This will generate gowaku.aar file in the current dir.

Notes

See https://github.com/golang/go/wiki/Mobile for more information on gomobile usage.

Documentation

Overview

Implements gomobile bindings for go-waku. Contains a set of functions that are exported when go-waku is exported as libraries for mobile devices

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPeer

func AddPeer(address string, protocolID string) string

func Connect

func Connect(address string, ms int) string

func ConnectPeerID

func ConnectPeerID(peerID string, ms int) string

func ContentTopic

func ContentTopic(applicationName string, applicationVersion int, contentTopicName string, encoding string) string

func DecodeAsymmetric

func DecodeAsymmetric(messageJSON string, privateKey string) string

func DecodeSymmetric

func DecodeSymmetric(messageJSON string, symmetricKey string) string

func DefaultPubsubTopic

func DefaultPubsubTopic() string

func Disconnect

func Disconnect(peerID string) string

func DnsDiscovery

func DnsDiscovery(url string, nameserver string, ms int) string

func FilterSubscribe

func FilterSubscribe(filterJSON string, peerID string, ms int) string

func FilterUnsubscribe

func FilterUnsubscribe(filterJSON string, ms int) string

func GetGossipSubParams added in v0.5.2

func GetGossipSubParams(cfg *GossipSubParams) pubsub.GossipSubParams

func GetSeenTTL added in v0.6.0

func GetSeenTTL(cfg wakuConfig) time.Duration

func IsStarted

func IsStarted() string

func LightpushPublish

func LightpushPublish(messageJSON string, topic string, peerID string, ms int) string

func LightpushPublishEncodeAsymmetric

func LightpushPublishEncodeAsymmetric(messageJSON string, topic string, peerID string, publicKey string, optionalSigningKey string, ms int) string

func LightpushPublishEncodeSymmetric

func LightpushPublishEncodeSymmetric(messageJSON string, topic string, peerID string, symmetricKey string, optionalSigningKey string, ms int) string

func ListenAddresses

func ListenAddresses() string

func MakeJSONResponse

func MakeJSONResponse(err error) string

func NewNode

func NewNode(configJSON string) string

func PeerCnt

func PeerCnt() string

func PeerID

func PeerID() string

func Peers

func Peers() string

func PrepareJSONResponse

func PrepareJSONResponse(result interface{}, err error) string

func PubsubTopic

func PubsubTopic(name string, encoding string) string

func RelayEnoughPeers

func RelayEnoughPeers(topic string) string

func RelayPublish

func RelayPublish(messageJSON string, topic string, ms int) string

func RelayPublishEncodeAsymmetric

func RelayPublishEncodeAsymmetric(messageJSON string, topic string, publicKey string, optionalSigningKey string, ms int) string

func RelayPublishEncodeSymmetric

func RelayPublishEncodeSymmetric(messageJSON string, topic string, symmetricKey string, optionalSigningKey string, ms int) string

func RelaySubscribe

func RelaySubscribe(topic string) string

func RelayTopics added in v0.6.0

func RelayTopics() string

func RelayUnsubscribe

func RelayUnsubscribe(topic string) string

func SetEventCallback

func SetEventCallback(cb unsafe.Pointer)

func SetMobileSignalHandler

func SetMobileSignalHandler(handler SignalHandler)

SetMobileSignalHandler setup geth callback to notify about new signal used for gomobile builds nolint

func Start

func Start() string

func StartDiscoveryV5

func StartDiscoveryV5() string

func Stop

func Stop() string

func StopDiscoveryV5

func StopDiscoveryV5() string

func StoreLocalQuery added in v0.5.0

func StoreLocalQuery(queryJSON string) string

func StoreQuery

func StoreQuery(queryJSON string, peerID string, ms int) string

Types

type DnsDiscoveryItem added in v0.5.0

type DnsDiscoveryItem struct {
	PeerID    string   `json:"peerID"`
	Addresses []string `json:"multiaddrs"`
	ENR       string   `json:"enr,omitempty"`
}

type FilterArgument

type FilterArgument struct {
	Topic          string                            `json:"pubsubTopic,omitempty"`
	ContentFilters []*pb.FilterRequest_ContentFilter `json:"contentFilters,omitempty"`
}

type GossipSubParams added in v0.5.2

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)

SignalHandler is a simple callback function that gets called when any signal is received

type SignalHandler

type SignalHandler interface {
	HandleSignal(string)
}

SignalHandler defines a minimal interface a signal handler needs to implement. nolint

type WakuState added in v0.5.0

type WakuState struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL