sentry

package
v1.9.7-0...-ba03429 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: LGPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const MessagesQueueSize = 1024 // one such queue per client of .Messages stream

Variables

View Source
var ErrNoHead = errors.New("ReadChainHead: ReadCurrentHeader error")

Functions

func ConvertH512ToPeerID

func ConvertH512ToPeerID(h512 *proto_types.H512) [64]byte

ConvertH512ToPeerID() ensures the return type is [64]byte so that short variable declarations will still be formatted as hex in logs

func Sentry

func Sentry(ctx context.Context, dirs datadir.Dirs, sentryAddr string, discoveryDNS []string, cfg *p2p.Config, protocolVersion uint, healthCheck bool, logger log.Logger) error

Sentry creates and runs standalone sentry

Types

type ChainHead

type ChainHead struct {
	HeadHeight uint64
	HeadTime   uint64
	HeadHash   libcommon.Hash
	HeadTd     *uint256.Int
}

func ReadChainHead

func ReadChainHead(ctx context.Context, db kv.RoDB) (ChainHead, error)

func ReadChainHeadWithTx

func ReadChainHeadWithTx(tx kv.Tx) (ChainHead, error)

type GrpcServer

type GrpcServer struct {
	proto_sentry.UnimplementedSentryServer

	Protocols    []p2p.Protocol
	GoodPeers    sync.Map
	TxSubscribed uint32 // Set to non-zero if downloader is subscribed to transaction messages
	// contains filtered or unexported fields
}

func NewGrpcServer

func NewGrpcServer(ctx context.Context, dialCandidates func() enode.Iterator, readNodeInfo func() *eth.NodeInfo, cfg *p2p.Config, protocol uint, logger log.Logger) *GrpcServer

func (*GrpcServer) AddPeer

func (*GrpcServer) Close

func (ss *GrpcServer) Close()

Close performs cleanup operations for the sentry

func (*GrpcServer) GetStatus

func (ss *GrpcServer) GetStatus() *proto_sentry.StatusData

func (*GrpcServer) HandShake

func (*GrpcServer) Messages

func (*GrpcServer) NodeInfo

func (*GrpcServer) PeerById

func (*GrpcServer) PeerCount

func (*GrpcServer) PeerEvents

func (*GrpcServer) PeerMinBlock

func (*GrpcServer) Peers

func (*GrpcServer) PenalizePeer

func (*GrpcServer) SendMessageById

func (*GrpcServer) SendMessageByMinBlock

func (*GrpcServer) SendMessageToAll

func (*GrpcServer) SendMessageToRandomPeers

func (*GrpcServer) SetStatus

func (ss *GrpcServer) SetStatus(ctx context.Context, statusData *proto_sentry.StatusData) (*proto_sentry.SetStatusReply, error)

func (*GrpcServer) SimplePeerCount

func (ss *GrpcServer) SimplePeerCount() map[uint]int

type PeerInfo

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

PeerInfo collects various extra bits of information about the peer, for example deadlines that is used for regulating requests sent to the peer

func NewPeerInfo

func NewPeerInfo(peer *p2p.Peer, rw p2p.MsgReadWriter) *PeerInfo

func (*PeerInfo) AddDeadline

func (pi *PeerInfo) AddDeadline(deadline time.Time)

AddDeadline adds given deadline to the list of deadlines Deadlines must be added in the chronological order for the function ClearDeadlines to work correctly (it uses binary search)

func (*PeerInfo) Async

func (pi *PeerInfo) Async(f func(), logger log.Logger)

func (*PeerInfo) ClearDeadlines

func (pi *PeerInfo) ClearDeadlines(now time.Time, givePermit bool) int

ClearDeadlines goes through the deadlines of given peers and removes the ones that have passed Optionally, it also clears one extra deadline - this is used when response is received It returns the number of deadlines left

func (*PeerInfo) Close

func (pi *PeerInfo) Close()

func (*PeerInfo) Height

func (pi *PeerInfo) Height() uint64

func (*PeerInfo) ID

func (pi *PeerInfo) ID() [64]byte

func (*PeerInfo) LatestDeadline

func (pi *PeerInfo) LatestDeadline() time.Time

func (*PeerInfo) Remove

func (pi *PeerInfo) Remove(reason *p2p.PeerError)

func (*PeerInfo) RemoveReason

func (pi *PeerInfo) RemoveReason() *p2p.PeerError

func (*PeerInfo) SetIncreasedHeight

func (pi *PeerInfo) SetIncreasedHeight(newHeight uint64)

SetIncreasedHeight atomically updates PeerInfo.height only if newHeight is higher

type PeerRef

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

type PeersByMinBlock

type PeersByMinBlock []PeerRef

PeersByMinBlock is the priority queue of peers. Used to select certain number of peers considered to be "best available"

func (PeersByMinBlock) Len

func (bp PeersByMinBlock) Len() int

Len (part of heap.Interface) returns the current size of the best peers queue

func (PeersByMinBlock) Less

func (bp PeersByMinBlock) Less(i, j int) bool

Less (part of heap.Interface) compares two peers

func (*PeersByMinBlock) Pop

func (bp *PeersByMinBlock) Pop() interface{}

Pop (part of heap.Interface) removes the first peer from the queue

func (*PeersByMinBlock) Push

func (bp *PeersByMinBlock) Push(x interface{})

Push (part of heap.Interface) places a new peer onto the end of queue.

func (PeersByMinBlock) Swap

func (bp PeersByMinBlock) Swap(i, j int)

Swap (part of heap.Interface) moves two peers in the queue into each other's places.

type PeersStreams

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

PeersStreams - it's safe to use this class as non-pointer

func NewPeersStreams

func NewPeersStreams() *PeersStreams

func (*PeersStreams) Add

func (s *PeersStreams) Add(stream proto_sentry.Sentry_PeerEventsServer) (remove func())

func (*PeersStreams) Broadcast

func (s *PeersStreams) Broadcast(reply *proto_sentry.PeerEvent) (errs []error)

func (*PeersStreams) Len

func (s *PeersStreams) Len() int

type StatusDataProvider

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

func NewStatusDataProvider

func NewStatusDataProvider(
	db kv.RoDB,
	chainConfig *chain.Config,
	genesis *types.Block,
	networkId uint64,
	logger log.Logger,
) *StatusDataProvider

func (*StatusDataProvider) GetStatusData

func (s *StatusDataProvider) GetStatusData(ctx context.Context) (*proto_sentry.StatusData, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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