Documentation ¶
Index ¶
- Variables
- type PeerConnectionState
- type PeerData
- type Store
- func (s *Store) Config() *StoreConfig
- func (s *Store) DeletePeerData(pid peer.ID)
- func (s *Store) DeleteTrustedPeers(peers []peer.ID)
- func (s *Store) GetTrustedPeers() []peer.ID
- func (s *Store) IsTrustedPeer(p peer.ID) bool
- func (s *Store) PeerData(pid peer.ID) (*PeerData, bool)
- func (s *Store) PeerDataGetOrCreate(pid peer.ID) *PeerData
- func (s *Store) Peers() map[peer.ID]*PeerData
- func (s *Store) SetPeerData(pid peer.ID, data *PeerData)
- func (s *Store) SetTrustedPeers(peers []peer.ID)
- type StoreConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPeerUnknown is returned when there is an attempt to obtain data from a peer that is not known. ErrPeerUnknown = errors.New("peer unknown") // ErrNoPeerStatus is returned when there is a map entry for a given peer but there is no chain // status for that peer. This should happen in rare circumstances only, but is a very possible // scenario in a chaotic and adversarial network. ErrNoPeerStatus = errors.New("no chain status for peer") )
Functions ¶
This section is empty.
Types ¶
type PeerConnectionState ¶
type PeerConnectionState zondpb.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 metadata.Metadata ChainState *zondpb.Status ChainStateLastUpdated time.Time ChainStateValidationError error // Scorers internal data. BadResponses int ProcessedBlocks uint64 BlockProviderUpdated time.Time // Gossip Scoring data. TopicScores map[string]*zondpb.TopicScoreSnapshot GossipScore float64 BehaviourPenalty float64 }
PeerData aggregates protocol and application level info about a single peer.
type Store ¶
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 ¶
DeletePeerData removes data associated with a given peer. Important: it is assumed that store mutex is locked when calling this method.
func (*Store) DeleteTrustedPeers ¶
DeleteTrustedPeers removes peers from trusted peer set. Important: it is assumed that store mutex is locked when calling this method.
func (*Store) GetTrustedPeers ¶
GetTrustedPeers gets our desired trusted peer ids. Important: it is assumed that store mutex is locked when calling this method.
func (*Store) IsTrustedPeer ¶
IsTrustedPeer checks that the provided peer is in our trusted peer set.
func (*Store) PeerData ¶
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 ¶
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 ¶
Peers returns map of peer data objects. Important: it is assumed that store mutex is locked when calling this method.
func (*Store) SetPeerData ¶
SetPeerData updates data associated with a given peer. Important: it is assumed that store mutex is locked when calling this method.
func (*Store) SetTrustedPeers ¶
SetTrustedPeers sets our desired trusted peer set. 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.