peerdata

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPeerUnknown is returned when there is an attempt to obtain data from a peer that is not known.
	ErrPeerUnknown = errors.New("peer unknown")
)

Functions

This section is empty.

Types

type PeerConnectionState

type PeerConnectionState ethpb.ConnectionState

PeerConnectionState is the state of the connection.

type PeerData

type PeerData struct {
	// Network related data.
	Address       ma.Multiaddr
	Direction     network.Direction
	ConnState     PeerConnectionState
	Enr           *enr.Record
	NextValidTime time.Time
	// Chain related data.
	MetaData                  interfaces.Metadata
	ChainState                *pb.Status
	ChainStateLastUpdated     time.Time
	ChainStateValidationError error
	// Scorers internal data.
	BadResponses         int
	ProcessedBlocks      uint64
	BlockProviderUpdated time.Time
	// Gossip Scoring data.
	TopicScores      map[string]*pbrpc.TopicScoreSnapshot
	GossipScore      float64
	BehaviourPenalty float64
}

PeerData aggregates protocol and application level info about a single peer.

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Store is a container for various peer related data (both protocol and app level). Container implements RWMutex, so data access can be restricted on the container level. This allows different components rely on the very same peer map container. Note: access to data is controlled by clients i.e. client code is responsible for locking/unlocking the mutex when accessing data.

func NewStore

func NewStore(ctx context.Context, config *StoreConfig) *Store

NewStore creates new peer data store.

func (*Store) Config

func (s *Store) Config() *StoreConfig

Config exposes store configuration params.

func (*Store) DeletePeerData

func (s *Store) DeletePeerData(pid peer.ID)

DeletePeerData removes data associated with a given peer. Important: it is assumed that store mutex is locked when calling this method.

func (*Store) PeerData

func (s *Store) PeerData(pid peer.ID) (*PeerData, bool)

PeerData returns data associated with a given peer, if any. Important: it is assumed that store mutex is locked when calling this method.

func (*Store) PeerDataGetOrCreate

func (s *Store) PeerDataGetOrCreate(pid peer.ID) *PeerData

PeerDataGetOrCreate returns data associated with a given peer. If no data has been associated yet, newly created and associated data object is returned. Important: it is assumed that store mutex is locked when calling this method.

func (*Store) Peers

func (s *Store) Peers() map[peer.ID]*PeerData

Peers returns map of peer data objects. Important: it is assumed that store mutex is locked when calling this method.

func (*Store) SetPeerData

func (s *Store) SetPeerData(pid peer.ID, data *PeerData)

SetPeerData updates data associated with a given peer. Important: it is assumed that store mutex is locked when calling this method.

type StoreConfig

type StoreConfig struct {
	MaxPeers int
}

StoreConfig holds peer store parameters.

Jump to

Keyboard shortcuts

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