Documentation
¶
Index ¶
- Constants
- Variables
- func MakeProtocols(backend Backend, dnsDisc enode.Iterator) []p2p.Protocol
- type AttestationScheduler
- type Backend
- type Decoder
- type Handler
- type NewAttestationPacket
- type NodeInfo
- type Packet
- type Peer
- func (p *Peer) AsyncSendNewAttestation(a *types.Attestation)
- func (p *Peer) AsyncSendNewJustifiedOrFinalizedBlock(bs *types.BlockStatus)
- func (p *Peer) Close()
- func (p *Peer) ID() string
- func (p *Peer) KnownAttestation(hash common.Hash) bool
- func (p *Peer) KnownJustifiedOrFinalizedBlock(hash common.Hash) bool
- func (p *Peer) Log() log.Logger
- func (p *Peer) SendNewAttestation(a *types.Attestation) error
- func (p *Peer) SendNewJustifiedOrFinalizedBlock(bs *types.BlockStatus) error
- func (p *Peer) Version() uint
Constants ¶
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 )
const ProtocolName = "cons"
ProtocolName is the official short name of the `cons` protocol used during devp2p capability negotiation.
Variables ¶
var ProtocolVersions = []uint{cons1}
ProtocolVersions are the supported versions of the `cons` protocol (first is primary).
Functions ¶
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 Handler ¶
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) KnownJustifiedOrFinalizedBlock ¶
func (*Peer) SendNewAttestation ¶
func (p *Peer) SendNewAttestation(a *types.Attestation) error
func (*Peer) SendNewJustifiedOrFinalizedBlock ¶
func (p *Peer) SendNewJustifiedOrFinalizedBlock(bs *types.BlockStatus) error