Documentation ¶
Index ¶
- Constants
- func EthProtocol(txPool txPool, chainManager chainManager, blockPool blockPool) p2p.Protocol
- func ProtocolError(code int, format string, params ...interface{}) (err *protocolError)
- func ReadPeers(path string) (ips []string, err error)
- func WritePeers(path string, addresses []string)
- type BlockPool
- func (self *BlockPool) AddBlock(block *types.Block, peerId string)
- func (self *BlockPool) AddBlockHashes(next func() ([]byte, bool), peerId string)
- func (self *BlockPool) AddPeer(td *big.Int, currentBlockHash []byte, peerId string, ...) (best bool)
- func (self *BlockPool) Purge()
- func (self *BlockPool) RemovePeer(peerId string)
- func (self *BlockPool) Start()
- func (self *BlockPool) Stop()
- func (self *BlockPool) Wait(t time.Duration)
- type Config
- type Ethereum
- func (s *Ethereum) BlockPool() *BlockPool
- func (s *Ethereum) BlockProcessor() *core.BlockProcessor
- func (s *Ethereum) ChainManager() *core.ChainManager
- func (s *Ethereum) Coinbase() []byte
- func (s *Ethereum) Db() ethutil.Database
- func (s *Ethereum) EventMux() *event.TypeMux
- func (s *Ethereum) IsListening() bool
- func (s *Ethereum) KeyManager() *crypto.KeyManager
- func (s *Ethereum) Logger() ethlogger.LogSystem
- func (s *Ethereum) MaxPeers() int
- func (s *Ethereum) Miner() *miner.Miner
- func (s *Ethereum) Name() string
- func (s *Ethereum) PeerCount() int
- func (s *Ethereum) Peers() []*p2p.Peer
- func (s *Ethereum) Start() error
- func (s *Ethereum) Stop()
- func (self *Ethereum) SuggestPeer(nodeURL string) error
- func (s *Ethereum) TxPool() *core.TxPool
- func (s *Ethereum) WaitForShutdown()
- func (s *Ethereum) Whisper() *whisper.Whisper
Constants ¶
const ( ErrMsgTooLarge = iota ErrDecode ErrInvalidMsgCode ErrProtocolVersionMismatch ErrNetworkIdMismatch ErrGenesisBlockMismatch ErrNoStatusMsg ErrExtraStatusMsg ErrInvalidBlock ErrInvalidPoW ErrUnrequestedBlock ErrInsufficientChainInfo )
const ( ProtocolVersion = 54 NetworkId = 0 ProtocolLength = uint64(8) ProtocolMaxMsgSize = 10 * 1024 * 1024 )
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
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 WritePeers ¶ added in v0.8.4
Types ¶
type BlockPool ¶ added in v0.8.4
type BlockPool struct {
// contains filtered or unexported fields
}
func NewBlockPool ¶ added in v0.8.4
func (*BlockPool) AddBlock ¶ added in v0.8.4
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
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) RemovePeer ¶ added in v0.8.4
RemovePeer is called by the eth protocol when the peer disconnects
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 (*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) IsListening ¶
func (*Ethereum) KeyManager ¶ added in v0.8.4
func (s *Ethereum) KeyManager() *crypto.KeyManager
func (*Ethereum) SuggestPeer ¶ added in v0.8.4
func (*Ethereum) WaitForShutdown ¶ added in v0.8.4
func (s *Ethereum) WaitForShutdown()
This function will wait for a shutdown and resumes main thread execution