aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-07 04:48:57 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-07 04:48:57 +0800
commit24d44f35f2cf17b07330a7e7be79abc2b6b92fc6 (patch)
treea64252ccd5ed06a9553af310a572e1dc95e92e55 /common
parent323216ed85b48abec07266a203b731e7491d4286 (diff)
parent2adcc31bb48af0dee979f2b4ab255d9af21fd097 (diff)
downloaddexon-24d44f35f2cf17b07330a7e7be79abc2b6b92fc6.tar
dexon-24d44f35f2cf17b07330a7e7be79abc2b6b92fc6.tar.gz
dexon-24d44f35f2cf17b07330a7e7be79abc2b6b92fc6.tar.bz2
dexon-24d44f35f2cf17b07330a7e7be79abc2b6b92fc6.tar.lz
dexon-24d44f35f2cf17b07330a7e7be79abc2b6b92fc6.tar.xz
dexon-24d44f35f2cf17b07330a7e7be79abc2b6b92fc6.tar.zst
dexon-24d44f35f2cf17b07330a7e7be79abc2b6b92fc6.zip
Merge pull request #791 from fjl/discover-sha3-distance
p2p/discover: sha3-based node distance
Diffstat (limited to 'common')
-rw-r--r--common/types.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/common/types.go b/common/types.go
index daefcde11..183d48fb3 100644
--- a/common/types.go
+++ b/common/types.go
@@ -1,6 +1,10 @@
package common
-import "math/big"
+import (
+ "math/big"
+ "math/rand"
+ "reflect"
+)
const (
hashLength = 32
@@ -48,6 +52,15 @@ func (h *Hash) Set(other Hash) {
}
}
+// Generate implements testing/quick.Generator.
+func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value {
+ m := rand.Intn(len(h))
+ for i := len(h) - 1; i > m; i-- {
+ h[i] = byte(rand.Uint32())
+ }
+ return reflect.ValueOf(h)
+}
+
/////////// Address
func BytesToAddress(b []byte) Address {
var a Address