eth

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2015 License: LGPL-2.1-or-later Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrInvalidBlock
	ErrInvalidPoW
	ErrUnrequestedBlock
	ErrInsufficientChainInfo
)
View Source
const (
	ProtocolVersion    = 54
	NetworkId          = 0
	ProtocolLength     = uint64(8)
	ProtocolMaxMsgSize = 10 * 1024 * 1024
)
View Source
const (
	StatusMsg = iota
	GetTxMsg  // unused
	TxMsg
	GetBlockHashesMsg
	BlockHashesMsg
	GetBlocksMsg
	BlocksMsg
	NewBlockMsg
)

eth protocol message codes

Variables

This section is empty.

Functions

func EthProtocol added in v0.8.4

func EthProtocol(txPool txPool, chainManager chainManager, blockPool blockPool) p2p.Protocol

main entrypoint, wrappers starting a server running the eth protocol use this constructor to attach the protocol ("class") to server caps the Dev p2p layer then runs the protocol instance on each peer

func ProtocolError added in v0.8.4

func ProtocolError(code int, format string, params ...interface{}) (err *protocolError)

func ReadPeers added in v0.8.4

func ReadPeers(path string) (ips []string, err error)

func WritePeers added in v0.8.4

func WritePeers(path string, addresses []string)

Types

type BlockPool added in v0.8.4

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

func NewBlockPool added in v0.8.4

func NewBlockPool(hasBlock func(hash []byte) bool, insertChain func(types.Blocks) error, verifyPoW func(pow.Block) bool,
) *BlockPool

func (*BlockPool) AddBlock added in v0.8.4

func (self *BlockPool) AddBlock(block *types.Block, peerId string)

AddBlock is the entry point for the eth protocol when blockmsg is received upon requests It has a strict interpretation of the protocol in that if the block received has not been requested, it results in an error (which can be ignored) block is checked for PoW only the first PoW-valid block for a hash is considered legit

func (*BlockPool) AddBlockHashes added in v0.8.4

func (self *BlockPool) AddBlockHashes(next func() ([]byte, bool), peerId string)

Entry point for eth protocol to add block hashes received via BlockHashesMsg only hashes from the best peer is handled this method is always responsible to initiate further hash requests until a known parent is reached unless cancelled by a peerChange event this process also launches all request processes on each chain section this function needs to run asynchronously for one peer since the message is discarded???

func (*BlockPool) AddPeer added in v0.8.4

func (self *BlockPool) AddPeer(td *big.Int, currentBlockHash []byte, peerId string, requestBlockHashes func([]byte) error, requestBlocks func([][]byte) error, peerError func(int, string, ...interface{})) (best bool)

AddPeer is called by the eth protocol instance running on the peer after the status message has been received with total difficulty and current block hash AddPeer can only be used once, RemovePeer needs to be called when the peer disconnects

func (*BlockPool) Purge added in v0.8.4

func (self *BlockPool) Purge()

func (*BlockPool) RemovePeer added in v0.8.4

func (self *BlockPool) RemovePeer(peerId string)

RemovePeer is called by the eth protocol when the peer disconnects

func (*BlockPool) Start added in v0.8.4

func (self *BlockPool) Start()

allows restart

func (*BlockPool) Stop added in v0.8.4

func (self *BlockPool) Stop()

func (*BlockPool) Wait added in v0.8.4

func (self *BlockPool) Wait(t time.Duration)

type Config

type Config struct {
	Name      string
	KeyStore  string
	DataDir   string
	LogFile   string
	LogLevel  int
	KeyRing   string
	LogFormat string

	MaxPeers int
	Port     string

	// This should be a space-separated list of
	// discovery node URLs.
	BootNodes string

	// This key is used to identify the node on the network.
	// If nil, an ephemeral key is used.
	NodeKey *ecdsa.PrivateKey

	NAT  nat.Interface
	Shh  bool
	Dial bool

	MinerThreads int

	KeyManager *crypto.KeyManager
}

type Ethereum

type Ethereum struct {
	RpcServer rpc.RpcServer
	WsServer  rpc.RpcServer

	Mining bool
	// contains filtered or unexported fields
}

func New

func New(config *Config) (*Ethereum, error)

func (*Ethereum) BlockPool added in v0.8.4

func (s *Ethereum) BlockPool() *BlockPool

func (*Ethereum) BlockProcessor added in v0.8.4

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

func (*Ethereum) ChainManager added in v0.8.4

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

func (*Ethereum) Coinbase added in v0.8.4

func (s *Ethereum) Coinbase() []byte

func (*Ethereum) Db added in v0.8.4

func (s *Ethereum) Db() ethutil.Database

func (*Ethereum) EventMux

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

func (*Ethereum) IsListening

func (s *Ethereum) IsListening() bool

func (*Ethereum) KeyManager added in v0.8.4

func (s *Ethereum) KeyManager() *crypto.KeyManager

func (*Ethereum) Logger added in v0.8.4

func (s *Ethereum) Logger() ethlogger.LogSystem

func (*Ethereum) MaxPeers added in v0.8.4

func (s *Ethereum) MaxPeers() int

func (*Ethereum) Miner

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

func (*Ethereum) Name added in v0.8.4

func (s *Ethereum) Name() string

func (*Ethereum) PeerCount added in v0.8.4

func (s *Ethereum) PeerCount() int

func (*Ethereum) Peers added in v0.8.4

func (s *Ethereum) Peers() []*p2p.Peer

func (*Ethereum) Start

func (s *Ethereum) Start() error

Start the ethereum

func (*Ethereum) Stop

func (s *Ethereum) Stop()

func (*Ethereum) SuggestPeer added in v0.8.4

func (self *Ethereum) SuggestPeer(nodeURL string) error

func (*Ethereum) TxPool

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

func (*Ethereum) WaitForShutdown added in v0.8.4

func (s *Ethereum) WaitForShutdown()

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

func (*Ethereum) Whisper added in v0.8.4

func (s *Ethereum) Whisper() *whisper.Whisper

Jump to

Keyboard shortcuts

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