Simplify
This commit is contained in:
parent
0a28338136
commit
98d8571ceb
|
@ -31,14 +31,12 @@ func parse(_: type UInt256, bytes: seq[byte]): ?UInt256 =
|
||||||
UInt256.fromBytesBE(bytes).some
|
UInt256.fromBytesBE(bytes).some
|
||||||
|
|
||||||
func init*(_: type Presence, message: PresenceMessage): ?Presence =
|
func init*(_: type Presence, message: PresenceMessage): ?Presence =
|
||||||
without parsedCid =? Cid.init(message.cid):
|
without cid =? Cid.init(message.cid) and
|
||||||
return none Presence
|
price =? UInt256.parse(message.price):
|
||||||
|
|
||||||
without parsedPrice =? UInt256.parse(message.price):
|
|
||||||
return none Presence
|
return none Presence
|
||||||
|
|
||||||
some Presence(
|
some Presence(
|
||||||
cid: parsedCid,
|
cid: cid,
|
||||||
have: message.`type` == presenceHave,
|
have: message.`type` == presenceHave,
|
||||||
price: parsedPrice
|
price: price
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue