cons

package
v1.0.0-release Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NewAttestationMsg               = 0x00 // A single attestation of a block
	NewJustifiedOrFinalizedBlockMsg = 0x01 // The current node tells other nodes that it has a block with state Justified or Finalized
	GetAttestationsMsg              = 0x02 // Request to get all attestations of a given block
	AttestationsMsg                 = 0x03 // Response of the GetAttestationsMsg
)
View Source
const ProtocolName = "cons"

ProtocolName is the official short name of the `cons` protocol used during devp2p capability negotiation.

Variables

View Source
var ProtocolVersions = []uint{cons1}

ProtocolVersions are the supported versions of the `cons` protocol (first is primary).

Functions

func MakeProtocols

func MakeProtocols(backend Backend, dnsDisc enode.Iterator) []p2p.Protocol

MakeProtocols constructs the P2P protocol definitions for `cons`.

Types

type AttestationScheduler

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

AttestationScheduler schedule attestation processing task, it's quite like the role of blockFetcher to blocks.

type Backend

type Backend interface {
	// Chain retrieves the blockchain object to serve data.
	Chain() *core.BlockChain

	// RunPeer is invoked when a peer joins on the `eth` protocol. The handler
	// should do any peer maintenance work, handshakes and validations. If all
	// is passed, control should be given back to the `handler` to process the
	// inbound messages going forward.
	RunPeer(peer *Peer, handler Handler) error

	// PeerInfo retrieves all known `cons` information about a peer.
	PeerInfo(id enode.ID) interface{}

	// Handle is a callback to be invoked when a data packet is received from
	// the remote peer. Only packets not consumed by the protocol handler will
	// be forwarded to the backend.
	Handle(peer *Peer, packet Packet) error

	// AcceptAttestation retrieves whether attestation processing is enabled on the node
	// or if inbound attestations should simply be dropped.
	AcceptAttestation() bool
}

Backend defines the data retrieval methods to serve remote requests and the callback methods to invoke on remote deliveries.

type Decoder

type Decoder interface {
	Decode(val interface{}) error
	Time() time.Time
}

type Handler

type Handler func(peer *Peer) error

Handler is a callback to invoke from an outside runner after the boilerplate exchanges have passed.

type NewAttestationPacket

type NewAttestationPacket struct {
	SourceRangeEdge *types.RangeEdge
	TargetRangeEdge *types.RangeEdge
	R               *big.Int
	S               *big.Int
	V               uint8
}

NewAttestationPacket represents a packet containing a single attestation of a block.

func (*NewAttestationPacket) Kind

func (*NewAttestationPacket) Kind() byte

func (*NewAttestationPacket) Name

func (*NewAttestationPacket) Name() string

type NodeInfo

type NodeInfo struct{}

NodeInfo represents a short summary of the `cons` sub-protocol metadata known about the host peer.

type Packet

type Packet interface {
	Name() string // Name returns a string corresponding to the message type.
	Kind() byte   // Kind returns the message type.
}

Packet represents a p2p message in the `cons` protocol.

type Peer

type Peer struct {
	*p2p.Peer // The embedded P2P package peer
	// contains filtered or unexported fields
}

Peer is a collection of relevant information we have about a `cons` peer.

func (*Peer) AsyncSendNewAttestation

func (p *Peer) AsyncSendNewAttestation(a *types.Attestation)

func (*Peer) AsyncSendNewJustifiedOrFinalizedBlock

func (p *Peer) AsyncSendNewJustifiedOrFinalizedBlock(bs *types.BlockStatus)

func (*Peer) Close

func (p *Peer) Close()

Close signals the broadcast goroutine to terminate. Only ever call this if you created the peer yourself via NewPeer. Otherwise let whoever created it clean it up!

func (*Peer) ID

func (p *Peer) ID() string

ID retrieves the peer's unique identifier.

func (*Peer) KnownAttestation

func (p *Peer) KnownAttestation(hash common.Hash) bool

func (*Peer) KnownJustifiedOrFinalizedBlock

func (p *Peer) KnownJustifiedOrFinalizedBlock(hash common.Hash) bool

func (*Peer) Log

func (p *Peer) Log() log.Logger

Log overrides the P2P logget with the higher level one containing only the id.

func (*Peer) SendNewAttestation

func (p *Peer) SendNewAttestation(a *types.Attestation) error

func (*Peer) SendNewJustifiedOrFinalizedBlock

func (p *Peer) SendNewJustifiedOrFinalizedBlock(bs *types.BlockStatus) error

func (*Peer) Version

func (p *Peer) Version() uint

Version retrieves the peer's negoatiated `cons` protocol version.

Jump to

Keyboard shortcuts

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