Documentation
¶
Overview ¶
Package websocket implements a websocket connection to an Ethereum node.
Deprecated: This package has been superseded by the node.Client interface.
This package is frozen and no new functionality will be added.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBlockNotFound = errors.New("block not found") ErrTransactionNotFound = errors.New("transaction not found") )
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface {
// URL returns the backend URL we are connected to
URL() string
// BlockNumber returns the current block number at head
BlockNumber(ctx context.Context) (uint64, error)
// BlockByNumber can be used to get a block by its number
BlockByNumber(ctx context.Context, number uint64, full bool) (*eth.Block, error)
// BlockByHash can be used to get a block by its hash
BlockByHash(ctx context.Context, hash string, full bool) (*eth.Block, error)
// eth_getTransactionByHash can be used to get transaction by its hash
TransactionByHash(ctx context.Context, hash string) (*eth.Transaction, error)
// Request method can be used by downstream consumers of ChangeEvent to make generic JSONRPC requests
Request(ctx context.Context, r *jsonrpc.Request) (*jsonrpc.RawResponse, error)
// Subscibe method can be used to make subscription requests
Subscribe(ctx context.Context, r *jsonrpc.Request) (Subscription, error)
// NewHeads subscription
NewHeads(ctx context.Context) (Subscription, error)
// NewPendingTransactions subscriptions
NewPendingTransaction(ctx context.Context, full ...bool) (Subscription, error)
// TransactionReceipt for a particular transaction
TransactionReceipt(ctx context.Context, hash string) (*eth.TransactionReceipt, error)
// GetLogs
GetLogs(ctx context.Context, filter eth.LogFilter) ([]eth.Log, error)
}
Connection represents a websocket connection to a backend ethereum client node.
func NewConnection ¶
func NewConnection(ctx context.Context, url string) (Connection, error)
NewConnection creates a Connection to the passed in URL. Use the supplied Context to shutdown the connection by cancelling or otherwise aborting the context.
type Subscription ¶
type Subscription interface {
Response() *jsonrpc.RawResponse
ID() string
Ch() chan *jsonrpc.Notification
Unsubscribe(ctx context.Context) error
Done() <-chan struct{}
Err() error
}
type SubscriptionParams ¶
type SubscriptionParams struct {
Subscription string `json:"subscription"`
Result json.RawMessage `json:"result"`
}
Click to show internal directories.
Click to hide internal directories.