Fix incorrect calculation of free space

when granting a range that spans a token and inserting a new token, the
free space on the last token that we are handing over has to change.
Add unit test for this too.
This commit is contained in:
Bryan Boreham committed 2015-05-28 18:12:30 +01:00
1 parent 32c35da402
commit af5531cbf6
3 files changed
+19 -1

No files matched your search

+1 -1
View File
@@ -167,7 +167,7 @@ func (r *Ring) GrantRangeToHost(start, end address.Address, peer router.PeerName
pos := preceedingPos + 1
for ; pos < len(r.Entries) && r.Entries.entry(pos).Token < end; pos++ {
entry := r.Entries.entry(pos)
entry.update(peer, entry.Free)
entry.update(peer, address.Min(entry.Free, r.distance(entry.Token, end)))
}
// There is never an entry with a token of r.End, as the end of