mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-13 03:26:38 +00:00
pow/ezp: use common.Hash
This commit is contained in:
parent
27f7aa0163
commit
65eee2006d
1 changed files with 4 additions and 7 deletions
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto/sha3"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto/sha3"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
"github.com/ethereum/go-ethereum/pow"
|
"github.com/ethereum/go-ethereum/pow"
|
||||||
)
|
)
|
||||||
|
|
@ -83,17 +83,14 @@ func (pow *EasyPow) Verify(block pow.Block) bool {
|
||||||
return Verify(block)
|
return Verify(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
func verify(hash []byte, diff *big.Int, nonce uint64) bool {
|
func verify(hash common.Hash, diff *big.Int, nonce uint64) bool {
|
||||||
sha := sha3.NewKeccak256()
|
sha := sha3.NewKeccak256()
|
||||||
|
|
||||||
n := make([]byte, 8)
|
n := make([]byte, 8)
|
||||||
binary.PutUvarint(n, nonce)
|
binary.PutUvarint(n, nonce)
|
||||||
d := append(hash, n...)
|
sha.Write(n)
|
||||||
sha.Write(d)
|
sha.Write(hash[:])
|
||||||
|
|
||||||
verification := new(big.Int).Div(common.BigPow(2, 256), diff)
|
verification := new(big.Int).Div(common.BigPow(2, 256), diff)
|
||||||
res := common.BigD(sha.Sum(nil))
|
res := common.BigD(sha.Sum(nil))
|
||||||
|
|
||||||
return res.Cmp(verification) <= 0
|
return res.Cmp(verification) <= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue