set uncles regardless of empty uncle list. Fixes invalid blocks being mined
This commit is contained in:
parent
57f95c1dc7
commit
a1b4547a53
|
@ -184,9 +184,7 @@ func (self *Miner) mine() {
|
||||||
block.Header().Extra = self.Extra
|
block.Header().Extra = self.Extra
|
||||||
|
|
||||||
// Apply uncles
|
// Apply uncles
|
||||||
if len(self.uncles) > 0 {
|
|
||||||
block.SetUncles(self.uncles)
|
block.SetUncles(self.uncles)
|
||||||
}
|
|
||||||
|
|
||||||
parent := chainMan.GetBlock(block.ParentHash())
|
parent := chainMan.GetBlock(block.ParentHash())
|
||||||
coinbase := state.GetOrNewStateObject(block.Coinbase())
|
coinbase := state.GetOrNewStateObject(block.Coinbase())
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ezp
|
package ezp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
@ -53,13 +54,13 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
|
||||||
elapsed := time.Now().UnixNano() - start
|
elapsed := time.Now().UnixNano() - start
|
||||||
hashes := ((float64(1e9) / float64(elapsed)) * float64(i)) / 1000
|
hashes := ((float64(1e9) / float64(elapsed)) * float64(i)) / 1000
|
||||||
pow.HashRate = int64(hashes)
|
pow.HashRate = int64(hashes)
|
||||||
//powlogger.Infoln("Hashing @", pow.HashRate, "khash")
|
|
||||||
|
|
||||||
t = time.Now()
|
t = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
sha := crypto.Sha3(big.NewInt(r.Int63()).Bytes())
|
sha := crypto.Sha3(big.NewInt(r.Int63()).Bytes())
|
||||||
if verify(hash, diff, sha) {
|
if verify(hash, diff, sha) {
|
||||||
|
fmt.Printf("HASH: %x\nDIFF %v\nSHA %x\n", hash, diff, sha)
|
||||||
return sha
|
return sha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +84,7 @@ func verify(hash []byte, diff *big.Int, nonce []byte) bool {
|
||||||
sha.Write(d)
|
sha.Write(d)
|
||||||
|
|
||||||
verification := new(big.Int).Div(ethutil.BigPow(2, 256), diff)
|
verification := new(big.Int).Div(ethutil.BigPow(2, 256), diff)
|
||||||
res := ethutil.U256(ethutil.BigD(sha.Sum(nil)))
|
res := ethutil.BigD(sha.Sum(nil))
|
||||||
|
|
||||||
return res.Cmp(verification) <= 0
|
return res.Cmp(verification) <= 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue