signal

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: MPL-2.0 Imports: 11 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 (
	// 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"

	// EventEnvelopeDiscarded is triggerd when envelope was discarded by a peer for some reason.
	EventEnvelopeDiscarded = "envelope.discarded"

	// 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"

	// EventWhisperFilterAdded is triggered when we setup a new filter or restore existing ones
	EventWhisperFilterAdded = "whisper.filter.added"

	// EventNewMessages is triggered when we receive new messages
	EventNewMessages = "messages.new"
)
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"
)

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 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 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 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 SendNewMessages added in v0.35.0

func SendNewMessages(response *statusproto.MessengerResponse)

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 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 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 SendWhisperFilterAdded added in v0.35.0

func SendWhisperFilterAdded(filters []*Filter)

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 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 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 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 Messages added in v0.35.0

type Messages struct {
	Error    error                       `json:"error"`
	Messages []*dedup.DeduplicateMessage `json:"messages"`
	Chat     statustransp.Filter         `json:"chat"` // not a mistake, it's called chat in status-react
}

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"`
}

type WhisperFilterAddedSignal added in v0.35.0

type WhisperFilterAddedSignal struct {
	Filters []*Filter `json:"filters"`
}

Jump to

Keyboard shortcuts

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