signal

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: MPL-2.0 Imports: 5 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"
)
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 ResetDefaultNodeNotificationHandler

func ResetDefaultNodeNotificationHandler()

ResetDefaultNodeNotificationHandler sets notification handler to default one

func SendChainDataRemoved

func SendChainDataRemoved()

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

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)

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)

nolint: golint

func TriggerDefaultNodeNotificationHandler

func TriggerDefaultNodeNotificationHandler(jsonEvent string)

TriggerDefaultNodeNotificationHandler triggers default notification handler (helpful in tests)

func TriggerTestSignal

func TriggerTestSignal()

nolint: golint

Types

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

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