diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-07 20:17:48 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-07 20:17:48 +0800 |
commit | fed3e6a808921fb8274b50043c5c39a24a1bbccf (patch) | |
tree | d632e95cfce78bd9a99a52bf7f30ee3ff980dfd3 /pow/ar/rnd.go | |
parent | 032ab665299d75bffc25260e8fa477ace19db06a (diff) | |
download | dexon-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar dexon-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.gz dexon-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.bz2 dexon-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.lz dexon-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.xz dexon-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.zst dexon-fed3e6a808921fb8274b50043c5c39a24a1bbccf.zip |
Refactored ethutil.Config.Db out
Diffstat (limited to 'pow/ar/rnd.go')
-rw-r--r-- | pow/ar/rnd.go | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/pow/ar/rnd.go b/pow/ar/rnd.go deleted file mode 100644 index c62f4e062..000000000 --- a/pow/ar/rnd.go +++ /dev/null @@ -1,66 +0,0 @@ -package ar - -import ( - "math/big" - - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethutil" -) - -var b = big.NewInt - -type Node interface { - Big() *big.Int -} - -type ByteNode []byte - -func (self ByteNode) Big() *big.Int { - return ethutil.BigD(ethutil.Encode([]byte(self))) -} - -func Sha3(v interface{}) *big.Int { - if b, ok := v.(*big.Int); ok { - return ethutil.BigD(crypto.Sha3(b.Bytes())) - } else if b, ok := v.([]interface{}); ok { - return ethutil.BigD(crypto.Sha3(ethutil.Encode(b))) - } else if s, ok := v.([]*big.Int); ok { - v := make([]interface{}, len(s)) - for i, b := range s { - v[i] = b - } - - return ethutil.BigD(crypto.Sha3(ethutil.Encode(v))) - } - - return nil -} - -type NumberGenerator interface { - rand(r *big.Int) *big.Int - rand64(r int64) *big.Int -} - -type rnd struct { - seed *big.Int -} - -func Rnd(s *big.Int) rnd { - return rnd{s} -} - -func (self rnd) rand(r *big.Int) *big.Int { - o := b(0).Mod(self.seed, r) - - self.seed.Div(self.seed, r) - - if self.seed.Cmp(ethutil.BigPow(2, 64)) < 0 { - self.seed = Sha3(self.seed) - } - - return o -} - -func (self rnd) rand64(r int64) *big.Int { - return self.rand(b(r)) -} |