signal

package
v0.16.4-7-gd0f204dc Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: MPL-2.0 Imports: 6 Imported by: 0

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

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(hash common.Hash)

SendEnvelopeExpired triggered when envelope delivered at least to 1 peer.

func SendEnvelopeSent

func SendEnvelopeSent(hash common.Hash)

SendEnvelopeSent triggered when envelope delivered at least to 1 peer.

func SendMailServerRequestCompleted

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

SendMailServerRequestCompleted triggered when mail server response has been received

func SendMailServerRequestExpired

func SendMailServerRequestExpired(hash common.Hash)

SendMailServerRequestExpired triggered when mail server request expires

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 SetDefaultNodeNotificationHandler

func SetDefaultNodeNotificationHandler(fn NodeNotificationHandler)

SetDefaultNodeNotificationHandler sets notification handler to invoke on Send

func SetSignalEventCallback

func SetSignalEventCallback(cb unsafe.Pointer)

SetSignalEventCallback set callback

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 {
	Hash common.Hash `json:"hash"`
}

EnvelopeSignal includes hash of the envelope.

type MailServerResponseSignal

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

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

type NodeCrashEvent

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

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

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

Jump to

Keyboard shortcuts

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