Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeTxn(arg *txnArgs, store nonceGetter) (*types.Transaction, error)
- func GetBlockHeader(number BlockNumber, store headerGetter) (*types.Header, error)
- func GetHeaderFromBlockNumberOrHash(bnh BlockNumberOrHash, store blockGetter) (*types.Header, error)
- func GetNextNonce(address types.Address, number BlockNumber, store nonceGetter) (uint64, error)
- func GetNumericBlockNumber(number BlockNumber, store latestHeaderGetter) (uint64, error)
- func GetTxAndBlockByTxHash(txHash types.Hash, store txLookupAndBlockGetter) (*types.Transaction, *types.Block)
- func NewInternalError(msg string) *internalError
- func NewInvalidParamsError(msg string) *invalidParamsError
- func NewInvalidRequestError(msg string) *invalidRequestError
- func NewMethodNotFoundError(method string) *methodNotFoundError
- func NewSubscriptionNotFoundError(method string) *subscriptionNotFoundError
- type Account
- type BlockNumber
- type BlockNumberOrHash
- type Bridge
- type Config
- type ContentResponse
- type Debug
- func (d *Debug) TraceBlock(input string, config *TraceConfig) (interface{}, error)
- func (d *Debug) TraceBlockByHash(blockHash types.Hash, config *TraceConfig) (interface{}, error)
- func (d *Debug) TraceBlockByNumber(blockNumber BlockNumber, config *TraceConfig) (interface{}, error)
- func (d *Debug) TraceCall(arg *txnArgs, filter BlockNumberOrHash, config *TraceConfig) (interface{}, error)
- func (d *Debug) TraceTransaction(txHash types.Hash, config *TraceConfig) (interface{}, error)
- type Dispatcher
- type Error
- type ErrorResponse
- type Eth
- func (e *Eth) BlockNumber() (interface{}, error)
- func (e *Eth) Call(arg *txnArgs, filter BlockNumberOrHash) (interface{}, error)
- func (e *Eth) ChainId() (interface{}, error)
- func (e *Eth) EstimateGas(arg *txnArgs, rawNum *BlockNumber) (interface{}, error)
- func (e *Eth) GasPrice() (interface{}, error)
- func (e *Eth) GetBalance(address types.Address, filter BlockNumberOrHash) (interface{}, error)
- func (e *Eth) GetBlockByHash(hash types.Hash, fullTx bool) (interface{}, error)
- func (e *Eth) GetBlockByNumber(number BlockNumber, fullTx bool) (interface{}, error)
- func (e *Eth) GetBlockTransactionCountByNumber(number BlockNumber) (interface{}, error)
- func (e *Eth) GetCode(address types.Address, filter BlockNumberOrHash) (interface{}, error)
- func (e *Eth) GetFilterChanges(id string) (interface{}, error)
- func (e *Eth) GetFilterLogs(id string) (interface{}, error)
- func (e *Eth) GetLogs(query *LogQuery) (interface{}, error)
- func (e *Eth) GetStorageAt(address types.Address, index types.Hash, filter BlockNumberOrHash) (interface{}, error)
- func (e *Eth) GetTransactionByHash(hash types.Hash) (interface{}, error)
- func (e *Eth) GetTransactionCount(address types.Address, filter BlockNumberOrHash) (interface{}, error)
- func (e *Eth) GetTransactionReceipt(hash types.Hash) (interface{}, error)
- func (e *Eth) NewBlockFilter() (interface{}, error)
- func (e *Eth) NewFilter(filter *LogQuery) (interface{}, error)
- func (e *Eth) SendRawTransaction(buf argBytes) (interface{}, error)
- func (e *Eth) SendTransaction(_ *txnArgs) (interface{}, error)
- func (e *Eth) Syncing() (interface{}, error)
- func (e *Eth) UninstallFilter(id string) (bool, error)
- func (e *Eth) Unsubscribe(id string) (bool, error)
- type FilterManager
- func (f *FilterManager) Close()
- func (f *FilterManager) Exists(id string) bool
- func (f *FilterManager) GetFilterChanges(id string) (interface{}, error)
- func (f *FilterManager) GetLogFilterFromID(filterID string) (*logFilter, error)
- func (f *FilterManager) GetLogsForQuery(query *LogQuery) ([]*Log, error)
- func (f *FilterManager) NewBlockFilter(ws wsConn) string
- func (f *FilterManager) NewLogFilter(logQuery *LogQuery, ws wsConn) string
- func (f *FilterManager) RemoveFilterByWs(ws wsConn)
- func (f *FilterManager) Run()
- func (f *FilterManager) Uninstall(id string) bool
- type GetResponse
- type InspectResponse
- type JSONRPC
- type JSONRPCStore
- type Log
- type LogQuery
- type Net
- type ObjectError
- type Request
- type Response
- type StatusResponse
- type SuccessResponse
- type TraceConfig
- type TxPool
- type Web3
Constants ¶
const ( PendingBlockNumber = BlockNumber(-3) LatestBlockNumber = BlockNumber(-2) EarliestBlockNumber = BlockNumber(-1) )
const (
// The index in heap which is indicating the element is not in the heap
NoIndexInHeap = -1
)
Variables ¶
var ( // ErrExecutionTimeout indicates the execution was terminated due to timeout ErrExecutionTimeout = errors.New("execution timeout") // ErrTraceGenesisBlock is an error returned when tracing genesis block which can't be traced ErrTraceGenesisBlock = errors.New("genesis is not traceable") )
var ( ErrFilterNotFound = errors.New("filter not found") ErrWSFilterDoesNotSupportGetChanges = errors.New("web socket Filter doesn't support to return a batch of the changes") ErrCastingFilterToLogFilter = errors.New("casting filter object to logFilter error") ErrBlockNotFound = errors.New("block not found") ErrIncorrectBlockRange = errors.New("incorrect range") ErrBlockRangeTooHigh = errors.New("block range too high") ErrNoWSConnection = errors.New("no websocket connection") )
var ( ErrHeaderNotFound = errors.New("header not found") ErrLatestNotFound = errors.New("latest header not found") ErrNegativeBlockNumber = errors.New("invalid argument 0: block number must not be negative") ErrFailedFetchGenesis = errors.New("error fetching genesis block header") ErrNoDataInContractCreation = errors.New("contract creation without data provided") )
var (
ErrInsufficientFunds = errors.New("insufficient funds for execution")
)
var (
ErrStateNotFound = errors.New("given root and slot not found in storage")
)
Functions ¶
func DecodeTxn ¶ added in v0.6.2
func DecodeTxn(arg *txnArgs, store nonceGetter) (*types.Transaction, error)
func GetBlockHeader ¶ added in v0.6.2
func GetBlockHeader(number BlockNumber, store headerGetter) (*types.Header, error)
GetBlockHeader returns a header using the provided number
func GetHeaderFromBlockNumberOrHash ¶ added in v0.6.2
func GetHeaderFromBlockNumberOrHash(bnh BlockNumberOrHash, store blockGetter) (*types.Header, error)
func GetNextNonce ¶ added in v0.6.2
func GetNextNonce(address types.Address, number BlockNumber, store nonceGetter) (uint64, error)
func GetNumericBlockNumber ¶
func GetNumericBlockNumber(number BlockNumber, store latestHeaderGetter) (uint64, error)
GetNumericBlockNumber returns block number based on current state or specified number
func GetTxAndBlockByTxHash ¶ added in v0.6.2
func GetTxAndBlockByTxHash(txHash types.Hash, store txLookupAndBlockGetter) (*types.Transaction, *types.Block)
GetTxAndBlockByTxHash returns the tx and the block including the tx by given tx hash
func NewInternalError ¶
func NewInternalError(msg string) *internalError
func NewInvalidParamsError ¶
func NewInvalidParamsError(msg string) *invalidParamsError
func NewInvalidRequestError ¶
func NewInvalidRequestError(msg string) *invalidRequestError
func NewMethodNotFoundError ¶
func NewMethodNotFoundError(method string) *methodNotFoundError
func NewSubscriptionNotFoundError ¶
func NewSubscriptionNotFoundError(method string) *subscriptionNotFoundError
Types ¶
type BlockNumber ¶
type BlockNumber int64
func (*BlockNumber) UnmarshalJSON ¶
func (b *BlockNumber) UnmarshalJSON(buffer []byte) error
UnmarshalJSON automatically decodes the user input for the block number, when a JSON RPC method is called
type BlockNumberOrHash ¶
type BlockNumberOrHash struct { BlockNumber *BlockNumber `json:"blockNumber,omitempty"` BlockHash *types.Hash `json:"blockHash,omitempty"` }
func (*BlockNumberOrHash) UnmarshalJSON ¶
func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error
UnmarshalJSON will try to extract the filter's data. Here are the possible input formats :
1 - "latest", "pending" or "earliest" - self-explaining keywords 2 - "0x2" - block number #2 (EIP-1898 backward compatible) 3 - {blockNumber: "0x2"} - EIP-1898 compliant block number #2 4 - {blockHash: "0xe0e..."} - EIP-1898 compliant block hash 0xe0e...
type Bridge ¶ added in v0.8.0
type Bridge struct {
// contains filtered or unexported fields
}
Bridge is the bridge jsonrpc endpoint
func (*Bridge) GenerateExitProof ¶ added in v0.8.0
GenerateExitProof generates exit proof for given exit event
func (*Bridge) GetStateSyncProof ¶ added in v0.8.0
GetStateSyncProof retrieves the StateSync proof
type ContentResponse ¶
type Debug ¶ added in v0.6.2
type Debug struct {
// contains filtered or unexported fields
}
Debug is the debug jsonrpc endpoint
func (*Debug) TraceBlock ¶ added in v0.6.2
func (d *Debug) TraceBlock( input string, config *TraceConfig, ) (interface{}, error)
func (*Debug) TraceBlockByHash ¶ added in v0.6.2
func (d *Debug) TraceBlockByHash( blockHash types.Hash, config *TraceConfig, ) (interface{}, error)
func (*Debug) TraceBlockByNumber ¶ added in v0.6.2
func (d *Debug) TraceBlockByNumber( blockNumber BlockNumber, config *TraceConfig, ) (interface{}, error)
func (*Debug) TraceCall ¶ added in v0.6.2
func (d *Debug) TraceCall( arg *txnArgs, filter BlockNumberOrHash, config *TraceConfig, ) (interface{}, error)
func (*Debug) TraceTransaction ¶ added in v0.6.2
func (d *Debug) TraceTransaction( txHash types.Hash, config *TraceConfig, ) (interface{}, error)
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher handles all json rpc requests by delegating the execution flow to the corresponding service
func (*Dispatcher) HandleWs ¶
func (d *Dispatcher) HandleWs(reqBody []byte, conn wsConn) ([]byte, error)
func (*Dispatcher) RemoveFilterByWs ¶ added in v0.5.0
func (d *Dispatcher) RemoveFilterByWs(conn wsConn)
type ErrorResponse ¶
type ErrorResponse struct { JSONRPC string `json:"jsonrpc"` ID interface{} `json:"id,omitempty"` Error *ObjectError `json:"error"` }
ErrorResponse is a jsonrpc error response
func (*ErrorResponse) Bytes ¶
func (e *ErrorResponse) Bytes() ([]byte, error)
Bytes return the serialized response
func (*ErrorResponse) Data ¶
func (e *ErrorResponse) Data() json.RawMessage
Data returns ObjectError
func (*ErrorResponse) GetID ¶
func (e *ErrorResponse) GetID() interface{}
GetID returns error response id
type Eth ¶
type Eth struct {
// contains filtered or unexported fields
}
Eth is the eth jsonrpc endpoint
func (*Eth) BlockNumber ¶
BlockNumber returns current block number
func (*Eth) Call ¶
func (e *Eth) Call(arg *txnArgs, filter BlockNumberOrHash) (interface{}, error)
Call executes a smart contract call using the transaction object data
func (*Eth) EstimateGas ¶
func (e *Eth) EstimateGas(arg *txnArgs, rawNum *BlockNumber) (interface{}, error)
EstimateGas estimates the gas needed to execute a transaction
func (*Eth) GasPrice ¶
GasPrice returns the average gas price based on the last x blocks taking into consideration operator defined price limit
func (*Eth) GetBalance ¶
func (e *Eth) GetBalance(address types.Address, filter BlockNumberOrHash) (interface{}, error)
GetBalance returns the account's balance at the referenced block.
func (*Eth) GetBlockByHash ¶
GetBlockByHash returns information about a block by hash
func (*Eth) GetBlockByNumber ¶
func (e *Eth) GetBlockByNumber(number BlockNumber, fullTx bool) (interface{}, error)
GetBlockByNumber returns information about a block by block number
func (*Eth) GetBlockTransactionCountByNumber ¶
func (e *Eth) GetBlockTransactionCountByNumber(number BlockNumber) (interface{}, error)
func (*Eth) GetCode ¶
func (e *Eth) GetCode(address types.Address, filter BlockNumberOrHash) (interface{}, error)
GetCode returns account code at given block number
func (*Eth) GetFilterChanges ¶
GetFilterChanges is a polling method for a filter, which returns an array of logs which occurred since last poll.
func (*Eth) GetFilterLogs ¶ added in v0.4.1
GetFilterLogs returns an array of logs for the specified filter
func (*Eth) GetStorageAt ¶
func (e *Eth) GetStorageAt( address types.Address, index types.Hash, filter BlockNumberOrHash, ) (interface{}, error)
GetStorageAt returns the contract storage at the index position
func (*Eth) GetTransactionByHash ¶
GetTransactionByHash returns a transaction by its hash. If the transaction is still pending -> return the txn with some fields omitted If the transaction is sealed into a block -> return the whole txn with all fields
func (*Eth) GetTransactionCount ¶
func (e *Eth) GetTransactionCount(address types.Address, filter BlockNumberOrHash) (interface{}, error)
GetTransactionCount returns account nonce
func (*Eth) GetTransactionReceipt ¶
GetTransactionReceipt returns a transaction receipt by his hash
func (*Eth) NewBlockFilter ¶
NewBlockFilter creates a filter in the node, to notify when a new block arrives
func (*Eth) NewFilter ¶
NewFilter creates a filter object, based on filter options, to notify when the state changes (logs).
func (*Eth) SendRawTransaction ¶
SendRawTransaction sends a raw transaction
func (*Eth) SendTransaction ¶
SendTransaction rejects eth_sendTransaction json-rpc call as we don't support wallet management
func (*Eth) UninstallFilter ¶
UninstallFilter uninstalls a filter with given ID
type FilterManager ¶
FilterManager manages all running filters
func NewFilterManager ¶
func NewFilterManager(logger hclog.Logger, store filterManagerStore, blockRangeLimit uint64) *FilterManager
func (*FilterManager) Close ¶
func (f *FilterManager) Close()
Close closed closeCh so that terminate worker
func (*FilterManager) Exists ¶
func (f *FilterManager) Exists(id string) bool
Exists checks the filter with given ID exists
func (*FilterManager) GetFilterChanges ¶
func (f *FilterManager) GetFilterChanges(id string) (interface{}, error)
GetFilterChanges returns the updates of the filter with given ID in string, and refreshes the timeout on the filter
func (*FilterManager) GetLogFilterFromID ¶ added in v0.4.1
func (f *FilterManager) GetLogFilterFromID(filterID string) (*logFilter, error)
GetLogFilterFromID return log filter for given filterID
func (*FilterManager) GetLogsForQuery ¶ added in v0.4.1
func (f *FilterManager) GetLogsForQuery(query *LogQuery) ([]*Log, error)
GetLogsForQuery return array of logs for given query
func (*FilterManager) NewBlockFilter ¶
func (f *FilterManager) NewBlockFilter(ws wsConn) string
NewBlockFilter adds new BlockFilter
func (*FilterManager) NewLogFilter ¶
func (f *FilterManager) NewLogFilter(logQuery *LogQuery, ws wsConn) string
NewLogFilter adds new LogFilter
func (*FilterManager) RemoveFilterByWs ¶ added in v0.5.0
func (f *FilterManager) RemoveFilterByWs(ws wsConn)
RemoveFilterByWs removes the filter with given WS [Thread safe]
func (*FilterManager) Run ¶
func (f *FilterManager) Run()
Run starts worker process to handle events
func (*FilterManager) Uninstall ¶
func (f *FilterManager) Uninstall(id string) bool
Uninstall removes the filter with given ID from list
type GetResponse ¶ added in v0.6.1
type InspectResponse ¶
type JSONRPC ¶
type JSONRPC struct {
// contains filtered or unexported fields
}
JSONRPC is an API consensus
func NewJSONRPC ¶
NewJSONRPC returns the JSONRPC http server
type JSONRPCStore ¶
type JSONRPCStore interface {
// contains filtered or unexported methods
}
JSONRPCStore defines all the methods required by all the JSON RPC endpoints
type Log ¶
type Log struct { Address types.Address `json:"address"` Topics []types.Hash `json:"topics"` Data argBytes `json:"data"` BlockNumber argUint64 `json:"blockNumber"` TxHash types.Hash `json:"transactionHash"` TxIndex argUint64 `json:"transactionIndex"` BlockHash types.Hash `json:"blockHash"` LogIndex argUint64 `json:"logIndex"` Removed bool `json:"removed"` }
type LogQuery ¶ added in v0.3.3
type LogQuery struct { BlockHash *types.Hash Addresses []types.Address Topics [][]types.Hash // contains filtered or unexported fields }
LogQuery is a query to filter logs
func (*LogQuery) Match ¶ added in v0.3.3
Match returns whether the receipt includes topics for this filter
func (*LogQuery) UnmarshalJSON ¶ added in v0.3.3
UnmarshalJSON decodes a json object
type Net ¶
type Net struct {
// contains filtered or unexported fields
}
Net is the net jsonrpc endpoint
func (*Net) Listening ¶
Listening returns true if client is actively listening for network connections
type ObjectError ¶
type ObjectError struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` }
ObjectError is a jsonrpc error
type Request ¶
type Request struct { ID interface{} `json:"id"` Method string `json:"method"` Params json.RawMessage `json:"params,omitempty"` }
Request is a jsonrpc request
type Response ¶
type Response interface { GetID() interface{} Data() json.RawMessage Bytes() ([]byte, error) }
Response is a jsonrpc response interface
func NewRPCErrorResponse ¶
NewRPCErrorResponse is used to create a custom error response
type StatusResponse ¶
type SuccessResponse ¶
type SuccessResponse struct { JSONRPC string `json:"jsonrpc"` ID interface{} `json:"id"` Result json.RawMessage `json:"result"` Error *ObjectError `json:"error,omitempty"` }
SuccessResponse is a jsonrpc success response
func (*SuccessResponse) Bytes ¶
func (s *SuccessResponse) Bytes() ([]byte, error)
Bytes return the serialized response
func (*SuccessResponse) Data ¶
func (s *SuccessResponse) Data() json.RawMessage
Data returns the result
func (*SuccessResponse) GetID ¶
func (s *SuccessResponse) GetID() interface{}
GetID returns success response id
type TraceConfig ¶ added in v0.6.2
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
TxPool is the txpool jsonrpc endpoint
func (*TxPool) Content ¶
Create response for txpool_content request. See https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_content.
func (*TxPool) Inspect ¶
Create response for txpool_inspect request. See https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_inspect.
func (*TxPool) Status ¶
Create response for txpool_status request. See https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_status.
type Web3 ¶
type Web3 struct {
// contains filtered or unexported fields
}
Web3 is the web3 jsonrpc endpoint
func (*Web3) ClientVersion ¶
ClientVersion returns the version of the web3 client (web3_clientVersion)