eth

package
v1.4.17 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2016 License: GPL-3.0 Imports: 48 Imported by: 1,707

Documentation

Overview

Package eth implements the Ethereum protocol.

Index

Constants

View Source
const (
	NetworkId          = 1
	ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
)
View Source
const (
	// Protocol messages belonging to eth/62
	StatusMsg          = 0x00
	NewBlockHashesMsg  = 0x01
	TxMsg              = 0x02
	GetBlockHeadersMsg = 0x03
	BlockHeadersMsg    = 0x04
	GetBlockBodiesMsg  = 0x05
	BlockBodiesMsg     = 0x06
	NewBlockMsg        = 0x07

	// Protocol messages belonging to eth/63
	GetNodeDataMsg = 0x0d
	NodeDataMsg    = 0x0e
	GetReceiptsMsg = 0x0f
	ReceiptsMsg    = 0x10
)

eth protocol message codes

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
)

Variables

View Source
var EnableBadBlockReporting = false
View Source
var ProtocolLengths = []uint64{17, 8}

Number of implemented message corresponding to different protocol versions.

View Source
var ProtocolName = "eth"

Official short name of the protocol used during capability negotiation.

View Source
var ProtocolVersions = []uint{eth63, eth62}

Supported versions of the eth protocol (first is primary).

Functions

func GPUBench added in v1.3.1

func GPUBench(gpuid uint64)

func PrintOpenCLDevices added in v1.3.1

func PrintOpenCLDevices()

Types

type BlockTraceResult added in v1.4.0

type BlockTraceResult struct {
	Validated  bool           `json:"validated"`
	StructLogs []structLogRes `json:"structLogs"`
	Error      string         `json:"error"`
}

BlockTraceResult is the returned value when replaying a block to check for consensus results and full VM trace logs for all included transactions.

type CallArgs added in v1.4.0

type CallArgs struct {
	From     common.Address  `json:"from"`
	To       *common.Address `json:"to"`
	Gas      *rpc.HexNumber  `json:"gas"`
	GasPrice *rpc.HexNumber  `json:"gasPrice"`
	Value    rpc.HexNumber   `json:"value"`
	Data     string          `json:"data"`
}

CallArgs represents the arguments for a call.

type Config

type Config struct {
	ChainConfig *core.ChainConfig // chain configuration

	NetworkId int    // Network ID to use for selecting peers to connect to
	Genesis   string // Genesis JSON to seed the chain database with
	FastSync  bool   // Enables the state download based fast synchronisation algorithm

	BlockChainVersion  int
	SkipBcVersionCheck bool // e.g. blockchain export
	DatabaseCache      int
	DatabaseHandles    int

	NatSpec   bool
	DocRoot   string
	AutoDAG   bool
	PowTest   bool
	PowShared bool
	ExtraData []byte

	AccountManager *accounts.Manager
	Etherbase      common.Address
	GasPrice       *big.Int
	MinerThreads   int
	SolcPath       string

	GpoMinGasPrice          *big.Int
	GpoMaxGasPrice          *big.Int
	GpoFullBlockRatio       int
	GpobaseStepDown         int
	GpobaseStepUp           int
	GpobaseCorrectionFactor int

	EnableJit bool
	ForceJit  bool

	TestGenesisBlock *types.Block   // Genesis block to seed the chain database with (testing only!)
	TestGenesisState ethdb.Database // Genesis state to seed the database with (testing only!)
}

type ContractBackend added in v1.4.1

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

ContractBackend implements bind.ContractBackend with direct calls to Ethereum internals to support operating on contracts within subprotocols like eth and swarm.

Internally this backend uses the already exposed API endpoints of the Ethereum object. These should be rewritten to internal Go method calls when the Go API is refactored to support a clean library use.

func NewContractBackend added in v1.4.1

func NewContractBackend(eth *Ethereum) *ContractBackend

NewContractBackend creates a new native contract backend using an existing Etheruem object.

func (*ContractBackend) ContractCall added in v1.4.1

func (b *ContractBackend) ContractCall(contract common.Address, data []byte, pending bool) ([]byte, error)

ContractCall implements bind.ContractCaller executing an Ethereum contract call with the specified data as the input. The pending flag requests execution against the pending block, not the stable head of the chain.

func (*ContractBackend) EstimateGasLimit added in v1.4.1

func (b *ContractBackend) EstimateGasLimit(sender common.Address, contract *common.Address, value *big.Int, data []byte) (*big.Int, error)

EstimateGasLimit implements bind.ContractTransactor triing to estimate the gas needed to execute a specific transaction based on the current pending state of the backend blockchain. There is no guarantee that this is the true gas limit requirement as other transactions may be added or removed by miners, but it should provide a basis for setting a reasonable default.

func (*ContractBackend) HasCode added in v1.4.5

func (b *ContractBackend) HasCode(contract common.Address, pending bool) (bool, error)

