trust

package
v0.0.0-...-4c3619c Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestRootMsg = 0x00
	RespondRootMsg = 0x01
)
View Source
const ProtocolName = "trust"

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

View Source
const (
	Trust1 = 1
)

Constants to match up protocol versions and messages

Variables

View Source
var ProtocolVersions = []uint{Trust1}

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

Functions

func Handle

func Handle(backend Backend, peer *Peer) error

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

func MakeProtocols

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

MakeProtocols constructs the P2P protocol definitions for `trust`.

Types

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(id enode.ID) interface{}

	Handle(peer *Peer, packet Packet) error
}

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 NodeInfo

type NodeInfo struct{}

NodeInfo represents a short summary of the `trust` 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 `trust` 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 `trust` 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) 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) Log

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

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

func (*Peer) RequestRoot

func (p *Peer) RequestRoot(blockNumber uint64, blockHash common.Hash, diffHash common.Hash) error

func (*Peer) Version

func (p *Peer) Version() uint

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

type RootRequestPacket

type RootRequestPacket struct {
	RequestId   uint64
	BlockNumber uint64
	BlockHash   common.Hash
	DiffHash    common.Hash
}

func (*RootRequestPacket) Kind

func (*RootRequestPacket) Kind() byte

func (*RootRequestPacket) Name

func (*RootRequestPacket) Name() string

type RootResponsePacket

type RootResponsePacket struct {
	RequestId   uint64
	Status      types.VerifyStatus
	BlockNumber uint64
	BlockHash   common.Hash
	Root        common.Hash
	Extra       rlp.RawValue // for extension
}

func (*RootResponsePacket) Kind

func (*RootResponsePacket) Kind() byte

func (*RootResponsePacket) Name

func (*RootResponsePacket) Name() string

Jump to

Keyboard shortcuts

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