renproject / aw

A flexible P2P networking library for upgradable distributed systems.
MIT License
38 stars 18 forks source link

BUG: Fix incorrect deletion from addrsSorted #47

Closed rahulghangas closed 3 years ago

rahulghangas commented 3 years ago

When deleting an address, the wrong index was being deleted, and if the address to be deleted was present at the end of the array, was not being deleted at all. This was leading to disparity between the addrsBySignatory hashmap and addrsSorted array. This PR fixes that and adds a correctness test to dht_test.go

This bug affects gossiping as well since dht.Addrs(n) uses addrsSorted

rahulghangas commented 3 years ago

I've added the edge cases, I think it's ready to be merged. Can someone do a sanity check on this?

jazg commented 3 years ago

@rahulghangas Approved!

rahulghangas commented 3 years ago

Closing this, changes have been integrated into the experimental branch