Skip to content

Commit

Permalink
p2p/enode: remove unused code (ethereum#21612)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrFranklin committed Sep 28, 2020
1 parent b007df8 commit 6660929
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions p2p/enode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"math/bits"
"math/rand"
"net"
"strings"

Expand Down Expand Up @@ -278,23 +277,3 @@ func LogDist(a, b ID) int {
}
return len(a)*8 - lz
}

// RandomID returns a random ID b such that logdist(a, b) == n.
func RandomID(a ID, n int) (b ID) {
if n == 0 {
return a
}
// flip bit at position n, fill the rest with random bits
b = a
pos := len(a) - n/8 - 1
bit := byte(0x01) << (byte(n%8) - 1)
if bit == 0 {
pos++
bit = 0x80
}
b[pos] = a[pos]&^bit | ^a[pos]&bit // TODO: randomize end bits
for i := pos + 1; i < len(a); i++ {
b[i] = byte(rand.Intn(255))
}
return b
}

0 comments on commit 6660929

Please sign in to comment.