(self: HashRing<A>)
| 186 | |
| 187 | // Sum in key order to avoid history-dependent floating-point rounding. |
| 188 | function updateTotalWeight<A extends PrimaryKey.PrimaryKey>(self: HashRing<A>) { |
| 189 | const keys = Array.from(self.nodes.keys()).sort() |
| 190 | let total = 0 |
| 191 | for (let i = 0; i < keys.length; i++) { |
| 192 | total += self.nodes.get(keys[i])![1] |
| 193 | } |
| 194 | self.totalWeightCache = total |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Adds a new node to the ring. If the node already exists in the ring, it |
no test coverage detected