ronin

package
v0.0.0-...-979e23b Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NewVoteMsg = 0x00
)
View Source
const ProtocolName = "ronin"

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

View Source
const (
	Ronin1 = 1
)

Constants to match up protocol versions and messages

Variables

View Source
var ProtocolVersions = []uint{Ronin1}

ProtocolVersions are the supported versions of the `ronin` protocol

Functions

func Handle

func Handle(backend Backend, peer *Peer) error

Handle is the callback invoked to manage the life cycle of a `ronin` peer. When this function terminates, the peer is disconnected.

func MakeProtocols

func MakeProtocols(backend Backend) []p2p.Protocol

Types

type Backend

type Backend interface {
	// RunPeer is invoked when a peer joins on the `ronin` 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 `ronin` 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
}

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 NewVotePacket

type NewVotePacket struct {
	Vote []*types.RawVoteEnvelope
}

func (*NewVotePacket) Kind

func (*NewVotePacket) Kind() byte

func (*NewVotePacket) Name

func (*NewVotePacket) Name() string

type NodeInfo

type NodeInfo struct{}

NodeInfo represents a short summary of the `ronin` 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 `ronin` 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 `ronin` peer.

func NewPeer

func NewPeer(version uint, p *p2p.Peer, rw p2p.MsgReadWriter) *Peer

NewPeer create a wrapper for a network connection and negotiated protocol version.

func (*Peer) AsyncSendNewVote

func (p *Peer) AsyncSendNewVote(vote *types.VoteEnvelope)

AsyncSendNewVote puts the vote into the batch vote goroutine.

func (*Peer) Close

func (p *Peer) Close()

Close terminates the vote batch goroutine.

func (*Peer) ID

func (p *Peer) ID() string

ID retrieves the peer's unique identifier.

func (*Peer) KnownFinalityVote

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

KnownFinalityVote returns whether peer is known to already have a vote.

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) Version

func (p *Peer) Version() uint

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

Jump to

Keyboard shortcuts

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