aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-11-27 10:13:05 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:19 +0800
commit4c520e06a04c0b734dcc703dd007bb89cfb15a9d (patch)
tree77b471cb9a9db4df532df82de300fb796576e950 /vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
parent2b4a537e21e3c2d0e3f31dec6cea60e31125db66 (diff)
downloadgo-tangerine-4c520e06a04c0b734dcc703dd007bb89cfb15a9d.tar
go-tangerine-4c520e06a04c0b734dcc703dd007bb89cfb15a9d.tar.gz
go-tangerine-4c520e06a04c0b734dcc703dd007bb89cfb15a9d.tar.bz2
go-tangerine-4c520e06a04c0b734dcc703dd007bb89cfb15a9d.tar.lz
go-tangerine-4c520e06a04c0b734dcc703dd007bb89cfb15a9d.tar.xz
go-tangerine-4c520e06a04c0b734dcc703dd007bb89cfb15a9d.tar.zst
go-tangerine-4c520e06a04c0b734dcc703dd007bb89cfb15a9d.zip
vendor: sync to latest core (#52)
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
index f6be46130..441aac174 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
@@ -20,6 +20,7 @@ package core
import (
"errors"
"fmt"
+ "math/rand"
"os"
"sort"
"time"
@@ -60,7 +61,7 @@ func Debugf(format string, args ...interface{}) {
// Debugln is like fmt.Println, but only output when we are in debug mode.
func Debugln(args ...interface{}) {
if debug {
- fmt.Println(args)
+ fmt.Println(args...)
}
}
@@ -114,6 +115,11 @@ func removeFromSortedUint32Slice(xs []uint32, x uint32) []uint32 {
return append(xs[:indexToRemove], xs[indexToRemove+1:]...)
}
+// pickBiasedTime returns a biased time based on a given range.
+func pickBiasedTime(base time.Time, biasedRange time.Duration) time.Time {
+ return base.Add(time.Duration(rand.Intn(int(biasedRange))))
+}
+
// HashConfigurationBlock returns the hash value of configuration block.
func HashConfigurationBlock(
notarySet map[types.NodeID]struct{},