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
- func NotifyNode(jsonEvent *C.char)
- func ResetDefaultNodeNotificationHandler()
- func SendChainDataRemoved()
- func SendDiscoveryStarted()
- func SendDiscoveryStopped()
- func SendDiscoverySummary(summary interface{})
- func SendEnodeDiscovered(enode, topic string)
- func SendEnvelopeExpired(hash common.Hash)
- func SendEnvelopeSent(hash common.Hash)
- func SendMailServerRequestCompleted(requestID common.Hash, lastEnvelopeHash common.Hash, cursor []byte)
- func SendMailServerRequestExpired(hash common.Hash)
- func SendNodeCrashed(err error)
- func SendNodeReady()
- func SendNodeStarted()
- func SendNodeStopped()
- func SendSignRequestAdded(event PendingRequestEvent)
- func SendSignRequestFailed(event PendingRequestEvent, err error, errCode int)
- func SetDefaultNodeNotificationHandler(fn NodeNotificationHandler)
- func SetSignalEventCallback(cb unsafe.Pointer)
- func TriggerDefaultNodeNotificationHandler(jsonEvent string)
- func TriggerTestSignal()
- type EnodeDiscoveredSignal
- type Envelope
- type EnvelopeSignal
- type MailServerResponseSignal
- type NodeCrashEvent
- type NodeNotificationHandler
- type PendingRequestErrorEvent
- type PendingRequestEvent
Constants ¶
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" )
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" )
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" )
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 ¶
SendEnvelopeExpired triggered when envelope delivered at least to 1 peer.
func SendEnvelopeSent ¶
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 ¶
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 ¶
SetSignalEventCallback set callback
func TriggerDefaultNodeNotificationHandler ¶
func TriggerDefaultNodeNotificationHandler(jsonEvent string)
TriggerDefaultNodeNotificationHandler triggers default notification handler (helpful in tests)
Types ¶
type EnodeDiscoveredSignal ¶
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 ¶
NewEnvelope creates new envlope of given type and event payload.
type EnvelopeSignal ¶
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