subscriptions

package
v0.179.11 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

README

Signal Subscriptions

This package implements subscriptions mechanics using signal package.

It defines 3 new RPC methods in the eth namespace and 2 signals.

Methods

###eth_subscribeSignal Creates a new filter and subscribes to its changes via signals.

Parameters: receives the method name and parameters for the filter that is created.

Example 1:

{
  "jsonrpc": "2.0", 
  "id": 1,
  "method": "eth_subscribeSignal", 
  "params": ["eth_newPendingTransactionFilter", []]
}

Example 2:

{
  "jsonrpc": "2.0", 
  "id": 2,
  "method": "eth_subscribeSignal", 
  "params": [
    "shh_newMessageFilter",
    [{ "symKeyID":"abcabcabcabc", "topics": ["0x12341234"] }]
  ]
}

Supported filters: shh_newMessageFilter, eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter (see Ethereum documentation for respective parameters).

Returns: error or subscriptionID.

###eth_unsubscribeSignal Unsubscribes and removes one filter by its ID. NOTE: Unsubscribing from a filter removes it.

Parameters: subscriptionID obtained from eth_subscribeSignal Returns: error if something went wrong while unsubscribing.

Signals

  1. Subscription data received
{
  "type": "subscriptions.data",
  "event": {
    "subscription_id": "shh_0x01",
    "data": {
        <whisper envelope 01>,
        <whisper envelope 02>,
        ...
    }
}
  1. Subscription error received
{
  "type": "subscriptions.error",
  "event": {
    "subscription_id": "shh_0x01",
    "error_message": "can not find filter with id: 0x01"
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func NewPublicAPI

func NewPublicAPI(rpcPrivateClientFunc func() *rpc.Client) *API

func (*API) SubscribeSignal

func (api *API) SubscribeSignal(method string, args []interface{}) (SubscriptionID, error)

func (*API) UnsubscribeSignal

func (api *API) UnsubscribeSignal(id string) error

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service represents our own implementation of personal sign operations.

func New

func New(rpcPrivateClientFunc func() *rpc.Client) *Service

New returns a new Service.

func (*Service) APIs

func (s *Service) APIs() []gethrpc.API

APIs returns a list of new APIs.

func (*Service) Protocols

func (s *Service) Protocols() []p2p.Protocol

Protocols returns a new protocols list. In this case, there are none.

func (*Service) Start

func (s *Service) Start() error

Start is run when a service is started.

func (*Service) Stop

func (s *Service) Stop() error

Stop is run when a service is stopped.

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

func NewSubscription

func NewSubscription(namespace string, filter filter) *Subscription

func (*Subscription) Start

func (s *Subscription) Start(checkPeriod time.Duration) error

func (*Subscription) Stop

func (s *Subscription) Stop(uninstall bool) error

type SubscriptionID

type SubscriptionID string

func NewSubscriptionID

func NewSubscriptionID(namespace, filterID string) SubscriptionID

type Subscriptions

type Subscriptions struct {
	// contains filtered or unexported fields
}

func NewSubscriptions

func NewSubscriptions(period time.Duration) *Subscriptions

func (*Subscriptions) Create

func (s *Subscriptions) Create(namespace string, filter filter) (SubscriptionID, error)

func (*Subscriptions) Remove

func (s *Subscriptions) Remove(id SubscriptionID) error

Jump to

Keyboard shortcuts

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