Documentation
¶
Index ¶
- Constants
- func EventTypeFromBeaconChainProtocol(protocol string) string
- func MaddrFrom(ip string, port uint) (ma.Multiaddr, error)
- func NoopHandler(ctx context.Context, msg *pubsub.Message) error
- type CallbackDataStream
- func (c *CallbackDataStream) OnEvent(onRecord func(ctx context.Context, event *TraceEvent))
- func (c *CallbackDataStream) OutputType() DataStreamOutputType
- func (c *CallbackDataStream) PutRecord(ctx context.Context, event *TraceEvent) error
- func (c *CallbackDataStream) Start(ctx context.Context) error
- func (c *CallbackDataStream) Stop(ctx context.Context) error
- func (c *CallbackDataStream) Type() DataStreamType
- type Config
- type DataStream
- type DataStreamOutputType
- type DataStreamRenderer
- type DataStreamType
- type Host
- func (h *Host) AddPeer(p peer.ID, proto protocol.ID)
- func (h *Host) AgentVersion(pid peer.ID) string
- func (h *Host) ConnSignal(ctx context.Context, pid peer.ID) chan error
- func (h *Host) DeliverMessage(msg *pubsub.Message)
- func (h *Host) DropRPC(rpc *pubsub.RPC, p peer.ID)
- func (h *Host) DuplicateMessage(msg *pubsub.Message)
- func (h *Host) FlushTrace(evtType string, payload any)
- func (h *Host) FlushTraceWithTimestamp(evtType string, timestamp time.Time, payload any)
- func (h *Host) Graft(p peer.ID, topic string)
- func (h *Host) InitGossipSub(ctx context.Context, opts ...pubsub.Option) (*pubsub.PubSub, error)
- func (h *Host) Join(topic string)
- func (h *Host) Leave(topic string)
- func (h *Host) LocalListenMaddr() (ma.Multiaddr, error)
- func (h *Host) PrivateListenMaddr() (ma.Multiaddr, error)
- func (h *Host) Prune(p peer.ID, topic string)
- func (h *Host) RecvRPC(rpc *pubsub.RPC)
- func (h *Host) RejectMessage(msg *pubsub.Message, reason string)
- func (h *Host) RemovePeer(p peer.ID)
- func (h *Host) SendRPC(rpc *pubsub.RPC, p peer.ID)
- func (h *Host) Serve(ctx context.Context) error
- func (h *Host) ThrottlePeer(p peer.ID)
- func (h *Host) Trace(evt *pubsubpb.TraceEvent)
- func (h *Host) TracedTopicHandler(handler TopicHandler) TopicHandler
- func (h *Host) UndeliverableMessage(msg *pubsub.Message)
- func (h *Host) UpdatePeerScore(scores map[peer.ID]*pubsub.PeerScoreSnapshot)
- func (h *Host) ValidateMessage(msg *pubsub.Message)
- func (h *Host) WaitForPublicAddress(ctx context.Context) error
- type KinesisDataStream
- func (k *KinesisDataStream) OutputType() DataStreamOutputType
- func (k *KinesisDataStream) PutRecord(ctx context.Context, event *TraceEvent) error
- func (k *KinesisDataStream) Start(ctx context.Context) error
- func (k *KinesisDataStream) Stop(ctx context.Context) error
- func (k *KinesisDataStream) Type() DataStreamType
- type RpcControlGraft
- type RpcControlIHave
- type RpcControlIWant
- type RpcControlIdontWant
- type RpcControlPrune
- type RpcMeta
- type RpcMetaControl
- type RpcMetaMsg
- type RpcMetaSub
- type ScoreKeeper
- type TopicHandler
- type TopicScore
- type TopicSubscription
- type TraceEvent
- type TraceEventPayloadMetaData
- type TraceEventPeerScore
- type TraceLogger
Constants ¶
const PeerScoreEventType = "PEERSCORE"
Variables ¶
This section is empty.
Functions ¶
func EventTypeFromBeaconChainProtocol ¶
EventTypeFromBeaconChainProtocol returns the event type for a given protocol string.
Types ¶
type CallbackDataStream ¶
type CallbackDataStream struct {
// contains filtered or unexported fields
}
CallbackDataStream is a simple implementation of DataStream that holds a callback function. Users of CallbackDataStream should ensure that the callback function does not block, as blocking can delay or disrupt the processing of subsequent events.
func NewCallbackDataStream ¶
func NewCallbackDataStream() *CallbackDataStream
NewCallbackDataStream creates a new instance of CallbackDataStream.
func (*CallbackDataStream) OnEvent ¶
func (c *CallbackDataStream) OnEvent(onRecord func(ctx context.Context, event *TraceEvent))
OnEvent sets the callback function that will be called when an event is received.
func (*CallbackDataStream) OutputType ¶
func (c *CallbackDataStream) OutputType() DataStreamOutputType
OutputType returns the output type to be used by this data stream.
func (*CallbackDataStream) PutRecord ¶
func (c *CallbackDataStream) PutRecord(ctx context.Context, event *TraceEvent) error
PutRecord sends an event to the callback if the stream has not been stopped.
func (*CallbackDataStream) Start ¶
func (c *CallbackDataStream) Start(ctx context.Context) error
Start begins the data stream's operations.
func (*CallbackDataStream) Stop ¶
func (c *CallbackDataStream) Stop(ctx context.Context) error
Stop ends the data stream's operation.
func (*CallbackDataStream) Type ¶
func (c *CallbackDataStream) Type() DataStreamType
Type returns the type of the data stream, which is DataStreamTypeCallback.
type DataStream ¶
type DataStream interface { Start(ctx context.Context) error Stop(ctx context.Context) error PutRecord(ctx context.Context, event *TraceEvent) error Type() DataStreamType OutputType() DataStreamOutputType }
type DataStreamOutputType ¶
type DataStreamOutputType int
DataStreamOutputType is the output type of the data stream.
const ( // DataStreamOutputTypeKinesis outputs the data stream decorated with metadata and in a format ingested by Kinesis. DataStreamOutputTypeKinesis DataStreamOutputType = iota // DataStreamOutputTypeFull outputs the data stream decorated with metadata and containing the raw/full event data. DataStreamOutputTypeFull )
type DataStreamRenderer ¶
type DataStreamRenderer interface {
RenderPayload(evt *TraceEvent, msg *pubsub.Message, dst ssz.Unmarshaler) (*TraceEvent, error)
}
DataStreamRenderer is an interface to support rendering a data-stream message into a destination.
type DataStreamType ¶
type DataStreamType int
const ( DataStreamTypeKinesis DataStreamType = iota DataStreamTypeCallback DataStreamTypeLogger )
func DataStreamtypeFromStr ¶
func DataStreamtypeFromStr(str string) DataStreamType
func (DataStreamType) String ¶
func (ds DataStreamType) String() string
type Host ¶
func (*Host) AgentVersion ¶
AgentVersion returns the agent version of the given peer. If the agent version is not known, it returns an empty string.
func (*Host) ConnSignal ¶
ConnSignal signals the incoming connection of the given peer on the returned channel by just closing it. Alternatively, if the context has a deadline that's exceeded, the channel will emit the context error and then be closed.
func (*Host) DeliverMessage ¶
func (*Host) DuplicateMessage ¶
func (*Host) FlushTrace ¶
func (*Host) FlushTraceWithTimestamp ¶
func (*Host) InitGossipSub ¶
func (*Host) LocalListenMaddr ¶
LocalListenMaddr returns the first multiaddress in a localhost IP range that this host is listening on.
func (*Host) PrivateListenMaddr ¶
PrivateListenMaddr returns the first multiaddress in a private IP range that this host is listening on.
func (*Host) RemovePeer ¶
func (*Host) ThrottlePeer ¶
func (*Host) Trace ¶
func (h *Host) Trace(evt *pubsubpb.TraceEvent)
func (*Host) TracedTopicHandler ¶
func (h *Host) TracedTopicHandler(handler TopicHandler) TopicHandler
func (*Host) UndeliverableMessage ¶
func (*Host) UpdatePeerScore ¶
func (h *Host) UpdatePeerScore(scores map[peer.ID]*pubsub.PeerScoreSnapshot)
func (*Host) ValidateMessage ¶
type KinesisDataStream ¶
type KinesisDataStream struct {
// contains filtered or unexported fields
}
func NewKinesisDataStream ¶
func NewKinesisDataStream(p *gk.Producer) *KinesisDataStream
NewKinesisDataStream creates a new instance of KinesisDataStream with a given producer.
func (*KinesisDataStream) OutputType ¶
func (k *KinesisDataStream) OutputType() DataStreamOutputType
OutputType returns the output type to be used by this data stream.
func (*KinesisDataStream) PutRecord ¶
func (k *KinesisDataStream) PutRecord(ctx context.Context, event *TraceEvent) error
PutRecord sends an event to the Kinesis data stream.
func (*KinesisDataStream) Start ¶
func (k *KinesisDataStream) Start(ctx context.Context) error
Start begins the data stream's operation.
func (*KinesisDataStream) Stop ¶
func (k *KinesisDataStream) Stop(ctx context.Context) error
Stop ends the data stream.
func (*KinesisDataStream) Type ¶
func (k *KinesisDataStream) Type() DataStreamType
Type returns the type of the data stream
type RpcControlGraft ¶
type RpcControlGraft struct {
TopicID string
}
type RpcControlIHave ¶
type RpcControlIWant ¶
type RpcControlIWant struct {
MsgIDs []string
}
type RpcControlIdontWant ¶
type RpcControlIdontWant struct {
MsgIDs []string
}
type RpcControlPrune ¶
type RpcMeta ¶
type RpcMeta struct { PeerID peer.ID Subscriptions []RpcMetaSub `json:"Subs,omitempty"` Messages []RpcMetaMsg `json:"Msgs,omitempty"` Control *RpcMetaControl `json:"Control,omitempty"` }
type RpcMetaControl ¶
type RpcMetaControl struct { IHave []RpcControlIHave `json:"IHave,omitempty"` IWant []RpcControlIWant `json:"IWant,omitempty"` Graft []RpcControlGraft `json:"Graft,omitempty"` Prune []RpcControlPrune `json:"Prune,omitempty"` Idontwant []RpcControlIdontWant `json:"Idontwant,omitempty"` }
type RpcMetaMsg ¶
type RpcMetaSub ¶
type ScoreKeeper ¶
type ScoreKeeper struct {
// contains filtered or unexported fields
}
ScoreKeeper is a thread-safe local copy of the score per peer and per copy TODO: figure out if this is some sort of info that we want to expose through OpenTelemetry (Still good to have it)
func (*ScoreKeeper) Get ¶
func (sk *ScoreKeeper) Get() map[peer.ID]*pubsub.PeerScoreSnapshot
func (*ScoreKeeper) Update ¶
func (sk *ScoreKeeper) Update(scores map[peer.ID]*pubsub.PeerScoreSnapshot)
type TopicScore ¶
type TopicSubscription ¶
type TopicSubscription struct { Topic string LocalID peer.ID Sub *pubsub.Subscription Handler TopicHandler }
type TraceEvent ¶
type TraceEvent struct { Type string Topic string PeerID peer.ID Timestamp time.Time Payload any `json:"Data"` // cannot use field "Data" because of gk.Record method }
func (*TraceEvent) Data ¶
func (t *TraceEvent) Data() []byte
func (*TraceEvent) ExplicitHashKey ¶
func (t *TraceEvent) ExplicitHashKey() *string
func (*TraceEvent) PartitionKey ¶
func (t *TraceEvent) PartitionKey() string
type TraceEventPeerScore ¶
type TraceLogger ¶
type TraceLogger struct{}
func (*TraceLogger) OutputType ¶
func (t *TraceLogger) OutputType() DataStreamOutputType
OutputType returns the output type to be used by this data stream.
func (*TraceLogger) PutRecord ¶
func (t *TraceLogger) PutRecord(ctx context.Context, event *TraceEvent) error
func (*TraceLogger) Type ¶
func (t *TraceLogger) Type() DataStreamType