mirror of
https://github.com/logos-storage/nim-mysticeti.git
synced 2026-01-04 06:33:11 +00:00
33 lines
636 B
Nim
33 lines
636 B
Nim
import std/json
|
|
import mysticeti
|
|
import ./transaction
|
|
|
|
type MockSerialization* = object
|
|
|
|
proc `%`*(member: CommitteeMember): JsonNode =
|
|
%member.int
|
|
|
|
proc `%`*(id: BlockId): JsonNode =
|
|
%*{
|
|
"author": id.author,
|
|
"round": id.round,
|
|
"hash": $id.hash
|
|
}
|
|
|
|
proc `%`*(transaction: MockTransaction): JsonNode =
|
|
%*{
|
|
"nonce": transaction.nonce
|
|
}
|
|
|
|
proc `%`*(blck: Block): JsonNode =
|
|
%*{
|
|
"author": blck.author,
|
|
"round": blck.round,
|
|
"parents": blck.parents,
|
|
"transactions": blck.transactions
|
|
}
|
|
|
|
func toBytes*(_: type MockSerialization, blck: Block): seq[byte] =
|
|
let json = %blck
|
|
cast[seq[byte]]($json)
|