Documentation ¶
Index ¶
- Constants
- func ConvertH512ToPeerID(h512 *proto_types.H512) [64]byte
- func Sentry(ctx context.Context, dirs datadir.Dirs, sentryAddr string, ...) error
- type GrpcServer
- func (ss *GrpcServer) AddPeer(_ context.Context, req *proto_sentry.AddPeerRequest) (*proto_sentry.AddPeerReply, error)
- func (ss *GrpcServer) Close()
- func (ss *GrpcServer) DiagnosticsPeersData() map[string]*diagnostics.PeerStatistics
- func (ss *GrpcServer) GetStatus() *proto_sentry.StatusData
- func (ss *GrpcServer) HandShake(context.Context, *emptypb.Empty) (*proto_sentry.HandShakeReply, error)
- func (ss *GrpcServer) Messages(req *proto_sentry.MessagesRequest, server proto_sentry.Sentry_MessagesServer) error
- func (ss *GrpcServer) NodeInfo(_ context.Context, _ *emptypb.Empty) (*proto_types.NodeInfoReply, error)
- func (ss *GrpcServer) PeerById(_ context.Context, req *proto_sentry.PeerByIdRequest) (*proto_sentry.PeerByIdReply, error)
- func (ss *GrpcServer) PeerCount(_ context.Context, req *proto_sentry.PeerCountRequest) (*proto_sentry.PeerCountReply, error)
- func (ss *GrpcServer) PeerEvents(req *proto_sentry.PeerEventsRequest, ...) error
- func (ss *GrpcServer) PeerMinBlock(_ context.Context, req *proto_sentry.PeerMinBlockRequest) (*emptypb.Empty, error)
- func (ss *GrpcServer) Peers(_ context.Context, _ *emptypb.Empty) (*proto_sentry.PeersReply, error)
- func (ss *GrpcServer) PenalizePeer(_ context.Context, req *proto_sentry.PenalizePeerRequest) (*emptypb.Empty, error)
- func (ss *GrpcServer) SendMessageById(_ context.Context, inreq *proto_sentry.SendMessageByIdRequest) (*proto_sentry.SentPeers, error)
- func (ss *GrpcServer) SendMessageByMinBlock(_ context.Context, inreq *proto_sentry.SendMessageByMinBlockRequest) (*proto_sentry.SentPeers, error)
- func (ss *GrpcServer) SendMessageToAll(ctx context.Context, req *proto_sentry.OutboundMessageData) (*proto_sentry.SentPeers, error)
- func (ss *GrpcServer) SendMessageToRandomPeers(ctx context.Context, req *proto_sentry.SendMessageToRandomPeersRequest) (*proto_sentry.SentPeers, error)
- func (ss *GrpcServer) SetStatus(ctx context.Context, statusData *proto_sentry.StatusData) (*proto_sentry.SetStatusReply, error)
- func (ss *GrpcServer) SimplePeerCount() map[uint]int
- type PeerInfo
- func (pi *PeerInfo) AddDeadline(deadline time.Time)
- func (pi *PeerInfo) Async(f func(), logger log.Logger)
- func (pi *PeerInfo) ClearDeadlines(now time.Time, givePermit bool) int
- func (pi *PeerInfo) Close()
- func (pi *PeerInfo) Height() uint64
- func (pi *PeerInfo) ID() [64]byte
- func (pi *PeerInfo) LatestDeadline() time.Time
- func (pi *PeerInfo) Remove(reason *p2p.PeerError)
- func (pi *PeerInfo) RemoveReason() *p2p.PeerError
- func (pi *PeerInfo) SetIncreasedHeight(newHeight uint64)
- type PeerRef
- type PeersByMinBlock
- type PeersStreams
Constants ¶
const MessagesQueueSize = 1024 // one such queue per client of .Messages stream
Variables ¶
This section is empty.
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
Types ¶
type GrpcServer ¶
type GrpcServer struct { proto_sentry.UnimplementedSentryServer Protocols []p2p.Protocol GoodPeers sync.Map P2pServer *p2p.Server TxSubscribed uint32 // Set to non-zero if downloader is subscribed to transaction messages // contains filtered or unexported fields }
func NewGrpcServer ¶
func (*GrpcServer) AddPeer ¶
func (ss *GrpcServer) AddPeer(_ context.Context, req *proto_sentry.AddPeerRequest) (*proto_sentry.AddPeerReply, error)
func (*GrpcServer) Close ¶
func (ss *GrpcServer) Close()
Close performs cleanup operations for the sentry
func (*GrpcServer) DiagnosticsPeersData ¶
func (ss *GrpcServer) DiagnosticsPeersData() map[string]*diagnostics.PeerStatistics
func (*GrpcServer) GetStatus ¶
func (ss *GrpcServer) GetStatus() *proto_sentry.StatusData
func (*GrpcServer) HandShake ¶
func (ss *GrpcServer) HandShake(context.Context, *emptypb.Empty) (*proto_sentry.HandShakeReply, error)
func (*GrpcServer) Messages ¶
func (ss *GrpcServer) Messages(req *proto_sentry.MessagesRequest, server proto_sentry.Sentry_MessagesServer) error
func (*GrpcServer) NodeInfo ¶
func (ss *GrpcServer) NodeInfo(_ context.Context, _ *emptypb.Empty) (*proto_types.NodeInfoReply, error)
func (*GrpcServer) PeerById ¶
func (ss *GrpcServer) PeerById(_ context.Context, req *proto_sentry.PeerByIdRequest) (*proto_sentry.PeerByIdReply, error)
func (*GrpcServer) PeerCount ¶
func (ss *GrpcServer) PeerCount(_ context.Context, req *proto_sentry.PeerCountRequest) (*proto_sentry.PeerCountReply, error)
func (*GrpcServer) PeerEvents ¶
func (ss *GrpcServer) PeerEvents(req *proto_sentry.PeerEventsRequest, server proto_sentry.Sentry_PeerEventsServer) error
func (*GrpcServer) PeerMinBlock ¶
func (ss *GrpcServer) PeerMinBlock(_ context.Context, req *proto_sentry.PeerMinBlockRequest) (*emptypb.Empty, error)
func (*GrpcServer) Peers ¶
func (ss *GrpcServer) Peers(_ context.Context, _ *emptypb.Empty) (*proto_sentry.PeersReply, error)
func (*GrpcServer) PenalizePeer ¶
func (ss *GrpcServer) PenalizePeer(_ context.Context, req *proto_sentry.PenalizePeerRequest) (*emptypb.Empty, error)
func (*GrpcServer) SendMessageById ¶
func (ss *GrpcServer) SendMessageById(_ context.Context, inreq *proto_sentry.SendMessageByIdRequest) (*proto_sentry.SentPeers, error)
func (*GrpcServer) SendMessageByMinBlock ¶
func (ss *GrpcServer) SendMessageByMinBlock(_ context.Context, inreq *proto_sentry.SendMessageByMinBlockRequest) (*proto_sentry.SentPeers, error)
func (*GrpcServer) SendMessageToAll ¶
func (ss *GrpcServer) SendMessageToAll(ctx context.Context, req *proto_sentry.OutboundMessageData) (*proto_sentry.SentPeers, error)
func (*GrpcServer) SendMessageToRandomPeers ¶
func (ss *GrpcServer) SendMessageToRandomPeers(ctx context.Context, req *proto_sentry.SendMessageToRandomPeersRequest) (*proto_sentry.SentPeers, error)
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 ¶
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) ClearDeadlines ¶
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) LatestDeadline ¶
func (*PeerInfo) RemoveReason ¶
func (*PeerInfo) SetIncreasedHeight ¶
SetIncreasedHeight atomically updates PeerInfo.height only if newHeight is higher
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