Skip to content

Commit 6660929

Browse files
authored
p2p/enode: remove unused code (#21612)
1 parent b007df8 commit 6660929

1 file changed

Lines changed: 0 additions & 21 deletions

File tree

‎p2p/enode/node.go‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"errors"
2424
"fmt"
2525
"math/bits"
26-
"math/rand"
2726
"net"
2827
"strings"
2928

@@ -278,23 +277,3 @@ func LogDist(a, b ID) int {
278277
}
279278
return len(a)*8 - lz
280279
}
281-
282-
// RandomID returns a random ID b such that logdist(a, b) == n.
283-
func RandomID(a ID, n int) (b ID) {
284-
if n == 0 {
285-
return a
286-
}
287-
// flip bit at position n, fill the rest with random bits
288-
b = a
289-
pos := len(a) - n/8 - 1
290-
bit := byte(0x01) << (byte(n%8) - 1)
291-
if bit == 0 {
292-
pos++
293-
bit = 0x80
294-
}
295-
b[pos] = a[pos]&^bit | ^a[pos]&bit // TODO: randomize end bits
296-
for i := pos + 1; i < len(a); i++ {
297-
b[i] = byte(rand.Intn(255))
298-
}
299-
return b
300-
}

0 commit comments

Comments
 (0)