HasCode implements bind.ContractVerifier.HasCode by retrieving any code associated with the contract from the local API, and checking its size.

func (*ContractBackend) PendingAccountNonce added in v1.4.1

func (b *ContractBackend) PendingAccountNonce(account common.Address) (uint64, error)

PendingAccountNonce implements bind.ContractTransactor retrieving the current pending nonce associated with an account.

func (*ContractBackend) SendTransaction added in v1.4.1

func (b *ContractBackend) SendTransaction(tx *types.Transaction) error

SendTransaction implements bind.ContractTransactor injects the transaction into the pending pool for execution.

func (*ContractBackend) SuggestGasPrice added in v1.4.1

func (b *ContractBackend) SuggestGasPrice() (*big.Int, error)

SuggestGasPrice implements bind.ContractTransactor retrieving the currently suggested gas price to allow a timely execution of a transaction.

type EthNodeInfo added in v1.3.2

type EthNodeInfo struct {
	Network    int         `json:"network"`    // Ethereum network ID (0=Olympic, 1=Frontier, 2=Morden)
	Difficulty *big.Int    `json:"difficulty"` // Total difficulty of the host's blockchain
	Genesis    common.Hash `json:"genesis"`    // SHA3 hash of the host's genesis block
	Head       common.Hash `json:"head"`       // SHA3 hash of the host's best owned block
}

EthNodeInfo represents a short summary of the Ethereum sub-protocol metadata known about the host peer.

type Ethereum

type Ethereum struct {
	SolcPath string

	GpoMinGasPrice          *big.Int
	GpoMaxGasPrice          *big.Int
	GpoFullBlockRatio       int
	GpobaseStepDown         int
	GpobaseStepUp           int
	GpobaseCorrectionFactor int

	Mining       bool
	MinerThreads int
	NatSpec      bool
	AutoDAG      bool
	PowTest      bool
	// contains filtered or unexported fields
}

func New

func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error)

func (*Ethereum) APIs added in v1.4.0

func (s *Ethereum) APIs() []rpc.API

APIs returns the collection of RPC services the ethereum package offers. NOTE, some of these services probably need to be moved to somewhere else.

func (*Ethereum) AccountManager added in v0.9.17

func (s *Ethereum) AccountManager() *accounts.Manager

func (*Ethereum) BlockChain added in v1.3.1

func (s *Ethereum) BlockChain() *core.BlockChain

func (*Ethereum) ChainDb added in v1.1.0

func (s *Ethereum) ChainDb() ethdb.Database

func (*Ethereum) DappDb added in v1.1.0

func (s *Ethereum) DappDb() ethdb.Database

func (*Ethereum) Downloader added in v0.9.17

func (s *Ethereum) Downloader() *downloader.Downloader

func (*Ethereum) EthVersion added in v0.9.17

func (s *Ethereum) EthVersion() int

func (*Ethereum) Etherbase added in v0.9.17

func (s *Ethereum) Etherbase() (eb common.Address, err error)

func (*Ethereum) EventMux

func (s *Ethereum) EventMux() *event.TypeMux

func (*Ethereum) HTTPClient added in v1.3.1

func (self *Ethereum) HTTPClient() *httpclient.HTTPClient

HTTPClient returns the light http client used for fetching offchain docs (natspec, source for verification)

func (*Ethereum) IsListening

func (s *Ethereum) IsListening() bool

func (*Ethereum) IsMining added in v0.9.17

func (s *Ethereum) IsMining() bool

func (*Ethereum) Miner

func (s *Ethereum) Miner() *miner.Miner

func (*Ethereum) NetVersion added in v0.9.17

func (s *Ethereum) NetVersion() int

func (*Ethereum) Protocols added in v1.4.0

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

Protocols implements node.Service, returning all the currently configured network protocols to start.

func (*Ethereum) ResetWithGenesisBlock added in v0.9.17

func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block)

func (*Ethereum) SetEtherbase added in v0.9.36

func (self *Ethereum) SetEtherbase(etherbase common.Address)

set in js console via admin interface or wrapper from cli flags

func (*Ethereum) SetSolc added in v0.9.23

func (self *Ethereum) SetSolc(solcPath string) (*compiler.Solidity, error)

set in js console via admin interface or wrapper from cli flags

func (*Ethereum) Solc added in v0.9.23

func (self *Ethereum) Solc() (*compiler.Solidity, error)

func (*Ethereum) Start

func (s *Ethereum) Start(srvr *p2p.Server) error

Start implements node.Service, starting all internal goroutines needed by the Ethereum protocol implementation.

func (*Ethereum) StartAutoDAG added in v0.9.23

func (self *Ethereum) StartAutoDAG()

StartAutoDAG() spawns a go routine that checks the DAG every autoDAGcheckInterval by default that is 10 times per epoch in epoch n, if we past autoDAGepochHeight within-epoch blocks, it calls ethash.MakeDAG to pregenerate the DAG for the next epoch n+1 if it does not exist yet as well as remove the DAG for epoch n-1 the loop quits if autodagquit channel is closed, it can safely restart and stop any number of times. For any more sophisticated pattern of DAG generation, use CLI subcommand makedag

