Documentation
¶
Index ¶
- Constants
- Variables
- type CBOR
- type CBORMarshalUnmarshaler
- type Discovery
- type DiscoveryConfig
- type EncodeDecoder
- type Node
- func (n *Node) CanSubscribe(topic string) bool
- func (n *Node) Connected(net network.Network, c network.Conn)
- func (n *Node) Disconnected(net network.Network, c network.Conn)
- func (n *Node) FilterIncomingSubscriptions(id peer.ID, subs []*pubsubpb.RPC_SubOpts) ([]*pubsubpb.RPC_SubOpts, error)
- func (n *Node) Listen(net network.Network, maddr ma.Multiaddr)
- func (n *Node) ListenClose(net network.Network, maddr ma.Multiaddr)
- func (n *Node) OnEvent(cb func(ctx context.Context, event *host.TraceEvent))
- func (n *Node) Start(ctx context.Context) error
- type NodeConfig
- type PubSub
- type PubSubConfig
- type TopicConfig
- type ZSTD
Constants ¶
const ( GossipScoreThreshold = -500 PublishScoreThreshold = -1000 GraylistScoreThreshold = -2500 AcceptPXScoreThreshold = 1000 OpportunisticGraftScoreThreshold = 3.5 )
Borrowed from lotus
Variables ¶
var ( GPBFTMessageIdFn = pubsubMsgIdHashData ChainExchangeMessageIdFn = pubsubMsgIdHashData )
var PubsubPeerScoreParams = &pubsub.PeerScoreParams{ AppSpecificScore: func(p peer.ID) float64 { return 0 }, AppSpecificWeight: 1, IPColocationFactorThreshold: 5, IPColocationFactorWeight: -100, IPColocationFactorWhitelist: nil, BehaviourPenaltyThreshold: 6, BehaviourPenaltyWeight: -10, BehaviourPenaltyDecay: pubsub.ScoreParameterDecay(time.Hour), DecayInterval: pubsub.DefaultDecayInterval, DecayToZero: pubsub.DefaultDecayToZero, RetainScore: 6 * time.Hour, Topics: make(map[string]*pubsub.TopicScoreParams), }
Borrowed from lotus
var PubsubPeerScoreThresholds = &pubsub.PeerScoreThresholds{ GossipThreshold: GossipScoreThreshold, PublishThreshold: PublishScoreThreshold, GraylistThreshold: GraylistScoreThreshold, AcceptPXThreshold: AcceptPXScoreThreshold, OpportunisticGraftThreshold: OpportunisticGraftScoreThreshold, }
var PubsubTopicScoreParams = &pubsub.TopicScoreParams{ TopicWeight: 0.1, TimeInMeshWeight: 0.0002778, TimeInMeshQuantum: time.Second, TimeInMeshCap: 1, FirstMessageDeliveriesWeight: 0.5, FirstMessageDeliveriesDecay: pubsub.ScoreParameterDecay(10 * time.Minute), FirstMessageDeliveriesCap: 100, InvalidMessageDeliveriesWeight: -1000, InvalidMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Hour), }
Borrowed from lotus
Functions ¶
This section is empty.
Types ¶
type CBOR ¶
type CBOR[T CBORMarshalUnmarshaler] struct{}
func NewCBOR ¶
func NewCBOR[T CBORMarshalUnmarshaler]() *CBOR[T]
type CBORMarshalUnmarshaler ¶
type CBORMarshalUnmarshaler interface {
cbg.CBORMarshaler
cbg.CBORUnmarshaler
}
type Discovery ¶
type Discovery struct {
// Metrics
MeterLookups metric.Int64Counter
// contains filtered or unexported fields
}
func NewDiscovery ¶
func NewDiscovery(h host.Host, cfg *DiscoveryConfig) (*Discovery, error)
type DiscoveryConfig ¶
type EncodeDecoder ¶
type EncodeDecoder[T CBORMarshalUnmarshaler] interface { Encode(v T) ([]byte, error) Decode([]byte, T) error }
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
Bootstrappers []peer.AddrInfo
// General timeout when communicating with other network participants
DialTimeout time.Duration
// Topic configurations to subscribe to
TopicConfigs map[string]*TopicConfig
// The address information of the local libp2p host
Libp2pHost string
Libp2pPort int
Libp2pPeerscoreSnapshotFreq time.Duration
// The size of the validate queue
PubSubValidateQueueSize int
// PeerFilter configuration for filtering peers (passed to host)
PeerFilter *host.FilterConfig
DirectConnections []string
// Whether to enable the periodic lookups
DiscoveryActorEnabled bool
// 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 PubSubConfig ¶
type PubSubConfig struct {
TopicConfigs map[string]*TopicConfig
DataStream host.DataStream
}
func (PubSubConfig) Validate ¶
func (p PubSubConfig) Validate() error
type TopicConfig ¶
type TopicConfig struct {
ScoreParams *pubsub.TopicScoreParams
Options []pubsub.TopicOpt
}
type ZSTD ¶
type ZSTD[T CBORMarshalUnmarshaler] struct { // contains filtered or unexported fields }
func NewZSTD ¶
func NewZSTD[T CBORMarshalUnmarshaler]() (*ZSTD[T], error)