-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal implementation of Portal ping payload extensions spec #3010
base: master
Are you sure you want to change the base?
Conversation
case customPayload.`type` | ||
of CapabilitiesType: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way currently decoding + actions taken + encoding is put all together is not very modular (and that also becomes visible in tests).
I'll probably change this to have an object variant for this. I'd have to use a enum with different numbers however than the current numbers used for the types. But that is probably better anyhow so that there are no holes. (It does mean that full range cannot be covered, but that should be fine as realistically that range should not be hit)
let customPayload = decodeSsz( | ||
pong.customPayload.asSeq(), CustomPayloadExtensionsFormat | ||
).valueOr: | ||
return err("Pong message contains invalid custom payload") | ||
|
||
if customPayload.`type` != CapabilitiesType: | ||
return err("Pong message contains invalid custom payload") | ||
|
||
let payload = decodeSsz(customPayload.payload.asSeq(), CapabilitiesPayload).valueOr: | ||
return err("Pong message contains invalid CapabilitiesPayload") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minimal version and does not decode anything else than CapabilitiesPayload, which is fine for now as that is the only one we send also.
let customPayload = decodeSsz( | ||
encodedCustomPayload.asSeq(), CustomPayloadExtensionsFormat | ||
).valueOr: | ||
# invalid custom payload format, send back FailedToDecodePayload | ||
return encodeErrorPayload(ErrorCode.FailedToDecodePayload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might be able to get away with this part if the spec gets changed to have the type and the payload directly in the ping/pong message
No description provided.