func (*Ethereum) StartMining added in v0.9.17

func (s *Ethereum) StartMining(threads int, gpus string) error

func (*Ethereum) Stop

func (s *Ethereum) Stop() error

Stop implements node.Service, terminating all internal goroutines used by the Ethereum protocol.

func (*Ethereum) StopAutoDAG added in v0.9.23

func (self *Ethereum) StopAutoDAG()

stopAutoDAG stops automatic DAG pregeneration by quitting the loop

func (*Ethereum) StopMining added in v0.9.17

func (s *Ethereum) StopMining()

func (*Ethereum) TxPool

func (s *Ethereum) TxPool() *core.TxPool

func (*Ethereum) WaitForShutdown

func (s *Ethereum) WaitForShutdown()

This function will wait for a shutdown and resumes main thread execution

type ExecutionResult added in v1.4.0

type ExecutionResult struct {
	Gas         *big.Int       `json:"gas"`
	ReturnValue string         `json:"returnValue"`
	StructLogs  []structLogRes `json:"structLogs"`
}

ExecutionResult groups all structured logs emitted by the EVM while replaying a transaction in debug mode as well as the amount of gas used and the return value

type GasPriceOracle added in v0.9.30

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

GasPriceOracle recommends gas prices based on the content of recent blocks.

func NewGasPriceOracle added in v0.9.30

func NewGasPriceOracle(eth *Ethereum) *GasPriceOracle

NewGasPriceOracle returns a new oracle.

func (*GasPriceOracle) SuggestPrice added in v0.9.30

func (self *GasPriceOracle) SuggestPrice() *big.Int

SuggestPrice returns the recommended gas price.

type NewBlocksArgs added in v1.4.0

type NewBlocksArgs struct {
	IncludeTransactions bool `json:"includeTransactions"`
	TransactionDetails  bool `json:"transactionDetails"`
}

NewBlocksArgs allows the user to specify if the returned block should include transactions and in which format.

type PeerInfo added in v0.9.17

type PeerInfo struct {
	Version    int      `json:"version"`    // Ethereum protocol version negotiated
	Difficulty *big.Int `json:"difficulty"` // Total difficulty of the peer's blockchain
	Head       string   `json:"head"`       // SHA3 hash of the peer's best owned block
}

PeerInfo represents a short summary of the Ethereum sub-protocol metadata known about a connected peer.

type PrivateAccountAPI added in v1.4.0

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

PrivateAccountAPI provides an API to access accounts managed by this node. It offers methods to create, (un)lock en list accounts. Some methods accept passwords and are therefore considered private by default.

func NewPrivateAccountAPI added in v1.4.0

func NewPrivateAccountAPI(e *Ethereum) *PrivateAccountAPI

NewPrivateAccountAPI create a new PrivateAccountAPI.

func (*PrivateAccountAPI) ImportRawKey added in v1.4.1

func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (common.Address, error)

ImportRawKey stores the given hex encoded ECDSA key into the key directory, encrypting it with the passphrase.

func (*PrivateAccountAPI) ListAccounts added in v1.4.0

func (s *PrivateAccountAPI) ListAccounts() []common.Address

ListAccounts will return a list of addresses for accounts this node manages.

func (*PrivateAccountAPI) LockAccount added in v1.4.0

func (s *PrivateAccountAPI) LockAccount(addr common.Address) bool

LockAccount will lock the account associated with the given address when it's unlocked.

func (*PrivateAccountAPI) NewAccount added in v1.4.0

func (s *PrivateAccountAPI) NewAccount(password string) (common.Address, error)

NewAccount will create a new account and returns the address for the new account.

func (*PrivateAccountAPI) SignAndSendTransaction added in v1.4.5

func (s *PrivateAccountAPI) SignAndSendTransaction(args SendTxArgs, passwd string) (common.Hash, error)

SignAndSendTransaction will create a transaction from the given arguments and tries to sign it with the key associated with args.To. If the given passwd isn't able to decrypt the key it fails.

func (*PrivateAccountAPI) UnlockAccount added in v1.4.0

func (s *PrivateAccountAPI) UnlockAccount(addr common.Address, password string, duration *rpc.HexNumber) (bool, error)

UnlockAccount will unlock the account associated with the given address with the given password for duration seconds. If duration is nil it will use a default of 300 seconds. It returns an indication if the account was unlocked.

type PrivateAdminAPI added in v1.4.0

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

PrivateAdminAPI is the collection of Etheruem APIs exposed over the private admin endpoint.

func NewPrivateAdminAPI added in v1.4.0

func NewPrivateAdminAPI(eth *Ethereum) *PrivateAdminAPI

