2019-06-24 15:13:48 +00:00
|
|
|
import libp2p/daemon/daemonapi, json_serialization
|
|
|
|
export json_serialization
|
|
|
|
|
|
|
|
proc writeValue*(writer: var JsonWriter, value: PeerID) {.inline.} =
|
2020-09-06 08:39:25 +00:00
|
|
|
writer.writeValue $value
|
2019-06-24 15:13:48 +00:00
|
|
|
|
|
|
|
proc readValue*(reader: var JsonReader, value: var PeerID) {.inline.} =
|
2020-07-01 11:41:40 +00:00
|
|
|
let res = PeerID.init reader.readValue(string)
|
|
|
|
if res.isOk:
|
|
|
|
value = res.get()
|
|
|
|
else:
|
|
|
|
raiseUnexpectedValue(reader, $res.error)
|
2019-06-24 15:13:48 +00:00
|
|
|
|
|
|
|
proc writeValue*(writer: var JsonWriter, value: MultiAddress) {.inline.} =
|
|
|
|
writer.writeValue $value
|
|
|
|
|
|
|
|
proc readValue*(reader: var JsonReader, value: var MultiAddress) {.inline.} =
|
2020-07-01 11:41:40 +00:00
|
|
|
let res = MultiAddress.init reader.readValue(string)
|
|
|
|
if res.isOk:
|
|
|
|
value = res.value
|
2020-06-05 15:08:50 +00:00
|
|
|
else:
|
2020-07-01 11:41:40 +00:00
|
|
|
raiseUnexpectedValue(reader, $res.error)
|
2019-06-24 15:13:48 +00:00
|
|
|
|