Skip to content

Commit

Permalink
add peer tracker and metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganesha Upadhyaya authored and Ganesha Upadhyaya committed Oct 11, 2023
1 parent 8b8d563 commit 6bb0b61
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions p2p/p2p.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 6bb0b61

Please sign in to comment.