k-choices cost calculation for departure cost

This commit is contained in:
Trolli Schmittlauch 2020-10-05 22:48:56 +02:00
parent 5ed8a28fde
commit ecb127e6af

View file

@ -305,13 +305,23 @@ kChoicesVsJoin queryVsSTM bootstrapNode capacity activeVss nodeSTM remainingTarg
kChoicesJoinCost :: Double -- ^ own remaining load target
-> Double -- ^ own capacity
-> SegmentLoadStats
-> SegmentLoadStats -- ^ load stats of neighbour vs
-> Double
kChoicesJoinCost remainingOwnLoad ownCap segment =
abs (segmentOwnerRemainingLoadTarget segment + segmentLoad segment) / segmentOwnerCapacity segment
+ abs (remainingOwnLoad - segmentLoad segment) / ownCap
- abs (segmentOwnerRemainingLoadTarget segment) / segmentOwnerCapacity segment
kChoicesDepartureCost :: Double -- ^ own remaining load target
-> Double -- ^ own capacity
-> Double -- ^ load of own segment to hand over
-> SegmentLoadStats -- ^ load stats of neighbour VS
-> Double
kChoicesDepartureCost remainingOwnLoad ownCap thisSegmentLoad segment =
abs (segmentOwnerRemainingLoadTarget segment - thisSegmentLoad) / segmentOwnerCapacity segment
+ abs (remainingOwnLoad + thisSegmentLoad) / ownCap
- abs (segmentOwnerRemainingLoadTarget segment) / segmentOwnerCapacity segment
-- | Join a new node into the DHT, using a provided bootstrap node as initial cache seed
-- for resolving the new node's position.
fediChordBootstrapJoin :: Service s (RealNodeSTM s)