mirror of
https://github.com/logos-storage/logos-storage-nim-validator.git
synced 2026-01-04 14:33:12 +00:00
25 lines
395 B
Nim
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
|