This question already has an answer here:
- How can I convert from int to hex 3 answers
I follow the article about building blockchain in go: https://jeiwan.cc/posts/building-blockchain-in-go-part-2/
When I study the part 2, I can't run the code in the prepareDate
function. It always throw up a error:
underfined: IntToHex.
This is my code:
func (pow *ProofOfWork) prepareData(nonce int) []byte {
data := bytes.Join(
[][]byte{
pow.block.PrevBlockHash,
pow.block.Data,
IntToHex(pow.block.Timestamp),
IntToHex(int64(targetBits)),
IntToHex(int64(nonce)),
},
[]byte{},
)
return data
}
</div>