signal

package
v0.91.13 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MPL-2.0 Imports: 8 Imported by: 30

Documentation

Overview

Package signal implements event-based signalling interface between status-go and externally linked codebases like status-react or status-desktop. Events are send asynchronously using OS-specific linking mechanisms. See sources for implementation details.

Index

Constants

View Source
const (
	// EventDiscoveryStarted is sent when node discv5 was started.
	EventDiscoveryStarted = "discovery.started"
	// EventDiscoveryStopped is sent when discv5 server was stopped.
	EventDiscoveryStopped = "discovery.stopped"

	// EventDiscoverySummary is sent when peer is added or removed.
	// it will be a map with capability=peer count k/v's.
	EventDiscoverySummary = "discovery.summary"
)
View Source
const (

	// EventMesssageDelivered triggered when we got acknowledge from datasync level, that means peer got message
	EventMesssageDelivered = "message.delivered"

	// EventCommunityFound triggered when user requested info about some community and messenger successfully
	// retrieved it from mailserver
	EventCommunityInfoFound = "community.found"
)
View Source
const (
	// EventNodeStarted is triggered when underlying node is started
	EventNodeStarted = "node.started"

	// EventNodeReady is triggered when underlying node is fully ready
	// (consider backend to be fully registered)
	EventNodeReady = "node.ready"

	// EventNodeStopped is triggered when underlying node is fully stopped
	EventNodeStopped = "node.stopped"

	// EventNodeCrashed is triggered when node crashes
	EventNodeCrashed = "node.crashed"

	// EventChainDataRemoved is triggered when node's chain data is removed
	EventChainDataRemoved = "chaindata.removed"

	// EventLoggedIn is once node was injected with user account and ready to be used.
	EventLoggedIn = "node.login"
)
View Source
const (
	// EventEnvelopeSent is triggered when envelope was sent at least to a one peer.
	EventEnvelopeSent = "envelope.sent"

	// EventEnvelopeExpired is triggered when envelop was dropped by a whisper without being sent
	// to any peer
	EventEnvelopeExpired = "envelope.expired"

	// EventMailServerRequestCompleted is triggered when whisper receives a message ack from the mailserver
	EventMailServerRequestCompleted = "mailserver.request.completed"

	// EventMailServerRequestExpired is triggered when request TTL ends
	EventMailServerRequestExpired = "mailserver.request.expired"

	// EventEnodeDiscovered is tiggered when enode has been discovered.
	EventEnodeDiscovered = "enode.discovered"

	// EventDecryptMessageFailed is triggered when we receive a message from a bundle we don't have
	EventDecryptMessageFailed = "messages.decrypt.failed"

	// EventBundleAdded is triggered when we receive a bundle
	EventBundleAdded = "bundles.added"

	// EventNewMessages is triggered when we receive new messages
	EventNewMessages = "messages.new"

	// EventHistoryRequestStarted is triggered before processing a mailserver batch
	EventHistoryRequestStarted = "history.request.started"

	// EventHistoryBatchProcessed is triggered after processing a mailserver batch
	EventHistoryBatchProcessed = "history.request.batch.processed"

	// EventHistoryRequestCompleted is triggered after processing all mailserver batches
	EventHistoryRequestCompleted = "history.request.completed"

	// EventHistoryRequestFailed is triggered when requesting history messages fails
	EventHistoryRequestFailed = "history.request.failed"

	// EventBackupPerformed is triggered when a backup has been performed
	EventBackupPerformed = "backup.performed"
)
View Source
const (
	// EventSignRequestAdded is triggered when send transaction request is queued
	EventSignRequestAdded = "sign-request.queued"
	// EventSignRequestFailed is triggered when send transaction request fails
	EventSignRequestFailed = "sign-request.failed"
)
View Source
const (
	// EventSubscriptionsData is triggered when there is new data in any of the subscriptions
	EventSubscriptionsData = "subscriptions.data"
	// EventSubscriptionsError is triggered when subscriptions failed to get new data
	EventSubscriptionsError = "subscriptions.error"
)
View Source
const (
	// EventPeerStats is sent when peer is added or removed.
	// it will be a map with capability=peer count k/v's.
	EventPeerStats = "wakuv2.peerstats"
)
View Source
const (
	// EventsStats is sent periodically with stats like upload/download rate
	EventStats = "stats"
)

Variables

This section is empty.

Functions

func NotifyNode

func NotifyNode(jsonEvent *C.char)

nolint: golint

func ResetDefaultNodeNotificationHandler

func ResetDefaultNodeNotificationHandler()

ResetDefaultNodeNotificationHandler sets notification handler to default one

func SendBackupPerformed added in v0.90.0

func SendBackupPerformed(lastBackup uint64)

func SendBundleAdded added in v0.16.4

func SendBundleAdded(identity string, installationID string)

func SendChainDataRemoved

func SendChainDataRemoved()

SendChainDataRemoved emits a signal when node's chain data has been removed.

