ethereum

package
v0.0.0-...-8f649d9 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: LGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusMsg          ethMessage = 0x00
	NewBlockHashesMsg             = 0x01
	TxMsg                         = 0x02
	GetBlockHeadersMsg            = 0x03
	BlockHeadersMsg               = 0x04
	GetBlockBodiesMsg             = 0x05
	BlockBodiesMsg                = 0x06
	NewBlockMsg                   = 0x07
	GetNodeDataMsg                = 0x0d
	NodeDataMsg                   = 0x0e
	GetReceiptsMsg                = 0x0f
	ReceiptsMsg                   = 0x10
)

Variables

View Source
var ETH63 = network.ProtocolSpec{
	Name:    "eth",
	Version: 63,
	Length:  17,
}

ETH63 is the Fast synchronization protocol

Functions

func Factory

func Factory(ctx context.Context, logger hclog.Logger, m interface{}, config map[string]interface{}) (protocol.Backend, error)

Types

type AckMessage

type AckMessage struct {
	Error  error
	Result interface{}
}

AckMessage is the ack message

func (*AckMessage) Completed

func (a *AckMessage) Completed() bool

Completed returns true if there is a value in the response

type Backend

type Backend struct {
	NetworkID uint64
	// contains filtered or unexported fields
}

Backend is the ethereum backend

func NewBackend

func NewBackend(minimal *minimal.Minimal, logger hclog.Logger, blockchain *blockchain.Blockchain) (*Backend, error)

NewBackend creates a new ethereum backend

func (*Backend) Add

func (b *Backend) Add(conn net.Conn, peer *network.Peer) (network.ProtocolHandler, error)

Add is called when we connect to a new node

func (*Backend) FindCommonAncestor

func (b *Backend) FindCommonAncestor(peer *Ethereum, height *types.Header) (*types.Header, error)

FindCommonAncestor finds the common ancestor with the peer and the syncer connection

func (*Backend) GetStatus

func (b *Backend) GetStatus() (*Status, error)

GetStatus returns the current ethereum status

func (*Backend) Protocols

func (b *Backend) Protocols() []*network.Protocol

Protocols implements the protocol interface

func (*Backend) Run

func (b *Backend) Run()

Run implements the protocol interface

func (*Backend) WatchMinedBlocks

func (b *Backend) WatchMinedBlocks(watch chan *sealer.SealedNotify)

type Blockchain

type Blockchain interface {
	GetReceiptsByHash(types.Hash) []*types.Receipt
	GetHeaderByHash(hash types.Hash) (*types.Header, bool)
	GetHeaderByNumber(number uint64) (*types.Header, bool)
	GetBodyByHash(types.Hash) (*types.Body, bool)
	GetConsensus() consensus.Consensus
}

Blockchain interface are the methods required by the handler

type Ethereum

type Ethereum struct {

	// header data
	HeaderHash   types.Hash
	HeaderDiff   *big.Int
	HeaderNumber *big.Int
	// contains filtered or unexported fields
}

Ethereum is the protocol for etheruem

func NewEthereumProtocol

func NewEthereumProtocol(session network.Session, peerID string, logger hclog.Logger, conn net.Conn, blockchain *blockchain.Blockchain) *Ethereum

NewEthereumProtocol creates the ethereum protocol

func (*Ethereum) Close

func (e *Ethereum) Close() error

Close the protocol

func (*Ethereum) DoRequest

func (e *Ethereum) DoRequest(req *Request, q *Queue3) error

DoRequest is an adhoc method to do Skeleton requests

func (*Ethereum) Header

func (e *Ethereum) Header() types.Hash

func (*Ethereum) Info

func (e *Ethereum) Info() (map[string]interface{}, error)

Info implements the handler interface

func (*Ethereum) Init

func (e *Ethereum) Init(peer *network.Peer, status *Status) error

Init starts the protocol

func (*Ethereum) Status

func (e *Ethereum) Status() *Status

func (*Ethereum) ValidateDAOBlock

func (e *Ethereum) ValidateDAOBlock() error

ValidateDAOBlock queries the DAO block

type NotifyMsg

type NotifyMsg struct {
	Block *types.Block
	Diff  *big.Int
}

NotifyMsg notifies that there is a new block

type Queue3

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

Queue3 stores the data in epochs, one epoch at a time, only when one epoch is consumed we proceed to consume the next one

func (*Queue3) AddSkeleton

func (q *Queue3) AddSkeleton(headers []*types.Header, lastSlotNum uint64) error

AddSkeleton adds a skeleton to the queue

func (*Queue3) DeliverJob

func (q *Queue3) DeliverJob(req *Request, p *fastrlp.Parser, v *fastrlp.Value) error

DeliverJob delivers a job

func (*Queue3) GetJob

func (q *Queue3) GetJob(req *Request) bool

GetJob gets a new job from the queue

func (*Queue3) Head

func (q *Queue3) Head() *types.Header

Head returns the head of the skeleton

func (*Queue3) IsCompleted

func (q *Queue3) IsCompleted() bool

IsCompleted returns true if the queue is completed

func (*Queue3) Len

func (q *Queue3) Len() int

func (*Queue3) Next

func (q *Queue3) Next() *types.Block

func (*Queue3) ReassignJob

func (q *Queue3) ReassignJob(req *Request)

func (*Queue3) Wait

func (q *Queue3) Wait()

Wait is to wait for the data to be ready

type Request

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

Request is a request from the skeleton queue to retrieve information

type RequestStatus

type RequestStatus uint

RequestStatus is the status of the items in the slot (RENAME)

const (
	// Completed if the item has been fully downloaded
	Completed RequestStatus = iota
	// OnFly if the item is being requested
	OnFly
	// Pending if the item has to be scheduled for downloading
	Pending
)

func (RequestStatus) String

func (r RequestStatus) String() string

type RequestType

type RequestType uint
const (
	Headers RequestType = iota
	Bodies
	Receipts
	NodeData
)

func (*RequestType) String

func (r *RequestType) String() string

type Slot

type Slot struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Slot is the slots in the epoch, groups of 190

func (*Slot) Deliver

func (s *Slot) Deliver(q *Queue3, req *Request, p *fastrlp.Parser, v *fastrlp.Value, isLast bool) error

Deliver delivers a response

func (*Slot) GetJob

func (s *Slot) GetJob(indx uint, req *Request) bool

GetJob returns a job from this slot

func (*Slot) Len

func (s *Slot) Len() uint64

Len is the size of the slot

type Status

type Status struct {
	ProtocolVersion uint64
	NetworkID       uint64
	TD              *big.Int
	CurrentBlock    types.Hash
	GenesisBlock    types.Hash
}

Status is the object for the status message.

func (*Status) MarshalRLP

func (s *Status) MarshalRLP() []byte

func (*Status) UnmarshalRLP

func (s *Status) UnmarshalRLP(buf []byte) error

Jump to

Keyboard shortcuts

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