Unverified Commit 163fb2af authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #31 from libp2p/fix/hash-under-lock

fix: avoid hashing under a lock
parents 509f0538 a3a726cb
......@@ -113,11 +113,12 @@ func (rt *RoutingTable) Update(p peer.ID) (evicted peer.ID, err error) {
// Remove deletes a peer from the routing table. This is to be used
// when we are sure a node has disconnected completely.
func (rt *RoutingTable) Remove(p peer.ID) {
rt.tabLock.Lock()
defer rt.tabLock.Unlock()
peerID := ConvertPeerID(p)
cpl := CommonPrefixLen(peerID, rt.local)
rt.tabLock.Lock()
defer rt.tabLock.Unlock()
bucketID := cpl
if bucketID >= len(rt.Buckets) {
bucketID = len(rt.Buckets) - 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment