eth

package module
v0.0.0-...-3887924 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: LGPL-2.1-or-later Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Current protocol version
	ProtocolVersion = 49
	// Current P2P version
	P2PVersion = 2
	// Ethereum network version
	NetVersion = 0
)

Variables

This section is empty.

Functions

func PastPeers

func PastPeers() []string

Types

type BlockPool

type BlockPool struct {
	ChainLength, BlocksProcessed int
	// contains filtered or unexported fields
}

func NewBlockPool

func NewBlockPool(eth *Ethereum) *BlockPool

func (*BlockPool) Add

func (self *BlockPool) Add(b *types.Block, peer *Peer)

func (*BlockPool) AddHash

func (self *BlockPool) AddHash(hash []byte, peer *Peer)

func (*BlockPool) AddNew

func (self *BlockPool) AddNew(b *types.Block, peer *Peer)

func (*BlockPool) Blocks

func (self *BlockPool) Blocks() (blocks types.Blocks)

func (*BlockPool) DistributeHashes

func (self *BlockPool) DistributeHashes()

func (*BlockPool) FetchHashes

func (self *BlockPool) FetchHashes(peer *Peer) bool

func (*BlockPool) HasCommonHash

func (self *BlockPool) HasCommonHash(hash []byte) bool

func (*BlockPool) HasLatestHash

func (self *BlockPool) HasLatestHash() bool

func (*BlockPool) Len

func (self *BlockPool) Len() int

func (*BlockPool) Remove

func (self *BlockPool) Remove(hash []byte)

func (*BlockPool) Reset

func (self *BlockPool) Reset()

func (*BlockPool) Start

func (self *BlockPool) Start()

func (*BlockPool) Stop

func (self *BlockPool) Stop()

type Caps

type Caps byte

Peer capabilities

const (
	CapPeerDiscTy Caps = 1 << iota
	CapTxTy
	CapChainTy

	CapDefault = CapChainTy | CapTxTy | CapPeerDiscTy
)

func (Caps) IsCap

func (c Caps) IsCap(cap Caps) bool

func (Caps) String

func (c Caps) String() string

type ChainSyncEvent

type ChainSyncEvent struct {
	InSync bool
}

type DiscReason

type DiscReason byte
const (
	// Values are given explicitly instead of by iota because these values are
	// defined by the wire protocol spec; it is easier for humans to ensure
	// correctness when values are explicit.
	DiscRequested DiscReason = iota
	DiscReTcpSysErr
	DiscBadProto
	DiscBadPeer
	DiscTooManyPeers
	DiscConnDup
	DiscGenesisErr
	DiscProtoErr
	DiscQuitting
)

func (DiscReason) String

func (d DiscReason) String() string

type Ethereum

type Ethereum struct {

	// Nonce
	Nonce uint64

	Addr net.Addr
	Port string

	// Specifies the desired amount of maximum peers
	MaxPeers int

	Mining bool

	RpcServer *rpc.JsonRpcServer
	// contains filtered or unexported fields
}

func New

func New(db ethutil.Database, clientIdentity wire.ClientIdentity, keyManager *crypto.KeyManager, caps Caps, usePnp bool) (*Ethereum, error)

func (*Ethereum) AddPeer

func (s *Ethereum) AddPeer(conn net.Conn)

func (*Ethereum) BlacklistPeer

func (self *Ethereum) BlacklistPeer(peer *Peer)

func (*Ethereum) BlockManager

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

func (*Ethereum) BlockPool

func (s *Ethereum) BlockPool() *BlockPool

func (*Ethereum) Broadcast

func (s *Ethereum) Broadcast(msgType wire.MsgType, data []interface{})

func (*Ethereum) BroadcastMsg

func (s *Ethereum) BroadcastMsg(msg *wire.Msg)

func (*Ethereum) ChainManager

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

func (*Ethereum) ClientIdentity

func (s *Ethereum) ClientIdentity() wire.ClientIdentity

func (*Ethereum) ConnectToPeer

func (s *Ethereum) ConnectToPeer(addr string) error

func (*Ethereum) Db

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

func (*Ethereum) EventMux

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

func (*Ethereum) GetFilter

func (self *Ethereum) GetFilter(id int) *core.Filter

GetFilter retrieves a filter installed using InstallFilter. The filter may not be modified.

func (*Ethereum) HighestTDPeer

func (s *Ethereum) HighestTDPeer() (td *big.Int)

func (*Ethereum) InOutPeers

func (s *Ethereum) InOutPeers() []*Peer

func (*Ethereum) InboundPeers

func (s *Ethereum) InboundPeers() []*Peer

func (*Ethereum) InstallFilter

func (self *Ethereum) InstallFilter(filter *core.Filter) (id int)

