mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-09 22:06:21 +00:00
c74ba5c0c6
* ssz: move ref support outside Instead of allocating ref's inside SSZ, move it to separate helper: * makes `ref` allocations explicit * less magic inside SSZ * `ref` in nim generally means reference whereas SSZ was loading as value - if a type indeed used references it would get copies instead of references to a single value on roundtrip which is unexpected TODO: EF tests would benefit from some refactoring since they all do the same thing practically.. Co-authored-by: Zahary Karadjov <zahary@gmail.com>
35 lines
1.0 KiB
Nim
35 lines
1.0 KiB
Nim
import
|
|
confutils, os, strutils, chronicles, json_serialization,
|
|
../beacon_chain/spec/[crypto, datatypes, digest],
|
|
../beacon_chain/[ssz]
|
|
|
|
# TODO turn into arguments
|
|
cli do(kind: string, file: string):
|
|
template printit(t: untyped) {.dirty.} =
|
|
let v = newClone(
|
|
if cmpIgnoreCase(ext, ".ssz") == 0:
|
|
SSZ.loadFile(file, t)
|
|
elif cmpIgnoreCase(ext, ".json") == 0:
|
|
JSON.loadFile(file, t)
|
|
else:
|
|
echo "Unknown file type: ", ext
|
|
quit 1
|
|
)
|
|
echo JSON.encode(v[], pretty = true)
|
|
|
|
let ext = splitFile(file).ext
|
|
|
|
case kind
|
|
of "attester_slashing": printit(AttesterSlashing)
|
|
of "attestation": printit(Attestation)
|
|
of "block": printit(BeaconBlock)
|
|
of "block_body": printit(BeaconBlockBody)
|
|
of "block_header": printit(BeaconBlockHeader)
|
|
of "deposit": printit(Deposit)
|
|
of "deposit_data": printit(DepositData)
|
|
of "eth1_data": printit(Eth1Data)
|
|
of "state": printit(BeaconState)
|
|
of "proposer_slashing": printit(ProposerSlashing)
|
|
of "voluntary_exit": printit(VoluntaryExit)
|
|
else: echo "Unknown kind"
|