package core import ( "hash" "math/big" "math/rand" "time" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" "github.com/obscuren/sha3" ) var powlogger = logger.NewLogger("POW") type Dagger struct { hash *big.Int xn *big.Int } var Found bool func (dag *Dagger) Find(obj *big.Int, resChan chan int64) { r := rand.New(rand.NewSource(time.Now().UnixNano())) for i := 0; i < 1000; i++ { rnd := r.Int63() res := dag.Eval(big.NewInt(rnd)) powlogger.Infof("rnd %v\nres %v\nobj %v\n", rnd, res, obj) if res.Cmp(obj) < 0 { // Post back result on the channel resChan <- rnd // Notify other threads we've found a valid nonce Found = true } // Break out if found if Found { break } } resChan <- 0 } func (dag *Dagger) Search(hash, diff *big.Int) *big.Int { // TODO fix multi threading. Somehow it results in the wrong nonce amountOfRoutines := 1 dag.hash = hash obj := ethutil.BigPow(2, 256) obj = obj.Div(obj, diff) Found = false resChan := make(chan int64, 3) var res int64 for k := 0; k < amountOfRoutines; k++ { go dag.Find(obj, resChan) // Wait for each go routine to finish } for k := 0; k < amountOfRoutines; k++ { // Get the result from the channel. 0 = quit if r := <-resChan; r != 0 { res = r } } return big.NewInt(res) } func (dag *Dagger) Verify(hash, diff, nonce *big.Int) bool { dag.hash = hash obj := ethutil.BigPow(2, 256) obj = obj.Div(obj, diff) return dag.Eval(nonce).Cmp(obj) < 0 } func DaggerVerify(hash, diff, nonce *big.Int) bool { dagger := &Dagger{} dagger.hash = hash obj := ethutil.BigPow(2, 256) obj = obj.Div(obj, diff) return dagger.Eval(nonce).Cmp(obj) < 0 } func (dag *Dagger) Node(L uint64, i uint64) *big.Int { if L == i { return dag.hash } var m *big.Int if L == 9 { m = big.NewInt(16) } else { m = big.NewInt(3) } sha := sha3.NewKeccak256() sha.Reset() d := sha3.NewKeccak256() b := new(big.Int) ret := new(big.Int) for k := 0; k < int(m.Uint64()); k++ { d.Reset() d.Write(dag.hash.Bytes()) d.Write(dag.xn.Bytes()) d.Write(big.NewInt(int64(L)).Bytes()) d.Write(big.NewInt(int64(i)).Bytes()) d.Write(big.NewInt(int64(k)).Bytes()) b.SetBytes(Sum(d)) pk := b.Uint64() & ((1 << ((L - 1) * 3)) - 1) sha.Write(dag.Node(L-1, pk).Bytes()) } ret.SetBytes(Sum(sha)) return ret } func Sum(sha hash.Hash) []byte { //in := make([]byte, 32) return sha.Sum(nil) } func (dag *Dagger) Eval(N *big.Int) *big.Int { pow := ethutil.BigPow(2, 26) dag.xn = pow.Div(N, pow) sha := sha3.NewKeccak256() sha.Reset() ret := new(big.Int) for k := 0; k < 4; k++ { d := sha3.NewKeccak256() b := new(big.Int) d.Reset() d.Write(dag.hash.Bytes()) d.Write(dag.xn.Bytes()) d.Write(N.Bytes()) d.Write(big.NewInt(int64(k)).Bytes()) b.SetBytes(Sum(d)) pk := (b.Uint64() & 0x1ffffff) sha.Write(dag.Node(9, pk).Bytes()) } return ret.SetBytes(Sum(sha)) } n value='dependabot/npm_and_yarn/devel/electron4/files/y18n-3.2.2'>dependabot/npm_and_yarn/devel/electron4/files/y18n-3.2.2 FreeBSD GNOME current development ports (https://github.com/freebsd/freebsd-ports-gnome)
aboutsummaryrefslogtreecommitdiffstats
path: root/vietnamese
Commit message (Expand)AuthorAgeFilesLines
* Remove misc/artikulate-kde4 and vietnamese/kde4-l10ntcberner2018-07-185-278/+0
* - Update to 6.0.5lwhsu2018-06-271-5/+5
* - Update to 6.0.4lwhsu2018-05-101-5/+5
* - Update to 6.0.3lwhsu2018-04-081-5/+5
* - Update LibreOffice to 6.0.2 [1]lwhsu2018-03-172-8/+5
* Rename KDE4 meta portstcberner2018-02-101-1/+1
* - Remove archivers/zip build dependencyak2017-11-084-9/+9
* Update to 5.3.7.jkim2017-11-031-5/+5
* Fix whitespace issues (mixed tab/spaces, alignment) in a few ports.olgeni2017-10-311-1/+1
* Update to 5.3.6.jkim2017-09-061-5/+5
* Update to 5.3.5.jkim2017-08-041-5/+5
* Update to 5.3.4.jkim2017-06-221-5/+5
* Update to 5.3.3.jkim2017-05-201-5/+5
* Update to 5.2.7.jkim2017-05-051-5/+5
* Chase ffmpeg 3.3 update (ABI changes)riggs2017-04-251-0/+1
* Rename the magic DISTVERSION into SPELLVERSION for the aspell ports.mat2017-04-121-1/+1
* Update to 5.2.6.jkim2017-03-281-5/+5
* vietnamese/x-unikey: unbreak with libc++ 3.9jbeich2017-02-021-0/+11
* Update to 5.2.5.jkim2017-02-011-5/+5
* Update to 5.2.4.jkim2017-01-02d class='commitgraph'>* - Update to 9.1swills2013-02-185-55/+98
* - Fix build with OpenSSL >= 1.0 [1]pawel2012-09-082-0/+33
* - Update to 0.8.0miwi2012-05-162-4/+3
* - Add LDFLAGS to CONFIGURE_ENV and MAKE_ENV (as it was done with LDFLAGS)amdmi32011-09-241-3/+4
* Fix build post gnutls update.zi2011-07-211-1/+5
* Chase security/gnutls update and add an UPDATING entry.novel2011-06-061-0/+1