From a889ccc06844abc7d70c69de7f9393c0c6cdff6f Mon Sep 17 00:00:00 2001 From: Ganesha Upadhyaya Date: Wed, 11 Oct 2023 16:05:13 -0500 Subject: [PATCH] add peer tracker and metrics --- p2p/p2p.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/p2p/p2p.md b/p2p/p2p.md index d1d52081..ca4aa3e9 100644 --- a/p2p/p2p.md +++ b/p2p/p2p.md @@ -42,11 +42,18 @@ Exchange defines a client for requesting headers from the p2p network. An exchan #### Peer Tracker -//TODO +The three main functionalities of the peer tracker are: +* bootstrap +* track +* gc -#### Trusted Peers vs Tracked Peers +When the exchange client is started, it bootstraps the peer tracker using the set of trusted peers used to initialize the exchange client. -//TODO +The new peers are tracked by subscribing to `event.EvtPeerConnectednessChanged{}`. + +The peer tracker also runs garbage collector (gc) that removes the disconnected peers (determined as disconnected for more than `maxAwaitingTime` or connected peers whose scores are less than or equal to `defaultScore`) from the tracked peers list once every `gcPeriod`. + +The peer tracker also provides a block peer functionality which is used to block peers that send invalid network headers. Invalid header is a header that fails when `Verify` method of the header interface is invoked. The exchange client implements the following interface: @@ -190,7 +197,11 @@ func DefaultClientParameters() ClientParameters { ## Metrics -//TODO +Currently only following metrics are collected: +* P2P header exchange response size +* Duration of the get headers request in seconds +* Total synced headers + # References