func SendCommunityInfoFound added in v0.76.3

func SendCommunityInfoFound(community interface{})

SendMessageDelivered notifies about delivered message

func SendDecryptMessageFailed added in v0.15.1

func SendDecryptMessageFailed(sender string)

func SendDiscoveryStarted

func SendDiscoveryStarted()

SendDiscoveryStarted sends discovery.started signal.

func SendDiscoveryStopped

func SendDiscoveryStopped()

SendDiscoveryStopped sends discovery.stopped signal.

func SendDiscoverySummary

func SendDiscoverySummary(summary interface{})

SendDiscoverySummary sends discovery.summary signal.

func SendEnodeDiscovered

func SendEnodeDiscovered(enode, topic string)

SendEnodeDiscovered tiggered when an enode is discovered. finds a new enode.

func SendEnvelopeExpired

func SendEnvelopeExpired(identifiers [][]byte, err error)

SendEnvelopeExpired triggered when envelope delivered at least to 1 peer.

func SendEnvelopeSent

func SendEnvelopeSent(identifiers [][]byte)

SendEnvelopeSent triggered when envelope delivered at least to 1 peer.

func SendHistoricMessagesRequestBatchProcessed added in v0.89.20

func SendHistoricMessagesRequestBatchProcessed(requestID string, batchIndex int, numBatches int)

func SendHistoricMessagesRequestCompleted added in v0.89.2

func SendHistoricMessagesRequestCompleted(requestID string)

func SendHistoricMessagesRequestFailed added in v0.89.2

func SendHistoricMessagesRequestFailed(requestID string, err error)

func SendHistoricMessagesRequestStarted added in v0.89.2

func SendHistoricMessagesRequestStarted(requestID string, numBatches int)

func SendLocalNotifications added in v0.62.16

func SendLocalNotifications(event interface{})

SendLocalNotifications sends event with a local notification.

func SendLoggedIn added in v0.35.0

func SendLoggedIn(err error)

func SendMailServerRequestCompleted

func SendMailServerRequestCompleted(requestID types.Hash, lastEnvelopeHash types.Hash, cursor []byte, err error)

SendMailServerRequestCompleted triggered when mail server response has been received

func SendMailServerRequestExpired

func SendMailServerRequestExpired(hash types.Hash)

SendMailServerRequestExpired triggered when mail server request expires

func SendMessageDelivered added in v0.71.5

func SendMessageDelivered(chatID string, messageID string)

SendMessageDelivered notifies about delivered message

func SendNewMessages added in v0.35.0

func SendNewMessages(obj json.Marshaler)

func SendNodeCrashed

func SendNodeCrashed(err error)

SendNodeCrashed emits a signal when status node has crashed, and provides error description.

func SendNodeReady

func SendNodeReady()

SendNodeReady emits a signal when status node has started and successfully completed startup.

func SendNodeStarted

func SendNodeStarted()

SendNodeStarted emits a signal when status node has just started (but not finished startup yet).

func SendNodeStopped

func SendNodeStopped()

SendNodeStopped emits a signal when underlying node has stopped.

func SendPeerStats added in v0.88.1

func SendPeerStats(peerStats interface{})

SendPeerStats sends discovery.summary signal.

func SendSignRequestAdded

func SendSignRequestAdded(event PendingRequestEvent)

SendSignRequestAdded sends a signal when a sign request is added.

func SendSignRequestFailed

func SendSignRequestFailed(event PendingRequestEvent, err error, errCode int)

SendSignRequestFailed sends a signal of failed sign request.

func SendStats added in v0.83.8

func SendStats(stats interface{})

SendStats sends stats signal.

func SendSubscriptionDataEvent added in v0.35.0

func SendSubscriptionDataEvent(filterID string, data []interface{})

SendSubscriptionDataEvent

func SendSubscriptionErrorEvent added in v0.35.0

func SendSubscriptionErrorEvent(filterID string, err error)

SendSubscriptionErrorEvent

func SendWalletEvent added in v0.35.0

func SendWalletEvent(event interface{})

SendWalletEvent sends event from services/wallet/events.

func SetDefaultNodeNotificationHandler

func SetDefaultNodeNotificationHandler(fn NodeNotificationHandler)

SetDefaultNodeNotificationHandler sets notification handler to invoke on Send

func SetMobileSignalHandler added in v0.35.0

func SetMobileSignalHandler(handler MobileSignalHandler)

SetMobileSignalHandler sets new handler for geth events this function uses pure go implementation

func SetSignalEventCallback

func SetSignalEventCallback(cb unsafe.Pointer)

SetSignalEventCallback set callback this function uses C implementation (see `signals.c` file)

func TriggerDefaultNodeNotificationHandler

func TriggerDefaultNodeNotificationHandler(jsonEvent string)

TriggerDefaultNodeNotificationHandler triggers default notification handler (helpful in tests)

func TriggerTestSignal

func TriggerTestSignal()

nolint: golint

Types

type BackupPerformedSignal added in v0.90.0

type BackupPerformedSignal struct {
	LastBackup uint64 `json:"lastBackup"`
}

BackupPerformedSignal signals that a backup has been performed

type BundleAddedSignal added in v0.16.4

type BundleAddedSignal struct {
	Identity       string `json:"identity"`
	InstallationID string `json:"installationID"`
}

BundleAddedSignal holds the identity and installation id of the user

type CommunityInfoFoundSignal added in v0.76.3

type CommunityInfoFoundSignal struct {
	Name         string `json:"name"`
	Description  string `json:"description"`
	MembersCount int    `json:"membersCount"`
	Verified     bool   `json:"verified"`
}

MessageDeliveredSignal specifies chat and message that was delivered

type DecryptMessageFailedSignal added in v0.15.1

type DecryptMessageFailedSignal struct {
	Sender string `json:"sender"`
}

DecryptMessageFailedSignal holds the sender of the message that could not be decrypted

type EnodeDiscoveredSignal

type EnodeDiscoveredSignal struct {
	Enode string `json:"enode"`
	Topic string `json:"topic"`
}

EnodeDiscoveredSignal includes enode address and topic

type Envelope

type Envelope struct {
	Type  string      `json:"type"`
	Event interface{} `json:"event"`
}

Envelope is a general signal sent upward from node to RN app

func NewEnvelope

func NewEnvelope(typ string, event interface{}) *Envelope

NewEnvelope creates new envlope of given type and event payload.

type EnvelopeSignal

type EnvelopeSignal struct {
	IDs     []hexutil.Bytes `json:"ids"`
	Hash    types.Hash      `json:"hash"`
	Message string          `json:"message"`
}

EnvelopeSignal includes hash of the envelope.

type Filter added in v0.35.0

type Filter struct {
	// ChatID is the identifier of the chat
	ChatID string `json:"chatId"`
	// SymKeyID is the symmetric key id used for symmetric chats
	SymKeyID string `json:"symKeyId"`
	// OneToOne tells us if we need to use asymmetric encryption for this chat
	Listen bool `json:"listen"`
	// FilterID the whisper filter id generated
	FilterID string `json:"filterId"`
	// Identity is the public key of the other recipient for non-public chats
	Identity string `json:"identity"`
	// Topic is the whisper topic
	Topic types.TopicType `json:"topic"`
}

type HistoryMessagesSignal added in v0.89.2

type HistoryMessagesSignal struct {
	RequestID  string `json:"requestId"`
	BatchIndex int    `json:"batchIndex"`
	NumBatches int    `json:"numBatches,omitempty"`
	ErrorMsg   string `json:"errorMessage,omitempty"`
}

type MailServerResponseSignal

type MailServerResponseSignal struct {
	RequestID        types.Hash `json:"requestID"`
	LastEnvelopeHash types.Hash `json:"lastEnvelopeHash"`
	Cursor           string     `json:"cursor"`
	ErrorMsg         string     `json:"errorMessage"`
}

MailServerResponseSignal holds the data received in the response from the mailserver.

type MessageDeliveredSignal added in v0.71.5

type MessageDeliveredSignal struct {
	ChatID    string `json:"chatID"`
	MessageID string `json:"messageID"`
}

MessageDeliveredSignal specifies chat and message that was delivered

type MobileSignalHandler added in v0.35.0

type MobileSignalHandler func([]byte)

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

type NodeCrashEvent

type NodeCrashEvent struct {
	Error string `json:"error"`
}

NodeCrashEvent is special kind of error, used to report node crashes

type NodeLoginEvent added in v0.35.0

type NodeLoginEvent struct {
	Error string `json:"error,omitempty"`
}

NodeLoginEvent returns the result of the login event

type NodeNotificationHandler

type NodeNotificationHandler func(jsonEvent string)

NodeNotificationHandler defines a handler able to process incoming node events. Events are encoded as JSON strings.

type PendingRequestErrorEvent

type PendingRequestErrorEvent struct {
	PendingRequestEvent
	ErrorMessage string `json:"error_message"`
	ErrorCode    int    `json:"error_code,string"`
}

PendingRequestErrorEvent is a signal sent when sign request has failed

type PendingRequestEvent

type PendingRequestEvent struct {
	ID        string      `json:"id"`
	Method    string      `json:"method"`
	Args      interface{} `json:"args"`
	MessageID string      `json:"message_id"`
}

PendingRequestEvent is a signal sent when a sign request is added

type SubscriptionDataEvent added in v0.35.0

type SubscriptionDataEvent struct {
	FilterID string        `json:"subscription_id"`
	Data     []interface{} `json:"data"`
}

type SubscriptionErrorEvent added in v0.35.0

type SubscriptionErrorEvent struct {
	FilterID     string `json:"subscription_id"`
	ErrorMessage string `json:"error_message"`
}

Jump to

Keyboard shortcuts

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