les, les/lespay: implement new server pool (#20758)
This PR reimplements the light client server pool. It is also a first step to move certain logic into a new lespay package. This package will contain the implementation of the lespay token sale functions, the token buying and selling logic and other components related to peer selection/prioritization and service quality evaluation. Over the long term this package will be reusable for incentivizing future protocols. Since the LES peer logic is now based on enode.Iterator, it can now use DNS-based fallback discovery to find servers. This document describes the function of the new components: https://gist.github.com/zsfelfoldi/3c7ace895234b7b345ab4f71dab102d4
This commit is contained in:
@@ -63,14 +63,7 @@ func ExpFactor(logOffset Fixed64) ExpirationFactor {
|
||||
// Value calculates the expired value based on a floating point base and integer
|
||||
// power-of-2 exponent. This function should be used by multi-value expired structures.
|
||||
func (e ExpirationFactor) Value(base float64, exp uint64) float64 {
|
||||
res := base / e.Factor
|
||||
if exp > e.Exp {
|
||||
res *= float64(uint64(1) << (exp - e.Exp))
|
||||
}
|
||||
if exp < e.Exp {
|
||||
res /= float64(uint64(1) << (e.Exp - exp))
|
||||
}
|
||||
return res
|
||||
return base / e.Factor * math.Pow(2, float64(int64(exp-e.Exp)))
|
||||
}
|
||||
|
||||
// value calculates the value at the given moment.
|
||||
|
Reference in New Issue
Block a user