eth

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 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

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

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

func ReadPeers

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

func WritePeers

func WritePeers(path string, addresses []string)

Types

type BlockPool

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

func NewBlockPool

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

func (*BlockPool) AddBlock

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

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

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

func (self *BlockPool) Purge()

func (*BlockPool) RemovePeer

func (self *BlockPool) RemovePeer(peerId string)

RemovePeer is called by the eth protocol when the peer disconnects

func (*BlockPool) Start

func (self *BlockPool) Start()

allows restart

func (*BlockPool) Stop

func (self *BlockPool) Stop()

func (*BlockPool) Wait

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

func (s *Ethereum) BlockPool() *BlockPool

func (*Ethereum) BlockProcessor

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

func (*Ethereum) ChainManager

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

func (*Ethereum) Coinbase

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

func (*Ethereum) Db

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

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

func (*Ethereum) Logger

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

func (*Ethereum) MaxPeers

func (s *Ethereum) MaxPeers() int

func (*Ethereum) Miner

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

func (*Ethereum) Name

func (s *Ethereum) Name() string

func (*Ethereum) PeerCount

func (s *Ethereum) PeerCount() int

func (*Ethereum) Peers

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

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

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

func (*Ethereum) Whisper

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

Jump to

Keyboard shortcuts

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