sentinel

package
v0.0.0-...-ff78b6e Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: GPL-3.0 Imports: 43 Imported by: 0

Documentation

Overview

package sentinel

Index

Constants

View Source
const SSZSnappyCodec = "ssz_snappy"

Variables

View Source
var AttesterSlashingSsz = GossipTopic{
	Name:     AttesterSlashingTopic,
	CodecStr: SSZSnappyCodec,
}
View Source
var BeaconAggregateAndProofSsz = GossipTopic{
	Name:     BeaconAggregateAndProofTopic,
	CodecStr: SSZSnappyCodec,
}
View Source
var BeaconBlockSsz = GossipTopic{
	Name:     BeaconBlockTopic,
	CodecStr: SSZSnappyCodec,
}
View Source
var BlsToExecutionChangeSsz = GossipTopic{
	Name:     BlsToExecutionChangeTopic,
	CodecStr: SSZSnappyCodec,
}
View Source
var ProposerSlashingSsz = GossipTopic{
	Name:     ProposerSlashingTopic,
	CodecStr: SSZSnappyCodec,
}
View Source
var VoluntaryExitSsz = GossipTopic{
	Name:     VoluntaryExitTopic,
	CodecStr: SSZSnappyCodec,
}

Functions

This section is empty.

Types

type Gater

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

func NewGater

func NewGater(cfg *SentinelConfig) (g *Gater, err error)

func (*Gater) InterceptAccept

func (g *Gater) InterceptAccept(n network.ConnMultiaddrs) (allow bool)

InterceptAccept tests whether an incipient inbound connection is allowed.

This is called by the upgrader, or by the transport directly (e.g. QUIC, Bluetooth), straight after it has accepted a connection from its socket.

func (*Gater) InterceptAddrDial

func (g *Gater) InterceptAddrDial(_ peer.ID, n multiaddr.Multiaddr) (allow bool)

InterceptAddrDial tests whether we're permitted to dial the specified multiaddr for the given peer.

This is called by the network.Network implementation after it has resolved the peer's addrs, and prior to dialling each.

func (*Gater) InterceptPeerDial

func (g *Gater) InterceptPeerDial(p peer.ID) (allow bool)

InterceptPeerDial tests whether we're permitted to Dial the specified peer. This is called by the network.Network implementation when dialling a peer.

func (*Gater) InterceptSecured

func (g *Gater) InterceptSecured(_ network.Direction, _ peer.ID, _ network.ConnMultiaddrs) (allow bool)

InterceptSecured tests whether a given connection, now authenticated, is allowed.

This is called by the upgrader, after it has performed the security handshake, and before it negotiates the muxer, or by the directly by the transport, at the exact same checkpoint.

func (*Gater) InterceptUpgraded

func (g *Gater) InterceptUpgraded(_ network.Conn) (allow bool, reason control.DisconnectReason)

InterceptUpgraded tests whether a fully capable connection is allowed.

At this point, the connection a multiplexer has been selected. When rejecting a connection, the gater can return a DisconnectReason. Refer to the godoc on the ConnectionGater type for more information.

NOTE: the go-libp2p implementation currently IGNORES the disconnect reason.

type GossipManager

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

func NewGossipManager

func NewGossipManager(
	ctx context.Context,
) *GossipManager

construct a new gossip manager that will handle packets with the given handlerfunc

func (*GossipManager) AddSubscription

func (s *GossipManager) AddSubscription(topic string, sub *GossipSubscription)

func (*GossipManager) Close

func (g *GossipManager) Close()

func (*GossipManager) GetMatchingSubscription

func (s *GossipManager) GetMatchingSubscription(match string) *GossipSubscription

func (*GossipManager) Recv

func (s *GossipManager) Recv() <-chan *pubsub.Message

type GossipSubscription

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

GossipSubscription abstracts a gossip subscription to write decoded structs.

func (*GossipSubscription) Close

func (s *GossipSubscription) Close()

calls the cancel func for the subscriber and closes the topic and sub