InstallFilter adds filter for blockchain events. The filter's callbacks will run for matching blocks and messages. The filter should not be modified after it has been installed.

func (*Ethereum) IsListening

func (s *Ethereum) IsListening() bool

func (*Ethereum) IsMining

func (s *Ethereum) IsMining() bool

func (*Ethereum) IsUpToDate

func (s *Ethereum) IsUpToDate() bool

func (*Ethereum) KeyManager

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

func (*Ethereum) OutboundPeers

func (s *Ethereum) OutboundPeers() []*Peer

func (*Ethereum) PeerCount

func (s *Ethereum) PeerCount() int

func (*Ethereum) Peers

func (s *Ethereum) Peers() *list.List

func (*Ethereum) ProcessPeerList

func (s *Ethereum) ProcessPeerList(addrs []string)

func (*Ethereum) PushPeer

func (s *Ethereum) PushPeer(peer *Peer)

func (*Ethereum) RemovePeer

func (s *Ethereum) RemovePeer(p *Peer)

func (*Ethereum) Seed

func (s *Ethereum) Seed()

func (*Ethereum) ServerCaps

func (s *Ethereum) ServerCaps() Caps

func (*Ethereum) Start

func (s *Ethereum) Start(seed bool)

Start the ethereum

func (*Ethereum) Stop

func (s *Ethereum) Stop()

func (*Ethereum) TxPool

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

func (*Ethereum) UninstallFilter

func (self *Ethereum) UninstallFilter(id int)

func (*Ethereum) WaitForShutdown

func (s *Ethereum) WaitForShutdown()

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

type NAT

type NAT interface {
	GetExternalAddress() (addr net.IP, err error)
	AddPortMapping(protocol string, externalPort, internalPort int, description string, timeout int) (mappedExternalPort int, err error)
	DeletePortMapping(protocol string, externalPort, internalPort int) (err error)
}

protocol is either "udp" or "tcp"

func Discover

func Discover() (nat NAT, err error)

func NewNatPMP

func NewNatPMP(gateway net.IP) (nat NAT)

type Peer

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

func NewOutboundPeer

func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer

func NewPeer

func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer

func (*Peer) Caps

func (self *Peer) Caps() *ethutil.Value

func (*Peer) Connect

func (self *Peer) Connect(addr string) (conn net.Conn, err error)

func (*Peer) Connected

func (p *Peer) Connected() *int32

func (*Peer) FetchBlocks

func (self *Peer) FetchBlocks(hashes [][]byte)

func (*Peer) FetchHashes

func (self *Peer) FetchHashes() bool

func (*Peer) FetchingHashes

func (self *Peer) FetchingHashes() bool

func (*Peer) HandleInbound

func (p *Peer) HandleInbound()

Inbound handler. Inbound messages are received here and passed to the appropriate methods

func (*Peer) HandleOutbound

func (p *Peer) HandleOutbound()

Outbound message handler. Outbound messages are handled here

func (*Peer) Host

func (p *Peer) Host() []byte

func (*Peer) Inbound

func (p *Peer) Inbound() bool

func (*Peer) IsCap

func (self *Peer) IsCap(cap string) bool

func (*Peer) LastPong

func (p *Peer) LastPong() int64

func (*Peer) LastSend

func (p *Peer) LastSend() time.Time

func (*Peer) PingTime

func (p *Peer) PingTime() string

Getters

func (*Peer) Port

func (p *Peer) Port() uint16

func (*Peer) QueueMessage

func (p *Peer) QueueMessage(msg *wire.Msg)

Outputs any RLP encoded data to the peer

func (*Peer) RlpData

func (p *Peer) RlpData() []interface{}

func (*Peer) SetVersion

func (p *Peer) SetVersion(version string)

Setters

func (*Peer) Start

func (p *Peer) Start()

func (*Peer) Stop

func (p *Peer) Stop()

func (*Peer) StopWithReason

func (p *Peer) StopWithReason(reason DiscReason)

func (*Peer) String

func (p *Peer) String() string

func (*Peer) Version

func (p *Peer) Version() string

type PeerListEvent

type PeerListEvent struct {
	Peers *list.List
}

Directories

Path Synopsis
cmd
evm
compression
rle
Package event implements an event multiplexer.
Package event implements an event multiplexer.
Package logger implements a multi-output leveled logger.
Package logger implements a multi-output leveled logger.
pow
ar
ezp
Package rlp implements the RLP serialization format.
Package rlp implements the RLP serialization format.
tests
ui
qt
Package wire provides low level access to the Ethereum network and allows you to broadcast data over the network.
Package wire provides low level access to the Ethereum network and allows you to broadcast data over the network.

Jump to

Keyboard shortcuts

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