Skip to content
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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kdeme
Copy link
Contributor

@kdeme kdeme commented Jan 17, 2025

No description provided.

Comment on lines 350 to 351
case customPayload.`type`
of CapabilitiesType:
Copy link
Contributor Author

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)

Comment on lines 763 to 772
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")
Copy link
Contributor Author

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.

Comment on lines 341 to 345
let customPayload = decodeSsz(
encodedCustomPayload.asSeq(), CustomPayloadExtensionsFormat
).valueOr:
# invalid custom payload format, send back FailedToDecodePayload
return encodeErrorPayload(ErrorCode.FailedToDecodePayload)
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant