engine: tag peers based on usefulness
This patch tracks two usefulness metrics: short-term usefulness and long-term usefulness. Short-term usefulness is sampled frequently and highly weights new observations. Long-term usefulness is sampled less frequently and highly weights on long-term trends. In practice, we do this by keeping two EWMAs. If we see an interaction within the sampling period, we record the score, otherwise, we record a 0. The short-term one has a high alpha and is sampled every shortTerm period. The long-term one has a low alpha and is sampled every longTermRatio*shortTerm period. To calculate the final score, we sum the short-term and long-term scores then adjust it ±25% based on our debt ratio. Peers that have historically been more useful to us than we are to them get the highest score.
Showing
decision/ewma.go
0 → 100644
... | ... | @@ -7,7 +7,6 @@ require ( |
github.com/gogo/protobuf v1.2.1 | ||
github.com/golang/protobuf v1.3.1 // indirect | ||
github.com/google/uuid v1.1.1 | ||
github.com/hashicorp/golang-lru v0.5.1 | ||
github.com/ipfs/go-block-format v0.0.2 | ||
github.com/ipfs/go-cid v0.0.2 | ||
github.com/ipfs/go-datastore v0.0.5 | ||
... | ... | @@ -38,3 +37,5 @@ require ( |
golang.org/x/text v0.3.2 // indirect | ||
gopkg.in/yaml.v2 v2.2.2 // indirect | ||
) | ||
go 1.12 |
Please register or sign in to comment