Skip to content

Commit 9815f68

Browse files
committed
fix sort based on xor, fix check node activity worker
1 parent 8486461 commit 9815f68

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

p2p/kademlia/node.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@ package kademlia
22

33
import (
44
"bytes"
5-
"encoding/hex"
65
"fmt"
76
"math/big"
87
"sort"
98
"strings"
109
"sync"
11-
12-
"github.com/pastelnetwork/gonode/common/log"
13-
"github.com/pastelnetwork/gonode/common/utils"
1410
)
1511

1612
// Node is the over-the-wire representation of a node
@@ -134,20 +130,6 @@ func (s *NodeList) distance(id1, id2 []byte) *big.Int {
134130
return new(big.Int).Xor(o1, o2)
135131
}
136132

137-
func (s *NodeList) computeDistances() []big.Int {
138-
distances := make([]big.Int, s.Len())
139-
for i, node := range s.Nodes {
140-
cID, _ := utils.Sha3256hash(node.ID)
141-
dist := s.distance(cID, s.Comparator)
142-
distances[i] = *dist
143-
144-
if s.debug {
145-
log.WithField("node", node.String()).WithField("skey", hex.EncodeToString(s.Comparator)).WithField("dist", distances[i]).Info("computeDistances")
146-
}
147-
}
148-
return distances
149-
}
150-
151133
// Sort sorts nodes
152134
func (s *NodeList) Sort() {
153135
s.Mux.Lock()

0 commit comments

Comments
 (0)