NewPrivateAdminAPI creates a new API definition for the private admin methods of the Ethereum service.

func (*PrivateAdminAPI) ExportChain added in v1.4.0

func (api *PrivateAdminAPI) ExportChain(file string) (bool, error)

ExportChain exports the current blockchain into a local file.

func (*PrivateAdminAPI) ImportChain added in v1.4.0

func (api *PrivateAdminAPI) ImportChain(file string) (bool, error)

ImportChain imports a blockchain from a local file.

func (*PrivateAdminAPI) SetSolc added in v1.4.0

func (api *PrivateAdminAPI) SetSolc(path string) (string, error)

SetSolc sets the Solidity compiler path to be used by the node.

type PrivateDebugAPI added in v1.4.0

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

PrivateDebugAPI is the collection of Etheruem APIs exposed over the private debugging endpoint.

func NewPrivateDebugAPI added in v1.4.0

func NewPrivateDebugAPI(config *core.ChainConfig, eth *Ethereum) *PrivateDebugAPI

NewPrivateDebugAPI creates a new API definition for the private debug methods of the Ethereum service.

func (*PrivateDebugAPI) ChaindbProperty added in v1.4.0

func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error)

ChaindbProperty returns leveldb properties of the chain database.

func (*PrivateDebugAPI) SetHead added in v1.4.0

func (api *PrivateDebugAPI) SetHead(number uint64)

SetHead rewinds the head of the blockchain to a previous block.

func (*PrivateDebugAPI) TraceBlock added in v1.4.0

func (api *PrivateDebugAPI) TraceBlock(blockRlp []byte, config *vm.Config) BlockTraceResult

TraceBlock processes the given block's RLP but does not import the block in to the chain.

func (*PrivateDebugAPI) TraceBlockByHash added in v1.4.0

func (api *PrivateDebugAPI) TraceBlockByHash(hash common.Hash, config *vm.Config) BlockTraceResult

TraceBlockByHash processes the block by hash.

func (*PrivateDebugAPI) TraceBlockByNumber added in v1.4.0

func (api *PrivateDebugAPI) TraceBlockByNumber(number uint64, config *vm.Config) BlockTraceResult

TraceBlockByNumber processes the block by canonical block number.

func (*PrivateDebugAPI) TraceBlockFromFile added in v1.4.0

func (api *PrivateDebugAPI) TraceBlockFromFile(file string, config *vm.Config) BlockTraceResult

TraceBlockFromFile loads the block's RLP from the given file name and attempts to process it but does not import the block in to the chain.

func (*PrivateDebugAPI) TraceTransaction added in v1.4.0

func (api *PrivateDebugAPI) TraceTransaction(txHash common.Hash, logger *vm.LogConfig) (*ExecutionResult, error)

TraceTransaction returns the structured logs created during the execution of EVM and returns them as a JSON object.

type PrivateMinerAPI added in v1.4.0

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

PrivateMinerAPI provides private RPC methods to control the miner. These methods can be abused by external users and must be considered insecure for use by untrusted users.

func NewPrivateMinerAPI added in v1.4.0

func NewPrivateMinerAPI(e *Ethereum) *PrivateMinerAPI

NewPrivateMinerAPI create a new RPC service which controls the miner of this node.

func (*PrivateMinerAPI) MakeDAG added in v1.4.0

func (s *PrivateMinerAPI) MakeDAG(blockNr rpc.BlockNumber) (bool, error)

MakeDAG creates the new DAG for the given block number

func (*PrivateMinerAPI) SetEtherbase added in v1.4.0

func (s *PrivateMinerAPI) SetEtherbase(etherbase common.Address) bool

SetEtherbase sets the etherbase of the miner

func (*PrivateMinerAPI) SetExtra added in v1.4.0

func (s *PrivateMinerAPI) SetExtra(extra string) (bool, error)

SetExtra sets the extra data string that is included when this miner mines a block.

func (*PrivateMinerAPI) SetGasPrice added in v1.4.0

func (s *PrivateMinerAPI) SetGasPrice(gasPrice rpc.HexNumber) bool

SetGasPrice sets the minimum accepted gas price for the miner.

func (*PrivateMinerAPI) Start added in v1.4.0

func (s *PrivateMinerAPI) Start(threads *rpc.HexNumber) (bool, error)

Start the miner with the given number of threads. If threads is nil the number of workers started is equal to the number of logical CPU's that are usable by this process.

func (*PrivateMinerAPI) StartAutoDAG added in v1.4.0

func (s *PrivateMinerAPI) StartAutoDAG() bool

StartAutoDAG starts auto DAG generation. This will prevent the DAG generating on epoch change which will cause the node to stop mining during the generation process.

func (*PrivateMinerAPI) Stop added in v1.4.0

func (s *PrivateMinerAPI) Stop() bool

Stop the miner

func (*PrivateMinerAPI) StopAutoDAG added in v1.4.0

func (s *PrivateMinerAPI) StopAutoDAG() bool

