2024-12-18 10:19:09 +01:00

25 lines
395 B
Nim

import ../basics
import ../hashing
import ./blck
import ./blockid
import ./serialization
func hash*(b: Block): Hash =
without var hash =? blck.hash(b):
hash = Hash.hash(b.toBytes())
b.hash = hash
hash
func id*(b: Block): BlockId =
BlockId.init(
b.author,
b.round,
hash(b)
)
func `==`*(a, b: Block): bool =
a.hash == b.hash
func `$`*(b: Block): string =
$b.id