aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-22 02:23:33 +0800
committerobscuren <geffobscura@gmail.com>2014-08-22 02:23:33 +0800
commitfb90ecc8bc3c9041612afbcf1d79900670055df0 (patch)
treef5d8b436ff41151352a1ee3cfa482f874ccfb289 /ethchain
parent0af0f0d890120e007ce42f072e1ee179a62115d3 (diff)
parent5196f9a340d3e867bbff2e317a3c0697377da1cf (diff)
downloadgo-tangerine-fb90ecc8bc3c9041612afbcf1d79900670055df0.tar.gz
go-tangerine-fb90ecc8bc3c9041612afbcf1d79900670055df0.tar.zst
go-tangerine-fb90ecc8bc3c9041612afbcf1d79900670055df0.zip
Merge branch 'release/0.6.4'
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/dagger.go25
-rw-r--r--ethchain/genesis.go2
2 files changed, 21 insertions, 6 deletions
diff --git a/ethchain/dagger.go b/ethchain/dagger.go
index 917b3d722..478b7e877 100644
--- a/ethchain/dagger.go
+++ b/ethchain/dagger.go
@@ -1,15 +1,16 @@
package ethchain
import (
+ "hash"
+ "math/big"
+ "math/rand"
+ "time"
+
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/sha3"
- "hash"
- "math/big"
- "math/rand"
- "time"
)
var powlogger = ethlog.NewLogger("POW")
@@ -18,23 +19,30 @@ type PoW interface {
Search(block *Block, reactChan chan ethreact.Event) []byte
Verify(hash []byte, diff *big.Int, nonce []byte) bool
GetHashrate() int64
+ Turbo(bool)
}
type EasyPow struct {
hash *big.Int
HashRate int64
+ turbo bool
}
func (pow *EasyPow) GetHashrate() int64 {
return pow.HashRate
}
+func (pow *EasyPow) Turbo(on bool) {
+ pow.turbo = on
+}
+
func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
hash := block.HashNoNonce()
diff := block.Difficulty
i := int64(0)
start := time.Now().UnixNano()
+ t := time.Now()
for {
select {
@@ -43,11 +51,14 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte {
return nil
default:
i++
- if i%1234567 == 0 {
+
+ if time.Since(t) > (1 * time.Second) {
elapsed := time.Now().UnixNano() - start
hashes := ((float64(1e9) / float64(elapsed)) * float64(i)) / 1000
pow.HashRate = int64(hashes)
powlogger.Infoln("Hashing @", int64(pow.HashRate), "khash")
+
+ t = time.Now()
}
sha := ethcrypto.Sha3Bin(big.NewInt(r.Int63()).Bytes())
@@ -55,6 +66,10 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte {
return sha
}
}
+
+ if !pow.turbo {
+ time.Sleep(20 * time.Microsecond)
+ }
}
return nil
diff --git a/ethchain/genesis.go b/ethchain/genesis.go
index 0ce53a6ee..8a1219acb 100644
--- a/ethchain/genesis.go
+++ b/ethchain/genesis.go
@@ -28,7 +28,7 @@ var GenesisHeader = []interface{}{
"",
// Difficulty
//ethutil.BigPow(2, 22),
- big.NewInt(4096),
+ big.NewInt(131072),
// Number
ethutil.Big0,
// Block minimum gas price