aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-22 00:14:41 +0800
committerobscuren <geffobscura@gmail.com>2014-08-22 00:14:41 +0800
commit0eb08693e90ce2f7cdabb142852a4173cc91e387 (patch)
tree78b07ec20f6da16eb1cfe1bb77e4f65ac23c201e
parentcc6ad034f1e1af5db98750b41ab1fbc863aab908 (diff)
downloaddexon-0eb08693e90ce2f7cdabb142852a4173cc91e387.tar
dexon-0eb08693e90ce2f7cdabb142852a4173cc91e387.tar.gz
dexon-0eb08693e90ce2f7cdabb142852a4173cc91e387.tar.bz2
dexon-0eb08693e90ce2f7cdabb142852a4173cc91e387.tar.lz
dexon-0eb08693e90ce2f7cdabb142852a4173cc91e387.tar.xz
dexon-0eb08693e90ce2f7cdabb142852a4173cc91e387.tar.zst
dexon-0eb08693e90ce2f7cdabb142852a4173cc91e387.zip
Turbo mode
-rw-r--r--ethchain/dagger.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/ethchain/dagger.go b/ethchain/dagger.go
index 917b3d722..065d2c843 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,17 +19,23 @@ 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()
@@ -55,6 +62,10 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte {
return sha
}
}
+
+ if !pow.turbo {
+ time.Sleep(500 * time.Millisecond)
+ }
}
return nil