Documentation
¶
Index ¶
- Variables
- func ParseInterfaceMapMessageMetrics(inputMap map[string]interface{}) (map[string]MessageMetric, error)
- type BeaconMetadataStamped
- type BeaconStatusStamped
- type ClientDiversity
- type MessageMetric
- type Peer
- func (pm *Peer) AddMAddr(input_addr string) error
- func (pm *Peer) AddNegConnAtt(deprecated bool, err string)
- func (pm *Peer) AddPositiveConnAttempt()
- func (pm *Peer) CheckIfPeerRealConnect() bool
- func (pm *Peer) ConnectionEvent(direction string, time time.Time)
- func (pm *Peer) DisconnectionEvent(time time.Time)
- func (pm *Peer) ExtractPublicAddr() ma.Multiaddr
- func (pm *Peer) FetchAttFromNewPeer(newPeer Peer)
- func (pm *Peer) FetchBasicHostInfoFromNewPeer(newPeer Peer)
- func (pm *Peer) FetchConnectionsFromNewPeer(newPeer Peer)
- func (pm *Peer) FetchPeerInfoFromNewPeer(newPeer Peer)
- func (pm Peer) FirstNegAttempt() (t time.Time, err error)
- func (pm *Peer) GetAllMessagesCount() uint64
- func (pm *Peer) GetAtt(key string) (interface{}, bool)
- func (pm *Peer) GetConnectedTime() float64
- func (pm Peer) GetLastActivityTime() time.Time
- func (pm *Peer) GetLastErrors() []string
- func (pm *Peer) GetNumOfMsgFromTopic(shortTopic string) uint64
- func (pm Peer) IsDeprecated() bool
- func (pm *Peer) IsEmpty() bool
- func (pm Peer) LastNegAttempt() (t time.Time, err error)
- func (pm *Peer) LogPeer()
- func (pm *Peer) MessageEvent(topicName string, time time.Time)
- func (pm *Peer) MetadataEvent(success bool)
- func (pm *Peer) ResetDynamicMetrics()
- func (pm *Peer) SetAtt(key string, value interface{})
- func (pm *Peer) ToCsvLine() string
Constants ¶
This section is empty.
Variables ¶
var ( MaxArraySize int = 10 ModuleName string = "Peer" )
Functions ¶
func ParseInterfaceMapMessageMetrics ¶
func ParseInterfaceMapMessageMetrics(inputMap map[string]interface{}) (map[string]MessageMetric, error)
----- Deprecated Since the integration of PSQL as DB ----
ParseInterfaceMapMessageMetrics: Parse the inputMap into the MessageMetric format @param inputMap: a map of string interface @return a map of string MessageMetric
Types ¶
type BeaconMetadataStamped ¶
Basic BeaconMetadata struct that includes the timestamp of the received beacon metadata
func NewBeaconMetadata ¶
func NewBeaconMetadata(bMetadata common.MetaData) BeaconMetadataStamped
UpdateBeaconMetadata: Update beacon Metadata of the peer. @param bMetadata: the Metadata object used to update the data
func (*BeaconMetadataStamped) IsEmpty ¶
func (b *BeaconMetadataStamped) IsEmpty() bool
type BeaconStatusStamped ¶
Basic BeaconMetadata struct that includes The timestamp of the received beacon Status
func NewBeaconStatus ¶
func NewBeaconStatus(bStatus common.Status) BeaconStatusStamped
UpdateBeaconStatus: Update beacon Status of the peer. @param bStatus: the Status object used to update the data
func ParseBeaconStatusFromInterface ¶
func ParseBeaconStatusFromInterface(input interface{}) (BeaconStatusStamped, error)
ParseBeaconStatusFromInterface: Parse the inputMap into the BeaconStatusStamped format @param inputMap: a map of string interface @return a map of string BeaconStatusStamped
func (*BeaconStatusStamped) IsEmpty ¶
func (b *BeaconStatusStamped) IsEmpty() bool
type ClientDiversity ¶
type ClientDiversity struct { Timestamp time.Time `json:"snapshot_timestamp"` Prysm int `json:"prysm"` Lighthouse int `json:"lighthouse"` Teku int `json:"teku"` Nimbus int `json:"nimbus"` Grandine int `json:"grandine"` Lodestar int `json:"lodestar"` Others int `json:"others"` }
func NewClientDiversity ¶
func NewClientDiversity() ClientDiversity
type MessageMetric ¶
Information regarding the messages received on a given topic
type Peer ¶
type Peer struct { // PeerBASICS PeerId string UserAgent string ClientName string ClientOS string //TODO: ClientVersion string // PeerNetwork Ip string Country string CountryCode string City string Latency float64 MAddrs []ma.Multiaddr Protocols []string ProtocolVersion string // PeerMetrics ConnectedDirection []string // The directions of each connection event. IsConnected bool // If the peer is connected (CheckIfRealConnect). Attempted bool // If the peer has been attempted to stablish a connection. Succeed bool // If the connection attempt (outbound) has been successful. Attempts uint64 // Number of attempts done. Error []string // List of errors (also adding "None" errors), aligned with connection events. LastErrorTimestamp time.Time // Timestamp of the last error reported for this peer. Deprecated bool // Flag to rummarize whether the peer is still valid for statistics or not. If true, the peer is not exported CSV / metrics. LastIdentifyTimestamp time.Time // Timestamp of the last time the peer was identified (get user agent...). NegativeConnAttempts []time.Time // List of dates when the peer retrieved a negative connection attempt (outbound) (if there is a possitive one, clean the array). ConnectionTimes []time.Time // List of registered connections events. DisconnectionTimes []time.Time // List of Disconnection Events. MetadataRequest bool // If the peer has been attempted to request its metadata. MetadataSucceed bool // If the peer has been successfully requested its metadata. LastExport int64 // Timestamp in seconds of the last exported time (backup for when we are loading the Peer). // Application layer / extra attributes Att map[string]interface{} // Message // Counters for the different topics MessageMetrics map[string]MessageMetric }
Stores all the information related to a peer
func (*Peer) AddMAddr ¶
AddAddr: This method adds a new multiaddress in string format to the MAddrs array. @return Any error. Otherwise nil.
func (*Peer) AddNegConnAtt ¶
AddNegConnAtt: This method will register a new negative connection attempt in the peer (outbound). @param deprecated: in case we want to activate the deprecation flag. @param err: error string to add to the peer error list.
func (*Peer) AddPositiveConnAttempt ¶
func (pm *Peer) AddPositiveConnAttempt()
AddPositiveConnAttempt: This method will register a new positive connection attempt in the peer (outbound).
func (*Peer) CheckIfPeerRealConnect ¶
CheckIfPeerRealConnect: This method will return whether the peer is currently connected or not. @return true if connected, false if not.
func (*Peer) ConnectionEvent ¶
ConnectionEvent: Register when a new connection was detected and the direction. @param direction: whether inbound or outbound. @param time: when the event happenned.
func (*Peer) DisconnectionEvent ¶
DisconnectionEvent: Register when a new disconnection was detected. @param time: when the event happenned.
func (*Peer) ExtractPublicAddr ¶
ExtractPublicMAddr: This method loops over all multiaddress and extract the first one that has a public IP. @return the found multiaddress, nil if error.
func (*Peer) FetchAttFromNewPeer ¶
FetchAttFromNewPeer: This method will read the custom attributes from the new peer and import them into our peer (pm). @param newPeer: the peer where to extract new information.
func (*Peer) FetchBasicHostInfoFromNewPeer ¶
FetchBasicHostInfoFromNewPeer: This method will read basic host info from the new peer and import it into our peer (pm). @param newPeer: the peer where to extract new information.
func (*Peer) FetchConnectionsFromNewPeer ¶
FetchConnectionsFromNewPeer: This method will read connections from the new peer and import it into our peer (pm). @param newPeer: the peer where to extract new information.
func (*Peer) FetchPeerInfoFromNewPeer ¶
FetchPeerInfoFromPeer: This method will read information from a new peer, and update the self (pm) peer with the new peer's attributes. Keep in mind that only fields which are not empty in the new peer will be overwriten in the old peer. @param newPeer: the peer from where to get new information and update the old one.
func (Peer) FirstNegAttempt ¶
FirstNegAttempt: This method will calculate the last negative attempt time. @return the time of the first negative connection attempt with this peer and and error if applicable.
func (*Peer) GetAllMessagesCount ¶
GetAllMessagesCount: Get total of messages received from that peer. @return a unit64 with the count.
func (*Peer) GetAtt ¶
GetAtt reads custom attribute from the att map, returns interface and status of the read
func (*Peer) GetConnectedTime ¶
GetConnectedTime: This method will calculate the total connected time based on con/disc timestamps. This means the total time that the peer has been connected. Shifted some calculus to nanoseconds. Millisecons were leaving fields empty when exporting (less that 3 decimals). @return the resulting time in float64 format.
func (Peer) GetLastActivityTime ¶
GetLastActivityTime: Calculates the last activity recorded for the peer. @return last activity recorded for the peer.
func (*Peer) GetLastErrors ¶
GetLastErrors: Returns the error in last position. The array also contains the same error if it was repeated consecutively. @return and array with the same error.
func (*Peer) GetNumOfMsgFromTopic ¶
GetNumOfMsgFromTopic: Get the number of messages that we got for a given topic. Note that the topic name is the shortened name i.e. BeaconBlock @param shortTopic: the topic to get count from. @return a uint64 with the total count.
func (Peer) IsDeprecated ¶
IsDeprecated: This method return the deprecated attirbute of the peer. @return true or false.
func (Peer) LastNegAttempt ¶
LastNegAttempt: This method will calculate the last negative attempt time. @return the time of the last negative connection attempt with this peer and and error if applicable.
func (*Peer) MessageEvent ¶
MessageEvent: Add one to the message count for the given topic. Also update the LastMessageTime. @param topicName: the topic to add a message on. @param time: when it was received.
func (*Peer) MetadataEvent ¶
MetadataEvent: Add a Metadata Event to the given peer (successful or not). @param success: whether successful (to identify the peer) or not.
func (*Peer) ResetDynamicMetrics ¶
func (pm *Peer) ResetDynamicMetrics()
ResetDynamicMetrics: It will reset the metrics by reinstancing the map.