|
|
|
@ -60,18 +60,6 @@ func (b *Block) String() string { |
|
|
|
|
return res |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// HashTransactions returns a hash of the transactions in the block
|
|
|
|
|
func (b *Block) HashTransactions() []byte { |
|
|
|
|
var txHashes [][]byte |
|
|
|
|
var txHash [32]byte |
|
|
|
|
|
|
|
|
|
for _, tx := range b.Transactions { |
|
|
|
|
txHashes = append(txHashes, tx.ID[:]) |
|
|
|
|
} |
|
|
|
|
txHash = sha256.Sum256(bytes.Join(txHashes, []byte{})) |
|
|
|
|
return txHash[:] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (b *Block) Write(db db.Database, key string) error { |
|
|
|
|
return db.Put([]byte(key), b.Serialize()) |
|
|
|
|
} |
|
|
|
|