Documentation ¶
Overview ¶
Package eth implements the Ethereum protocol.
Index ¶
- Constants
- Variables
- func CreateConsensusEngine(name string, chainConfig *params.ChainConfig, db ethdb.Database) consensus.Engine
- type Config
- type Ethereum
- func (s *Ethereum) BlockChain() *core.BlockChain
- func (s *Ethereum) ChainDb() ethdb.Database
- func (s *Ethereum) Engine() consensus.Engine
- func (s *Ethereum) EthVersion() string
- func (s *Ethereum) Etherbase() (eb common.Address, err error)
- func (s *Ethereum) EventFeed() *EventFeed
- func (s *Ethereum) GetProtocolManager() IProtocolManager
- func (s *Ethereum) IsListening() bool
- func (s *Ethereum) IsMining() bool
- func (s *Ethereum) Miner() *miner.Miner
- func (s *Ethereum) Protocols() []IProtocol
- func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block)
- func (s *Ethereum) SetEtherbase(etherbase common.Address)
- func (s *Ethereum) SetOnline(online bool)
- func (s *Ethereum) Start()
- func (s *Ethereum) StartMining() error
- func (s *Ethereum) Stop()
- func (s *Ethereum) TxPool() *core.TxPool
- type NodeInfo
- type PeerInfo
- type ProtocolManager
- func (pm *ProtocolManager) AddTxs(txs types.Transactions) []error
- func (pm *ProtocolManager) BroadcastBlock(block *types.Block, propagate bool)
- func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions)
- func (pm *ProtocolManager) FindPeer(node INode) IPeer
- func (pm *ProtocolManager) GetSubProtocols() []IProtocol
- func (pm *ProtocolManager) HandleBlockHeadersMsg(p *peer, msg *Message)
- func (pm *ProtocolManager) HandleGetBlockHeadersMsg(p *peer, msg *Message)
- func (pm *ProtocolManager) HandleNewBlockHashesMsg(p *peer, m *Message)
- func (pm *ProtocolManager) HandleNewBlockMsg(p *peer, m *Message)
- func (pm *ProtocolManager) HandleTxMsg(p *peer, m *Message)
- func (pm *ProtocolManager) NodeInfo() *NodeInfo
- func (pm *ProtocolManager) PeerCount() int
- func (pm *ProtocolManager) PendingTxCount() int
- func (pm *ProtocolManager) RetrieveHandshakePeer(node INode) IPeer
- func (pm *ProtocolManager) Start()
- func (pm *ProtocolManager) Stop()
- func (pm *ProtocolManager) String() string
Constants ¶
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
const ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
Variables ¶
var ( ErrMsgTooLarge = errors.New("Message too long") ErrDecode = errors.New("Invalid message") ErrInvalidMsgCode = errors.New("Invalid message code") ErrProtocolVersionMismatch = errors.New("Protocol version mismatch") ErrNetworkIdMismatch = errors.New("NetworkId mismatch") ErrGenesisBlockMismatch = errors.New("Genesis block mismatch") ErrNoStatusMsg = errors.New("No status message") ErrExtraStatusMsg = errors.New("Extra status message") ErrSuspendedPeer = errors.New("Suspended peer") )
var ( EthPeers = metrics.EthPeers MinedBlock = metrics.MinedBlock TxsPerBlock = metrics.TxsPerBlock )
var DefaultConfig = Config{ DatabaseCache: 512, TrieCleanCache: 256, TrieDirtyCache: 256, TrieTimeout: 60 * time.Minute, Miner: miner.Config{ GasFloor: 8000000, GasCeil: 8000000, GasPrice: big.NewInt(params.Wei), Recommit: 3 * time.Second, }, TxPool: core.DefaultTxPoolConfig, }
DefaultConfig contains default settings for use on the Ethereum main net.
var ProtocolLengths = []uint64{17, 8}
ProtocolLengths are the number of implemented message corresponding to different protocol versions.
var ProtocolName = "eth"
ProtocolName is the official short name of the protocol used during capability negotiation.
var ProtocolVersions = []uint{eth63, eth62}
ProtocolVersions are the supported versions of the eth protocol (first is primary).
Functions ¶
func CreateConsensusEngine ¶
func CreateConsensusEngine(name string, chainConfig *params.ChainConfig, db ethdb.Database) consensus.Engine
CreateConsensusEngine creates the required type of consensus engine instance for an Ethereum service
Types ¶
type Config ¶
type Config struct { // The genesis block, which is inserted if the database is empty. // If nil, the Ethereum main net block is used. Genesis *core.Genesis `toml:",omitempty"` NoPruning bool // Whether to disable pruning and flush everything to disk NoPrefetch bool // Whether to disable prefetching and only load state on demand // Database options SkipBcVersionCheck bool `toml:"-"` DatabaseHandles int `toml:"-"` DatabaseCache int TrieCleanCache int TrieDirtyCache int TrieTimeout time.Duration // Mining options Miner miner.Config // Transaction pool options TxPool core.TxPoolConfig }
type Ethereum ¶
Ethereum implements the Ethereum full node service.
func New ¶
New creates a new Ethereum object (including the initialisation of the common Ethereum object)
func (*Ethereum) BlockChain ¶
func (s *Ethereum) BlockChain() *core.BlockChain
func (*Ethereum) EthVersion ¶
func (*Ethereum) GetProtocolManager ¶
func (s *Ethereum) GetProtocolManager() IProtocolManager
func (*Ethereum) IsListening ¶
func (*Ethereum) Protocols ¶
func (s *Ethereum) Protocols() []IProtocol
Protocols implements node.Service, returning all the currently configured network protocols to start.
func (*Ethereum) ResetWithGenesisBlock ¶
func (*Ethereum) SetEtherbase ¶
SetEtherbase sets the mining reward address.
func (*Ethereum) Start ¶
func (s *Ethereum) Start()
Start implements node.Service, starting all internal goroutines needed by the Ethereum protocol implementation.
func (*Ethereum) StartMining ¶
StartMining starts the miner with the given number of CPU threads. If mining is already running, this method adjust the number of threads allowed to use and updates the minimum price required by the transaction pool.
type NodeInfo ¶
type NodeInfo struct { Network int // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4) Difficulty *big.Int // Total difficulty of the host's blockchain Genesis common.Hash // SHA3 hash of the host's genesis block Config *params.ChainConfig // Chain configuration for the fork rules Head common.Hash // SHA3 hash of the host's best owned block }
NodeInfo represents a short summary of the Ethereum sub-protocol metadata known about the host peer.
type PeerInfo ¶
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 ProtocolManager ¶
type ProtocolManager struct { IMetricCollector SubProtocols []IProtocol // contains filtered or unexported fields }
func NewProtocolManager ¶
func NewProtocolManager(srv IServer, metricCollector IMetricCollector, eventFeed *EventFeed, blockchain *core.BlockChain, pool txPool) *ProtocolManager
NewProtocolManager returns a new Ethereum sub protocol manager. The Ethereum sub protocol manages peers capable with the Ethereum network.
func (*ProtocolManager) AddTxs ¶
func (pm *ProtocolManager) AddTxs(txs types.Transactions) []error
func (*ProtocolManager) BroadcastBlock ¶
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) BroadcastTxs ¶
func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions)
BroadcastTxs will propagate a batch of transactions to all peers which are not known to already have the given transaction.
func (*ProtocolManager) FindPeer ¶
func (pm *ProtocolManager) FindPeer(node INode) IPeer
func (*ProtocolManager) GetSubProtocols ¶
func (pm *ProtocolManager) GetSubProtocols() []IProtocol
func (*ProtocolManager) HandleBlockHeadersMsg ¶
func (pm *ProtocolManager) HandleBlockHeadersMsg(p *peer, msg *Message)
func (*ProtocolManager) HandleGetBlockHeadersMsg ¶
func (pm *ProtocolManager) HandleGetBlockHeadersMsg(p *peer, msg *Message)
func (*ProtocolManager) HandleNewBlockHashesMsg ¶
func (pm *ProtocolManager) HandleNewBlockHashesMsg(p *peer, m *Message)
func (*ProtocolManager) HandleNewBlockMsg ¶
func (pm *ProtocolManager) HandleNewBlockMsg(p *peer, m *Message)
func (*ProtocolManager) HandleTxMsg ¶
func (pm *ProtocolManager) HandleTxMsg(p *peer, m *Message)
func (*ProtocolManager) NodeInfo ¶
func (pm *ProtocolManager) NodeInfo() *NodeInfo
NodeInfo retrieves some protocol metadata about the running host node.
func (*ProtocolManager) PeerCount ¶
func (pm *ProtocolManager) PeerCount() int
func (*ProtocolManager) PendingTxCount ¶
func (pm *ProtocolManager) PendingTxCount() int
func (*ProtocolManager) RetrieveHandshakePeer ¶
func (pm *ProtocolManager) RetrieveHandshakePeer(node INode) IPeer
func (*ProtocolManager) Start ¶
func (pm *ProtocolManager) Start()
func (*ProtocolManager) Stop ¶
func (pm *ProtocolManager) Stop()
func (*ProtocolManager) String ¶
func (pm *ProtocolManager) String() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package common contains various helper functions.
|
Package common contains various helper functions. |
Package consensus implements different Ethereum consensus engines.
|
Package consensus implements different Ethereum consensus engines. |
clique
Package clique implements the proof-of-authority consensus engine.
|
Package clique implements the proof-of-authority consensus engine. |
Package core implements the Ethereum consensus protocol.
|
Package core implements the Ethereum consensus protocol. |
rawdb
Package rawdb contains a collection of low level database accessors.
|
Package rawdb contains a collection of low level database accessors. |
state
Package state provides a caching layer atop the Ethereum state trie.
|
Package state provides a caching layer atop the Ethereum state trie. |
types
Package types contains data types related to Ethereum consensus.
|
Package types contains data types related to Ethereum consensus. |
Package ethdb defines the interfaces for an Ethereum data store.
|
Package ethdb defines the interfaces for an Ethereum data store. |
memorydb
Package memorydb implements the key-value database layer based on memory maps.
|
Package memorydb implements the key-value database layer based on memory maps. |
Package fetcher contains the block announcement based synchronisation.
|
Package fetcher contains the block announcement based synchronisation. |
Package miner implements Ethereum block creation and mining.
|
Package miner implements Ethereum block creation and mining. |
Package trie implements Merkle Patricia Tries.
|
Package trie implements Merkle Patricia Tries. |