aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-22 02:13:26 +0800
committerobscuren <geffobscura@gmail.com>2014-08-22 02:13:26 +0800
commit732573ba512aa215e88aed3f20393c3c42c1aeb0 (patch)
treef568ee70952f740a380384afb3ccf2d75a2bddb6
parent854d6d4e5cb8783e18397fef655ad79065263cc2 (diff)
downloadgo-tangerine-732573ba512aa215e88aed3f20393c3c42c1aeb0.tar
go-tangerine-732573ba512aa215e88aed3f20393c3c42c1aeb0.tar.gz
go-tangerine-732573ba512aa215e88aed3f20393c3c42c1aeb0.tar.bz2
go-tangerine-732573ba512aa215e88aed3f20393c3c42c1aeb0.tar.lz
go-tangerine-732573ba512aa215e88aed3f20393c3c42c1aeb0.tar.xz
go-tangerine-732573ba512aa215e88aed3f20393c3c42c1aeb0.tar.zst
go-tangerine-732573ba512aa215e88aed3f20393c3c42c1aeb0.zip
Turbo mining
-rw-r--r--ethchain/dagger.go8
-rw-r--r--ethchain/genesis.go2
-rw-r--r--ethminer/miner.go8
3 files changed, 15 insertions, 3 deletions
diff --git a/ethchain/dagger.go b/ethchain/dagger.go
index 065d2c843..478b7e877 100644
--- a/ethchain/dagger.go
+++ b/ethchain/dagger.go
@@ -42,6 +42,7 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte {
diff := block.Difficulty
i := int64(0)
start := time.Now().UnixNano()
+ t := time.Now()
for {
select {
@@ -50,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())
@@ -64,7 +68,7 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte {
}
if !pow.turbo {
- time.Sleep(500 * time.Millisecond)
+ time.Sleep(20 * time.Microsecond)
}
}
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
diff --git a/ethminer/miner.go b/ethminer/miner.go
index 74f5bc7af..799db79f1 100644
--- a/ethminer/miner.go
+++ b/ethminer/miner.go
@@ -23,6 +23,8 @@ type Miner struct {
powChan chan []byte
powQuitChan chan ethreact.Event
quitChan chan chan error
+
+ turbo bool
}
func (self *Miner) GetPow() ethchain.PoW {
@@ -39,6 +41,12 @@ func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) *Miner {
return &miner
}
+func (self *Miner) ToggleTurbo() {
+ self.turbo = !self.turbo
+
+ self.pow.Turbo(self.turbo)
+}
+
func (miner *Miner) Start() {
miner.reactChan = make(chan ethreact.Event, 1) // This is the channel that receives 'updates' when ever a new transaction or block comes in
miner.powChan = make(chan []byte, 1) // This is the channel that receives valid sha hashes for a given block