Documentation
¶
Index ¶
Constants ¶
const DecayToZero = 0.01
DecayToZero is the decay factor for a peer's score to zero.
Variables ¶
var MessageDomainInvalidSnappy = [4]byte{0, 0, 0, 0}
var MessageDomainValidSnappy = [4]byte{1, 0, 0, 0}
Functions ¶
Types ¶
type DiscoveredPeer ¶
func NewDiscoveredPeer ¶
func NewDiscoveredPeer(node *enode.Node) (*DiscoveredPeer, error)
type Discovery ¶
type Discovery struct {
// Metrics
MeterDiscoveredPeers metric.Int64Counter
// contains filtered or unexported fields
}
Discovery is a suture service that periodically queries the discv5 DHT for random peers and publishes the discovered peers on the `out` channel. Users of this Discovery service are required to read from the channel. Otherwise, the discovery will block forever.
func NewDiscovery ¶
func NewDiscovery(privKey *ecdsa.PrivateKey, cfg *DiscoveryConfig) (*Discovery, error)
type DiscoveryConfig ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is the main entry point to listening to the Ethereum GossipSub mesh.
func NewNode ¶
func NewNode(cfg *NodeConfig) (*Node, error)
NewNode initializes a new Node using the provided configuration. It first validates the node configuration. Then it initializes the libp2p host using the libp2p options from the given configuration object. Next, it initializes the Ethereum node by extracting the ECDSA private key, creating a new discovery service, creating a new ReqResp server, creating a new PubSub server, and creating a new Prysm client. Finally, it initializes the Hermes node by setting the configuration and dependencies.
func (*Node) CanSubscribe ¶
CanSubscribe originally returns true if the topic is of interest, and we could subscribe to it.
func (*Node) FilterIncomingSubscriptions ¶
func (n *Node) FilterIncomingSubscriptions(id peer.ID, subs []*pubsubpb.RPC_SubOpts) ([]*pubsubpb.RPC_SubOpts, error)
FilterIncomingSubscriptions is invoked for all RPCs containing subscription notifications. This method returns only the topics of interest and may return an error if the subscription request contains too many topics.
type NodeConfig ¶
type NodeConfig struct {
// The private key for the libp2p host and local enode in hex format
PrivateKeyStr string
ChainID int
BlockTopics []string
Bootstrappers []*enode.Node
// General timeout when communicating with other network participants
DialTimeout time.Duration
// The address information of the local ethereuem [enode.Node].
Devp2pHost string
Devp2pPort int
// The address information of the local libp2p host
Libp2pHost string
Libp2pPort int
Libp2pPeerscoreSnapshotFreq time.Duration
PubSubValidateQueueSize int
DirectConnections []string
// PeerFilter configuration for filtering peers (passed to host)
PeerFilter *host.FilterConfig
// Pause between two discovery lookups
LookupInterval time.Duration
// The Data Stream configuration
DataStreamType host.DataStreamType
AWSConfig *aws.Config
S3Config *host.S3DSConfig
KinesisRegion string
KinesisStream string
// Telemetry accessors
Tracer trace.Tracer
Meter metric.Meter
// contains filtered or unexported fields
}
func (*NodeConfig) DirectMultiaddrs ¶
func (n *NodeConfig) DirectMultiaddrs() []peer.AddrInfo
DirectMultiaddrs returns the []peer.AddrInfo for the given direct connction peers
func (*NodeConfig) ECDSAPrivateKey ¶
func (n *NodeConfig) ECDSAPrivateKey() (*ecdsa.PrivateKey, error)
ECDSAPrivateKey returns the ECDSA private key associated with the NodeConfig. It retrieves the private key using the PrivateKey method and then converts it to ECDSA format. If there is an error retrieving the private key or converting it to ECDSA format, an error is returned.
func (*NodeConfig) PrivateKey ¶
func (n *NodeConfig) PrivateKey() (*crypto.Secp256k1PrivateKey, error)
PrivateKey returns a parsed Secp256k1 private key from the given PrivateKeyStr. If that's unset, a new one will be generated. In any case, the result will be cached, so that the private key won't be generated twice.
func (*NodeConfig) Validate ¶
func (n *NodeConfig) Validate() error
Validate validates the NodeConfig Node configuration.
type OpStackENRData ¶
type OpStackENRData struct {
// contains filtered or unexported fields
}
func (*OpStackENRData) ENRKey ¶
func (o *OpStackENRData) ENRKey() string
type PeerDialer ¶
type PeerDialer struct {
// contains filtered or unexported fields
}
PeerDialer is a suture service that reads peers from the peerChan (which is filled by the Discovery service until that peerChan channel is closed. When PeerDialer sees a new peer, it does a few sanity checks and tries to establish a connection.
type PubSubConfig ¶
type PubSubConfig struct {
ChainID int
BlockTopics []string
DataStream host.DataStream
}
func (PubSubConfig) Validate ¶
func (p PubSubConfig) Validate() error