StopAutoDAG stops auto DAG generation

type ProtocolManager added in v0.9.17

type ProtocolManager struct {
	SubProtocols []p2p.Protocol
	// contains filtered or unexported fields
}

func NewProtocolManager added in v0.9.17

func NewProtocolManager(config *core.ChainConfig, fastSync bool, networkId int, mux *event.TypeMux, txpool txPool, pow pow.PoW, blockchain *core.BlockChain, chaindb ethdb.Database) (*ProtocolManager, error)

NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable with the ethereum network.

func (*ProtocolManager) BroadcastBlock added in v0.9.17

func (pm *ProtocolManager) BroadcastBlock(block *types.Block, propagate bool)

BroadcastBlock will either propagate a block to a subset of it's peers, or will only announce it's availability (depending what's requested).

func (*ProtocolManager) BroadcastTx added in v0.9.17

func (pm *ProtocolManager) BroadcastTx(hash common.Hash, tx *types.Transaction)

BroadcastTx will propagate a transaction to all peers which are not known to already have the given transaction.

func (*ProtocolManager) NodeInfo added in v1.3.2

func (self *ProtocolManager) NodeInfo() *EthNodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) Start added in v0.9.17

func (pm *ProtocolManager) Start()

func (*ProtocolManager) Stop added in v0.9.17

func (pm *ProtocolManager) Stop()

type PublicAccountAPI added in v1.4.0

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

PublicAccountAPI provides an API to access accounts managed by this node. It offers only methods that can retrieve accounts.

func NewPublicAccountAPI added in v1.4.0

func NewPublicAccountAPI(am *accounts.Manager) *PublicAccountAPI

NewPublicAccountAPI creates a new PublicAccountAPI.

func (*PublicAccountAPI) Accounts added in v1.4.0

func (s *PublicAccountAPI) Accounts() []accounts.Account

Accounts returns the collection of accounts this node manages

type PublicBlockChainAPI added in v1.4.0

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

PublicBlockChainAPI provides an API to access the Ethereum blockchain. It offers only methods that operate on public data that is freely available to anyone.

func NewPublicBlockChainAPI added in v1.4.0

func NewPublicBlockChainAPI(config *core.ChainConfig, bc *core.BlockChain, m *miner.Miner, chainDb ethdb.Database, gpo *GasPriceOracle, eventMux *event.TypeMux, am *accounts.Manager) *PublicBlockChainAPI

NewPublicBlockChainAPI creates a new Etheruem blockchain API.

func (*PublicBlockChainAPI) BlockNumber added in v1.4.0

func (s *PublicBlockChainAPI) BlockNumber() *big.Int

BlockNumber returns the block number of the chain head.

func (*PublicBlockChainAPI) Call added in v1.4.0

func (s *PublicBlockChainAPI) Call(args CallArgs, blockNr rpc.BlockNumber) (string, error)

Call executes the given transaction on the state for the given block number. It doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.

func (*PublicBlockChainAPI) EstimateGas added in v1.4.0

func (s *PublicBlockChainAPI) EstimateGas(args CallArgs) (*rpc.HexNumber, error)

EstimateGas returns an estimate of the amount of gas needed to execute the given transaction.

func (*PublicBlockChainAPI) GetBalance added in v1.4.0

func (s *PublicBlockChainAPI) GetBalance(address common.Address, blockNr rpc.BlockNumber) (*big.Int, error)

GetBalance returns the amount of wei for the given address in the state of the given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*PublicBlockChainAPI) GetBlockByHash added in v1.4.0

func (s *PublicBlockChainAPI) GetBlockByHash(blockHash common.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetBlockByNumber added in v1.4.0

func (s *PublicBlockChainAPI) GetBlockByNumber(blockNr rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber returns the requested block. When blockNr is -1 the chain head is returned. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetCode added in v1.4.0

func (s *PublicBlockChainAPI) GetCode(address common.Address, blockNr rpc.BlockNumber) (string, error)

GetCode returns the code stored at the given address in the state for the given block number.

func (*PublicBlockChainAPI) GetStorageAt added in v1.4.0

func (s *PublicBlockChainAPI) GetStorageAt(address common.Address, key string, blockNr rpc.BlockNumber) (string, error)

GetStorageAt returns the storage from the state at the given address, key and block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*PublicBlockChainAPI) GetUncleByBlockHashAndIndex added in v1.4.0

func (s *PublicBlockChainAPI) GetUncleByBlockHashAndIndex(blockHash common.Hash, index rpc.HexNumber) (map[string]interface{}, error)

GetUncleByBlockHashAndIndex returns the uncle block for the given block hash and index. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetUncleByBlockNumberAndIndex added in v1.4.0

func (s *PublicBlockChainAPI) GetUncleByBlockNumberAndIndex(blockNr rpc.BlockNumber, index rpc.HexNumber) (map[string]interface{}, error)

GetUncleByBlockNumberAndIndex returns the uncle block for the given block hash and index. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetUncleCountByBlockHash added in v1.4.0

func (s *PublicBlockChainAPI) GetUncleCountByBlockHash(blockHash common.Hash) *rpc.HexNumber

GetUncleCountByBlockHash returns number of uncles in the block for the given block hash

func (*PublicBlockChainAPI) GetUncleCountByBlockNumber added in v1.4.0

func (s *PublicBlockChainAPI) GetUncleCountByBlockNumber(blockNr rpc.BlockNumber) *rpc.HexNumber

GetUncleCountByBlockNumber returns number of uncles in the block for the given block number

func (*PublicBlockChainAPI) NewBlocks added in v1.4.0

NewBlocks triggers a new block event each time a block is appended to the chain. It accepts an argument which allows the caller to specify whether the output should contain transactions and in what format.

func (*PublicBlockChainAPI) TraceCall added in v1.4.0

func (s *PublicBlockChainAPI) TraceCall(args CallArgs, blockNr rpc.BlockNumber) (*ExecutionResult, error)

TraceCall executes a call and returns the amount of gas, created logs and optionally returned values.

type PublicDebugAPI added in v1.4.0

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

PublicDebugAPI is the collection of Etheruem APIs exposed over the public debugging endpoint.

func NewPublicDebugAPI added in v1.4.0

func NewPublicDebugAPI(eth *Ethereum) *PublicDebugAPI

NewPublicDebugAPI creates a new API definition for the public debug methods of the Ethereum service.

func (*PublicDebugAPI) DumpBlock added in v1.4.0

func (api *PublicDebugAPI) DumpBlock(number uint64) (state.Dump, error)

DumpBlock retrieves the entire state of the database at a given block.

func (*PublicDebugAPI) GetBlockRlp added in v1.4.0

func (api *PublicDebugAPI) GetBlockRlp(number uint64) (string, error)

GetBlockRlp retrieves the RLP encoded for of a single block.

func (*PublicDebugAPI) PrintBlock added in v1.4.0

func (api *PublicDebugAPI) PrintBlock(number uint64) (string, error)

PrintBlock retrieves a block and returns its pretty printed form.

func (*PublicDebugAPI) SeedHash added in v1.4.0

func (api *PublicDebugAPI) SeedHash(number uint64) (string, error)

SeedHash retrieves the seed hash of a block.

type PublicEthereumAPI added in v1.4.0

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

PublicEthereumAPI provides an API to access Ethereum related information. It offers only methods that operate on public data that is freely available to anyone.

func NewPublicEthereumAPI added in v1.4.0

func NewPublicEthereumAPI(e *Ethereum) *PublicEthereumAPI

NewPublicEthereumAPI creates a new Ethereum protocol API.

func (*PublicEthereumAPI) Coinbase added in v1.4.0

func (s *PublicEthereumAPI) Coinbase() (common.Address, error)

Coinbase is the address that mining rewards will be send to (alias for Etherbase)

func (*PublicEthereumAPI) CompileSolidity added in v1.4.0

func (s *PublicEthereumAPI) CompileSolidity(source string) (map[string]*compiler.Contract, error)

CompileSolidity compiles the given solidity source

func (*PublicEthereumAPI) Etherbase added in v1.4.0

func (s *PublicEthereumAPI) Etherbase() (common.Address, error)

Etherbase is the address that mining rewards will be send to

func (*PublicEthereumAPI) GasPrice added in v1.4.0

func (s *PublicEthereumAPI) GasPrice() *big.Int

GasPrice returns a suggestion for a gas price.

func (*PublicEthereumAPI) GetCompilers added in v1.4.0

func (s *PublicEthereumAPI) GetCompilers() ([]string, error)

GetCompilers returns the collection of available smart contract compilers

func (*PublicEthereumAPI) Hashrate added in v1.4.0

func (s *PublicEthereumAPI) Hashrate() *rpc.HexNumber

Hashrate returns the POW hashrate

func (*PublicEthereumAPI) ProtocolVersion added in v1.4.0

func (s *PublicEthereumAPI) ProtocolVersion() *rpc.HexNumber

ProtocolVersion returns the current Ethereum protocol version this node supports

func (*PublicEthereumAPI) Syncing added in v1.4.0

func (s *PublicEthereumAPI) Syncing() (interface{}, error)

Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not yet received the latest block headers from its pears. In case it is synchronizing: - startingBlock: block number this node started to synchronise from - currentBlock: block number this node is currently importing - highestBlock: block number of the highest block header this node has received from peers - pulledStates: number of state entries processed until now - knownStates: number of known state entries that still need to be pulled

type PublicMinerAPI added in v1.4.0

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

PublicMinerAPI provides an API to control the miner. It offers only methods that operate on data that pose no security risk when it is publicly accessible.

func NewPublicMinerAPI added in v1.4.0

func NewPublicMinerAPI(e *Ethereum) *PublicMinerAPI

NewPublicMinerAPI create a new PublicMinerAPI instance.

func (*PublicMinerAPI) GetWork added in v1.4.0

func (s *PublicMinerAPI) GetWork() (work [3]string, err error)

GetWork returns a work package for external miner. The work package consists of 3 strings result[0], 32 bytes hex encoded current block header pow-hash result[1], 32 bytes hex encoded seed hash used for DAG result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty

func (*PublicMinerAPI) Mining added in v1.4.0

func (s *PublicMinerAPI) Mining() bool

Mining returns an indication if this node is currently mining.

func (*PublicMinerAPI) SubmitHashrate added in v1.4.0

func (s *PublicMinerAPI) SubmitHashrate(hashrate rpc.HexNumber, id common.Hash) bool

SubmitHashrate can be used for remote miners to submit their hash rate. This enables the node to report the combined hash rate of all miners which submit work through this node. It accepts the miner hash rate and an identifier which must be unique between nodes.

func (*PublicMinerAPI) SubmitWork added in v1.4.0

func (s *PublicMinerAPI) SubmitWork(nonce rpc.HexNumber, solution, digest common.Hash) bool

SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was accepted. Note, this is not an indication if the provided work was valid!

type PublicNetAPI added in v1.4.0

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

PublicNetAPI offers network related RPC methods

func NewPublicNetAPI added in v1.4.0

func NewPublicNetAPI(net *p2p.Server, networkVersion int) *PublicNetAPI

NewPublicNetAPI creates a new net API instance.

func (*PublicNetAPI) Listening added in v1.4.0

func (s *PublicNetAPI) Listening() bool

Listening returns an indication if the node is listening for network connections.

func (*PublicNetAPI) PeerCount added in v1.4.0

func (s *PublicNetAPI) PeerCount() *rpc.HexNumber

PeerCount returns the number of connected peers

func (*PublicNetAPI) Version added in v1.4.0

func (s *PublicNetAPI) Version() string

Version returns the current ethereum protocol version.

type PublicTransactionPoolAPI added in v1.4.0

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

PublicTransactionPoolAPI exposes methods for the RPC interface

func NewPublicTransactionPoolAPI added in v1.4.0

func NewPublicTransactionPoolAPI(e *Ethereum) *PublicTransactionPoolAPI

NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.

func (*PublicTransactionPoolAPI) GetBlockTransactionCountByHash added in v1.4.0

func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByHash(blockHash common.Hash) *rpc.HexNumber

GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.

func (*PublicTransactionPoolAPI) GetBlockTransactionCountByNumber added in v1.4.0

func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(blockNr rpc.BlockNumber) *rpc.HexNumber

GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.

func (*PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex added in v1.4.0

func (s *PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex(blockHash common.Hash, index rpc.HexNumber) (*RPCTransaction, error)

GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.

func (*PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex added in v1.4.0

func (s *PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex(blockNr rpc.BlockNumber, index rpc.HexNumber) (*RPCTransaction, error)

GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.

func (*PublicTransactionPoolAPI) GetTransactionByHash added in v1.4.0

func (s *PublicTransactionPoolAPI) GetTransactionByHash(txHash common.Hash) (*RPCTransaction, error)

GetTransactionByHash returns the transaction for the given hash

func (*PublicTransactionPoolAPI) GetTransactionCount added in v1.4.0

func (s *PublicTransactionPoolAPI) GetTransactionCount(address common.Address, blockNr rpc.BlockNumber) (*rpc.HexNumber, error)

GetTransactionCount returns the number of transactions the given address has sent for the given block number

func (*PublicTransactionPoolAPI) GetTransactionReceipt added in v1.4.0

func (s *PublicTransactionPoolAPI) GetTransactionReceipt(txHash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt returns the transaction receipt for the given transaction hash.

func (*PublicTransactionPoolAPI) NewPendingTransactions added in v1.4.0

func (s *PublicTransactionPoolAPI) NewPendingTransactions(ctx context.Context) (rpc.Subscription, error)

NewPendingTransactions creates a subscription that is triggered each time a transaction enters the transaction pool and is send from one of the transactions this nodes manages.

func (*PublicTransactionPoolAPI) PendingTransactions added in v1.4.0

func (s *PublicTransactionPoolAPI) PendingTransactions() []*RPCTransaction

PendingTransactions returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.

func (*PublicTransactionPoolAPI) Resend added in v1.4.0

func (s *PublicTransactionPoolAPI) Resend(tx Tx, gasPrice, gasLimit *rpc.HexNumber) (common.Hash, error)

Resend accepts an existing transaction and a new gas price and limit. It will remove the given transaction from the pool and reinsert it with the new gas price and limit.

func (*PublicTransactionPoolAPI) SendRawTransaction added in v1.4.0

func (s *PublicTransactionPoolAPI) SendRawTransaction(encodedTx string) (string, error)

SendRawTransaction will add the signed transaction to the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.

func (*PublicTransactionPoolAPI) SendTransaction added in v1.4.0

func (s *PublicTransactionPoolAPI) SendTransaction(args SendTxArgs) (common.Hash, error)

SendTransaction creates a transaction for the given argument, sign it and submit it to the transaction pool.

func (*PublicTransactionPoolAPI) Sign added in v1.4.0

Sign signs the given hash using the key that matches the address. The key must be unlocked in order to sign the hash.

func (*PublicTransactionPoolAPI) SignTransaction added in v1.4.0

SignTransaction will sign the given transaction with the from account. The node needs to have the private key of the account corresponding with the given from address and it needs to be unlocked.

type PublicTxPoolAPI added in v1.4.0

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

PublicTxPoolAPI offers and API for the transaction pool. It only operates on data that is non confidential.

func NewPublicTxPoolAPI added in v1.4.0

func NewPublicTxPoolAPI(e *Ethereum) *PublicTxPoolAPI

NewPublicTxPoolAPI creates a new tx pool service that gives information about the transaction pool.

func (*PublicTxPoolAPI) Content added in v1.4.0

func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string][]*RPCTransaction

Content returns the transactions contained within the transaction pool.

func (*PublicTxPoolAPI) Inspect added in v1.4.0

func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string][]string

Inspect retrieves the content of the transaction pool and flattens it into an easily inspectable list.

func (*PublicTxPoolAPI) Status added in v1.4.0

func (s *PublicTxPoolAPI) Status() map[string]*rpc.HexNumber

Status returns the number of pending and queued transaction in the pool.

type RPCTransaction added in v1.4.0

type RPCTransaction struct {
	BlockHash        common.Hash     `json:"blockHash"`
	BlockNumber      *rpc.HexNumber  `json:"blockNumber"`
	From             common.Address  `json:"from"`
	Gas              *rpc.HexNumber  `json:"gas"`
	GasPrice         *rpc.HexNumber  `json:"gasPrice"`
	Hash             common.Hash     `json:"hash"`
	Input            string          `json:"input"`
	Nonce            *rpc.HexNumber  `json:"nonce"`
	To               *common.Address `json:"to"`
	TransactionIndex *rpc.HexNumber  `json:"transactionIndex"`
	Value            *rpc.HexNumber  `json:"value"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

type SendTxArgs added in v1.4.0

type SendTxArgs struct {
	From     common.Address  `json:"from"`
	To       *common.Address `json:"to"`
	Gas      *rpc.HexNumber  `json:"gas"`
	GasPrice *rpc.HexNumber  `json:"gasPrice"`
	Value    *rpc.HexNumber  `json:"value"`
	Data     string          `json:"data"`
	Nonce    *rpc.HexNumber  `json:"nonce"`
}

SendTxArgs represents the arguments to sumbit a new transaction into the transaction pool.

type SignTransactionArgs added in v1.4.0

type SignTransactionArgs struct {
	From     common.Address
	To       *common.Address
	Nonce    *rpc.HexNumber
	Value    *rpc.HexNumber
	Gas      *rpc.HexNumber
	GasPrice *rpc.HexNumber
	Data     string

	BlockNumber int64
}

SignTransactionArgs represents the arguments to sign a transaction.

type SignTransactionResult added in v1.4.0

type SignTransactionResult struct {
	Raw string `json:"raw"`
	Tx  *Tx    `json:"tx"`
}

SignTransactionResult represents a RLP encoded signed transaction.

type TraceCollector added in v1.4.0

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

TraceCollector collects EVM structered logs.

TraceCollector implements vm.Collector

func (*TraceCollector) AddStructLog added in v1.4.0

func (t *TraceCollector) AddStructLog(slog vm.StructLog)

AddStructLog adds a structered log.

type Tx added in v1.4.0

type Tx struct {
	To       *common.Address `json:"to"`
	From     common.Address  `json:"from"`
	Nonce    *rpc.HexNumber  `json:"nonce"`
	Value    *rpc.HexNumber  `json:"value"`
	Data     string          `json:"data"`
	GasLimit *rpc.HexNumber  `json:"gas"`
	GasPrice *rpc.HexNumber  `json:"gasPrice"`
	Hash     common.Hash     `json:"hash"`
	// contains filtered or unexported fields
}

Tx is a helper object for argument and return values

func (*Tx) UnmarshalJSON added in v1.4.0

func (tx *Tx) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON parses JSON data into tx.

Directories

Path Synopsis
Package downloader contains the manual full chain synchronisation.
Package downloader contains the manual full chain synchronisation.
Package fetcher contains the block announcement based synchronisation.
Package fetcher contains the block announcement based synchronisation.
package filters implements an ethereum filtering system for block, transactions and log events.
package filters implements an ethereum filtering system for block, transactions and log events.

Jump to

Keyboard shortcuts

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