devp2p

package
v0.0.0-...-2fe5e27 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

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

	// ethereum byzantium fork relevant information
	ByzantiumBlockNumber  = 4370000
	ByzantiumBlockHashStr = "0xb1fcff633029ee18ab6482b58ff8b6e95dd7c82a954c852157152a7a6d32785e"
)

eth protocol message codes

Variables

View Source
var ByzantiumBlockNumberBigInt = big.NewInt(ByzantiumBlockNumber)

Functions

This section is empty.

Types

type Config

type Config struct {
	// bootnodes file
	BootnodesPath string

	// node database path. Must be appointed outside this package
	NodeDatabasePath string

	// we can log what is going on with the go-ethereum/p2p library
	LibP2PDebug bool

	// Passing labels from one object to another
	DbPool *redis.Pool

	// activate this value to send updates on discovered and connected
	// peers to the database
	IsPeerScrapperActive bool

	// activate this value to start the block header syncing
	IsSyncBlockHeaderActive bool

	// the client's private key here
	PrivateKeyFilePath string
}

Config is the configuration object for DevP2P

type Manager

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

Manager is the object that sets up the node as a devp2p peer, managing its connected peers, and communicating with the bridge through the assigned channels.

func NewManager

func NewManager(config *Config) *Manager

NewManager returns a DevP2P Manager object

  • defines bootnodes, and
  • defines node database, to be used by the discovery functions of go-ethereum/p2p library.

* sets up the mustekala services database connection.

  • sets up the peerstore, which , among other things, keeps track of the best available peer to send a message.
  • sets up a custom p2p lib logger, to be able to get stats on dialing, encrypted and proto handshakes, as well as catching and printing those logs.
  • sets up the server. See manager.protocolHandler() and handlerIncomingMsg() to understand a peer's lifecycle and the receiving of devp2p messages and sending to the bridge.

* sets up the block header syncer, if the option is enabled.

func (*Manager) BestPeer

func (m *Manager) BestPeer() *Peer

BestPeer makes available the best peer from the store

func (*Manager) NewSyncer

func (m *Manager) NewSyncer() *Syncer

NewSyncer is the Syncer constructor

func (*Manager) Start

func (m *Manager) Start()

Start should be run as a goroutine

func (*Manager) Stop

func (m *Manager) Stop()

Stop terminates the server

type Peer

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

Peer is an arrangement we use to organize the life cycle of a devp2p peer after it is dialed, and the encryption and protocol handshakes are performed. After a succesful ethereum handshake, this Peer can be added in the peerstore, to be managed for further requesting.

func (*Peer) DoEthereumHandshake

func (p *Peer) DoEthereumHandshake() error

DoEthereumHandshake initiates the ethereum handshake, sending the status message.

func (*Peer) Head

func (p *Peer) Head() (currentBlock common.Hash, td *big.Int)

Head returns reported current block and total difficulty of the peer

func (*Peer) RequestHeadersByHash

func (p *Peer) RequestHeadersByHash(origin common.Hash, amount int, skip int, reverse bool) error

RequestHeadersByHash fetches a batch of blocks' headers corresponding to the specified header query, based on the hash of an origin block.

func (*Peer) RequestHeadersByNumber

func (p *Peer) RequestHeadersByNumber(origin uint64, amount int, skip int, reverse bool) error

RequestHeadersByNumber fetches a batch of blocks' headers corresponding to the specified header query, based on the number of an origin block.

func (*Peer) String

func (p *Peer) String() string

String implements fmt.Stringer.

type Syncer

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

Syncer is the coordinator of the block header syncer service.

func (*Syncer) Start

func (s *Syncer) Start()

Start the main function of this service.

Directories

Path Synopsis
Package downloader contains the manual full chain synchronisation.
Package downloader contains the manual full chain synchronisation.
Package metrics provides general system and process level metrics collection.
Package metrics provides general system and process level metrics collection.

Jump to

Keyboard shortcuts

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