In addition to hooks that get invoked by Geth, several objects are injected that give you access to additional information.
+
Backend Object
+
The core.Backend
object is injected by the InitializeNode()
and GetAPI()
functions. It offers the following functions:
+
+
Downloader
+
Downloader() Downloader
+
Returns a Downloader objects, which can provide Syncing status
+
+
+
SuggestGasTipCap
+
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
+
Suggests a Gas tip for the current block.
+
+
+
ExtRPCEnabled
+
ExtRPCEnabled() bool
+
Returns whether RPC external RPC calls are enabled.
+
+
+
RPCGasCap
+
RPCGasCap() uint64
+
Returns the maximum Gas available to RPC Calls.
+
+
+
RPCTxFeeCap
+
RPCTxFeeCap() float64
+
Returns the maximum transaction fee for a transaction submitted via RPC.
+
+
+
UnprotectedAllowed
+
UnprotectedAllowed() bool
+
Returns whether or not unprotected transactions can be transmitted through this
+node via RPC.
+
+
+
SetHead
+
SetHead(number uint64)
+
Resets the head to the specified block number.
+
+
+
+
+
+
CurrentBlock
+
CurrentBlock() []byte
+
Returns an RLP encoded full block for the current block.
+
The RLP encoded response can be decoded into a plugeth-utils/restricted/types.Block object.
+
+
+
BlockByNumber
+
BlockByNumber(ctx context.Context, number int64) ([]byte, error)
+
Returns an RLP encoded full block for the specified block number.
+
The RLP encoded response can be decoded into a plugeth-utils/restricted/types.Block object.
+
+
+
BlockByHash
+
BlockByHash(ctx context.Context, hash Hash) ([]byte, error)
+
Returns an RLP encoded full block for the specified block hash.
+
The RLP encoded response can be decoded into a plugeth-utils/restricted/types.Block object.
+
+
+
GetReceipts
+
GetReceipts(ctx context.Context, hash Hash) ([]byte, error)
+
Returns an JSON encoded list of receipts for the specified block hash.
+
The JSON encoded response can be decoded into a plugeth-utils/restricted/types.Receipts object.
+
+
+
GetTd
+
GetTd(ctx context.Context, hash Hash) *big.Int
+
Returns the total difficulty for the specified block hash.
+
+
+
SubscribeChainEvent
+
SubscribeChainEvent(ch chan<- ChainEvent) Subscription
+
Subscribes the provided channel to new chain events.
+
+
+
SubscribeChainHeadEvent
+
SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) Subscription
+
Subscribes the provided channel to new chain head events.
+
+
+
SubscribeChainSideEvent
+
SubscribeChainSideEvent(ch chan<- ChainSideEvent) Subscription
+
Subscribes the provided channel to new chain side events.
+
+
+
SendTx
+
SendTx(ctx context.Context, signedTx []byte) error
+
Sends an RLP encoded, signed transaction to the network.
+
+
+
GetTransaction
+
GetTransaction(ctx context.Context, txHash Hash) ([]byte, Hash, uint64, uint64, error)
+
Returns an RLP encoded transaction at the specified hash, along with the hash and number of the included block, and the transaction’s position within that block.
+
+
GetPoolTransactions
+
GetPoolTransactions() ([][]byte, error)
+
Returns a list of RLP encoded transactions found in the mempool
+
+
+
+
GetPoolTransaction
+
GetPoolTransaction(txHash Hash) []byte
+
Returns the RLP encoded transaction from the mempool at the specified hash.
+
+
+
GetPoolNonce
+
GetPoolNonce(ctx context.Context, addr Address) (uint64, error)
+
Returns the nonce of the last transaction for a given address, including
+transactions found in the mempool.
+
+
+
Stats
+
Stats() (pending int, queued int)
+
Returns the number of pending and queued transactions in the mempool.
+
+
+
TxPoolContent
+
TxPoolContent() (map[Address][][]byte, map[Address][][]byte)
+
Returns a map of addresses to the list of RLP encoded transactions pending in
+the mempool, and queued in the mempool.
+
+
+
SubscribeNewTxsEvent
+
SubscribeNewTxsEvent(chan<- NewTxsEvent) Subscription
+
Subscribe to a feed of new transactions added to the mempool.
+
+
+
GetLogs
+
GetLogs(ctx context.Context, blockHash Hash) ([][]byte, error)
+
Returns a list of RLP encoded logs found in the specified block.
+
+
+
SubscribeLogsEvent
+
SubscribeLogsEvent(ch chan<- [][]byte) Subscription
+
Subscribe to logs included in a confirmed block.
+
+
+
SubscribePendingLogsEvent
+
SubscribePendingLogsEvent(ch chan<- [][]byte) Subscription
+
Subscribe to logs from pending transactions.
+
+
+
SubscribeRemovedLogsEvent
+
SubscribeRemovedLogsEvent(ch chan<- []byte) Subscription
+
Subscribe to logs removed from the canonical chain in reorged blocks.
+
+
+
Node Object
+
The core.Node
object is injected by the InitializeNode()
and GetAPI()
functions. It offers the following functions:
+
+
Server
+
Server() Server
+
The Server object provides access to server.PeerCount()
, the number of peers connected to the node.
+
+
+
DataDir
+
DataDir() string
+
Returns the Ethereuem datadir.
+
+
+
InstanceDir
+
InstanceDir() string
+
Returns the instancedir used by the protocol stack.
+
+
+
IPCEndpoint
+
IPCEndpoint() string
+
The path of the IPC Endpoint for this node.
+
+
+
HTTPEndpoint
+
HTTPEndpoint() string
+
The url of the HTTP Endpoint for this node.
+
+
+
WSEndpoint
+
WSEndpoint() string
+
The url of the websockets Endpoint for this node.
+
+
+
ResolvePath
+
ResolvePath(x string) string
+
Resolves a path within the DataDir.
+
+