func (*GossipSubscription) Listen

func (sub *GossipSubscription) Listen() (err error)

func (*GossipSubscription) Publish

func (g *GossipSubscription) Publish(data []byte) error

type GossipTopic

type GossipTopic struct {
	Name     TopicName
	CodecStr string
}

func GossipSidecarTopics

func GossipSidecarTopics(maxBlobs uint64) (ret []GossipTopic)

type Sentinel

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

func New

func New(
	ctx context.Context,
	cfg *SentinelConfig,
	db persistence.RawBeaconBlockChain,
	logger log.Logger,
) (*Sentinel, error)

This is just one of the examples from the libp2p repository.

func (*Sentinel) Config

func (s *Sentinel) Config() *SentinelConfig

func (*Sentinel) ConnectWithPeer

func (s *Sentinel) ConnectWithPeer(ctx context.Context, info peer.AddrInfo) (err error)

ConnectWithPeer is used to attempt to connect and add the peer to our pool it errors when if fail to connect with the peer, for instance, if it fails the handshake if it does not return an error, the peer is attempted to be added to the pool

func (*Sentinel) GetPeersCount

func (s *Sentinel) GetPeersCount() int

func (*Sentinel) GossipManager

func (s *Sentinel) GossipManager() *GossipManager

func (*Sentinel) HasTooManyPeers

func (s *Sentinel) HasTooManyPeers() bool

func (*Sentinel) Host

func (s *Sentinel) Host() host.Host

func (*Sentinel) Peers

func (s *Sentinel) Peers() *peers.Pool

func (*Sentinel) PeersList

func (s *Sentinel) PeersList() []peer.AddrInfo

func (*Sentinel) RecvGossip

func (s *Sentinel) RecvGossip() <-chan *pubsub.Message

func (*Sentinel) ReqRespHandler

func (s *Sentinel) ReqRespHandler() http.Handler

func (*Sentinel) SetStatus

func (s *Sentinel) SetStatus(status *cltypes.Status)

func (*Sentinel) Start

func (s *Sentinel) Start() error

func (*Sentinel) Status

func (s *Sentinel) Status() *cltypes.Status

func (*Sentinel) Stop

func (s *Sentinel) Stop()

func (*Sentinel) String

func (s *Sentinel) String() string

func (*Sentinel) SubscribeGossip

func (s *Sentinel) SubscribeGossip(topic GossipTopic, opts ...pubsub.TopicOpt) (sub *GossipSubscription, err error)

func (*Sentinel) Unsubscribe

func (s *Sentinel) Unsubscribe(topic GossipTopic, opts ...pubsub.TopicOpt) (err error)

type SentinelConfig

type SentinelConfig struct {
	NetworkConfig *clparams.NetworkConfig
	GenesisConfig *clparams.GenesisConfig
	BeaconConfig  *clparams.BeaconChainConfig
	IpAddr        string
	Port          int
	TCPPort       uint
	// Optional
	LocalIP        string
	EnableUPnP     bool
	RelayNodeAddr  string
	HostAddress    string
	HostDNS        string
	NoDiscovery    bool
	TmpDir         string
	LocalDiscovery bool
}

type TopicName

type TopicName string
const (
	BeaconBlockTopic             TopicName = "beacon_block"
	BeaconAggregateAndProofTopic TopicName = "beacon_aggregate_and_proof"
	VoluntaryExitTopic           TopicName = "voluntary_exit"
	ProposerSlashingTopic        TopicName = "proposer_slashing"
	AttesterSlashingTopic        TopicName = "attester_slashing"
	BlsToExecutionChangeTopic    TopicName = "bls_to_execution_change"
	BlobSidecarTopic             TopicName = "blob_sidecar_%d" // This topic needs an index
)

Directories

Path Synopsis
package httpreqresp encapsulates eth2 beacon chain resp-resp into http
package httpreqresp encapsulates eth2 beacon chain resp-resp into http

Jump to

Keyboard shortcuts

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