nimbus-eth2/beacon_chain/networking/libp2p_json_serialization.nim
Mamy Ratsimbazafy d47f53cd9d
Reorg (5/5) (#2377)
* Reorg things left into networking and gossip_processing

* time -> beacon_clock

* fix builds
2021-03-05 14:12:00 +01:00

24 lines
714 B
Nim

import libp2p/daemon/daemonapi, json_serialization
export json_serialization
proc writeValue*(writer: var JsonWriter, value: PeerID) {.inline.} =
writer.writeValue $value
proc readValue*(reader: var JsonReader, value: var PeerID) {.inline.} =
let res = PeerID.init reader.readValue(string)
if res.isOk:
value = res.get()
else:
raiseUnexpectedValue(reader, $res.error)
proc writeValue*(writer: var JsonWriter, value: MultiAddress) {.inline.} =
writer.writeValue $value
proc readValue*(reader: var JsonReader, value: var MultiAddress) {.inline.} =
let res = MultiAddress.init reader.readValue(string)
if res.isOk:
value = res.value
else:
raiseUnexpectedValue(reader, $res.error)