func (b *Block) Hash() []byte { answer := make([]byte, len(b.Version)+len(b.PrevBlock)+len(b.MerkleRoot)+len(b.Timestamp)+len(b.Bits)+len(b.Nonce)) iterator := 0 copy(answer[iterator:], b.Version[:]) iterator += len(b.Version) copy(answer[iterator:], b.PrevBlock[:]) iterator += len(b.PrevBlock) copy(answer[iterator:], b.MerkleRoot[:]) iterator += len(b.MerkleRoot) copy(answer[iterator:], b.Timestamp[:]) iterator += len(b.Timestamp) copy(answer[iterator:], b.Bits[:]) iterator += len(b.Bits) copy(answer[iterator:], b.Nonce[:]) return mymath.Rev(mymath.DoubleSHA(answer)) }
func (b *Block) SetMerkleRootStrRev(merkle string) { if len(merkle) == 64 { answer := mymath.String2Hex(merkle) copy(b.MerkleRoot[:], mymath.Rev(answer)) } }
func (b *Block) SetPrevBlockStrRev(prev string) { if len(prev) == 32 { answer := mymath.String2Hex(prev) copy(b.PrevBlock[:], mymath.Rev(answer)) } }