const targetBits = 20
//工作量证明结构体
type ProofOfWork struct {
block *Block
target *big.Int
}
func NewProofOfWork(b *Block) *ProofOfWork{
target := big.NewInt(1)
target.Lsh(target, uint(256 - targetBits))
pow := &ProofOfWork{b, target}
return pow
}
通过target.Lsh函数 将target变量位移20