eth

package
v0.0.0-...-7de8d3f Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Overview

Package eth implements the Ethereum protocol.

Index

Constants

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 ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message

Variables

View Source
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")
)
View Source
var (
	EthPeers    = metrics.EthPeers
	MinedBlock  = metrics.MinedBlock
	TxsPerBlock = metrics.TxsPerBlock
)
View Source
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.

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

ProtocolLengths are the number of implemented message corresponding to different protocol versions.

View Source
var ProtocolName = "eth"

ProtocolName is the official short name of the protocol used during capability negotiation.

View Source
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

type Ethereum struct {
	*devp2p.Server
	// contains filtered or unexported fields
}

Ethereum implements the Ethereum full node service.

func New

func New(node INode, metricCollector IMetricCollector) (*Ethereum, error)

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) ChainDb

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

func (*Ethereum) Engine

func (s *Ethereum) Engine() consensus.Engine

func (*Ethereum) EthVersion

func (s *Ethereum) EthVersion() string

func (*Ethereum) Etherbase

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

func (*Ethereum) EventFeed

func (s *Ethereum) EventFeed() *EventFeed

func (*Ethereum) GetProtocolManager

func (s *Ethereum) GetProtocolManager() IProtocolManager

func (*Ethereum) IsListening

func (s *Ethereum) IsListening() bool

func (*Ethereum) IsMining

func (s *Ethereum) IsMining() bool

func (*Ethereum) Miner

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

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 (s *Ethereum) ResetWithGenesisBlock(gb *types.Block)

func (*Ethereum) SetEtherbase

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

SetEtherbase sets the mining reward address.

func (*Ethereum) SetOnline

func (s *Ethereum) SetOnline(online bool)

func (*Ethereum) Start

func (s *Ethereum) Start()

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

func (*Ethereum) StartMining

func (s *Ethereum) StartMining() error

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.

func (*Ethereum) Stop

func (s *Ethereum) Stop()

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

func (*Ethereum) TxPool

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

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

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.
vm
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.

Jump to

Keyboard shortcuts

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