store

package
v1.5.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT, MIT Imports: 18 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UnknownBanErr = errors.New("unknown ban")
View Source
var UnknownRecordErr = errors.New("unknown record")

Functions

This section is empty.

Types

type DecayApplicationScores added in v1.1.2

type DecayApplicationScores struct {
	ValidResponseDecay   float64
	ErrorResponseDecay   float64
	RejectedPayloadDecay float64
	DecayToZero          float64
}

func (*DecayApplicationScores) Apply added in v1.1.2

func (d *DecayApplicationScores) Apply(rec *scoreRecord)

type ExtendedPeerstore

ExtendedPeerstore defines a type-safe API to work with additional peer metadata based on a libp2p peerstore.Peerstore

func NewExtendedPeerstore

func NewExtendedPeerstore(ctx context.Context, logger log.Logger, clock clock.Clock, ps peerstore.Peerstore, store ds.Batching, scoreRetention time.Duration) (ExtendedPeerstore, error)

type GossipScores added in v1.1.2

type GossipScores struct {
	Total              float64     `json:"total"`
	Blocks             TopicScores `json:"blocks"` // fully zeroed if the peer has not been in the mesh on the topic
	IPColocationFactor float64     `json:"IPColocationFactor"`
	BehavioralPenalty  float64     `json:"behavioralPenalty"`
}

func (GossipScores) Apply added in v1.1.2

func (g GossipScores) Apply(rec *scoreRecord)

type IPBanStore added in v1.1.2

type IPBanStore interface {
	// SetIPBanExpiration create the IP ban with expiration time.
	// If expiry == time.Time{} then the ban is deleted.
	SetIPBanExpiration(ip net.IP, expiry time.Time) error
	// GetIPBanExpiration gets the IP ban expiration time, or UnknownBanErr error if none exists.
	GetIPBanExpiration(ip net.IP) (time.Time, error)
}

type IncrementErrorResponses added in v1.1.2

type IncrementErrorResponses struct {
	Cap float64
}

func (IncrementErrorResponses) Apply added in v1.1.2

func (i IncrementErrorResponses) Apply(rec *scoreRecord)

type IncrementRejectedPayloads added in v1.1.2

type IncrementRejectedPayloads struct {
	Cap float64
}

func (IncrementRejectedPayloads) Apply added in v1.1.2

func (i IncrementRejectedPayloads) Apply(rec *scoreRecord)

type IncrementValidResponses added in v1.1.2

type IncrementValidResponses struct {
	Cap float64
}

func (IncrementValidResponses) Apply added in v1.1.2

func (i IncrementValidResponses) Apply(rec *scoreRecord)

type MetadataStore added in v1.4.2

type MetadataStore interface {
	// SetPeerMetadata sets the metadata for the specified peer
	SetPeerMetadata(id peer.ID, md PeerMetadata) (PeerMetadata, error)
	// GetPeerMetadata returns the metadata for the specified peer
	GetPeerMetadata(id peer.ID) (PeerMetadata, error)
}

type PeerBanStore added in v1.1.2

type PeerBanStore interface {
	// SetPeerBanExpiration create the peer ban with expiration time.
	// If expiry == time.Time{} then the ban is deleted.
	SetPeerBanExpiration(id peer.ID, expiry time.Time) error
	// GetPeerBanExpiration gets the peer ban expiration time, or UnknownBanErr error if none exists.
	GetPeerBanExpiration(id peer.ID) (time.Time, error)
}

type PeerMetadata added in v1.4.2

type PeerMetadata struct {
	ENR       string `json:"enr"`
	OPStackID uint64 `json:"opStackID"`
}

type PeerScores

type PeerScores struct {
	Gossip  GossipScores  `json:"gossip"`
	ReqResp ReqRespScores `json:"reqResp"`
}

type ReqRespScores added in v1.1.2

type ReqRespScores struct {
	ValidResponses   float64 `json:"validResponses"`
	ErrorResponses   float64 `json:"errorResponses"`
	RejectedPayloads float64 `json:"rejectedPayloads"`
}

type ScoreDatastore

type ScoreDatastore interface {
	// GetPeerScores returns the current scores for the specified peer
	GetPeerScores(id peer.ID) (PeerScores, error)

	// GetPeerScore returns the current combined score for the specified peer
	GetPeerScore(id peer.ID) (float64, error)

	// SetScore applies the given store diff to the specified peer
	SetScore(id peer.ID, diff ScoreDiff) (PeerScores, error)
}

ScoreDatastore defines a type-safe API for getting and setting libp2p peer score information

type ScoreDiff added in v1.1.2

type ScoreDiff interface {
	Apply(score *scoreRecord)
}

ScoreDiff defines a type-safe batch of changes to apply to the peer-scoring record of the peer. The scoreRecord the diff is applied to is private: diffs can only be defined in this package, to ensure changes to the record are non-breaking.

type TopicScores added in v1.1.2

type TopicScores struct {
	TimeInMesh               float64 `json:"timeInMesh"` // in seconds
	FirstMessageDeliveries   float64 `json:"firstMessageDeliveries"`
	MeshMessageDeliveries    float64 `json:"meshMessageDeliveries"`
	InvalidMessageDeliveries float64 `json:"invalidMessageDeliveries"`
}

Jump to

Keyboard shortcuts

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