-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Write request decode validation as async fn #1901
Conversation
dapplion
commented
Dec 18, 2020
- Move validation logic out of the async generator into a standalone function
- Use LodestarError pattern for validation errors
- Use RequestDecodeErrorCode in tests instead of asserting raw strings
Code Climate has analyzed commit 7cb87c4 and detected 2 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
if (sszDataLength === null) { | ||
sszDataLength = decode(chunk.slice()); | ||
if (decode.bytes > 10) { | ||
logger.error("eth2RequestDecode: Invalid number of bytes for protobuf varint", { |
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.
IMO having method in log could be useful
|
||
// only one request body accepted, so return | ||
try { | ||
return type.deserialize(buffer.slice(0, sszDataLength)); |
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.
I wonder if you don't break when reading from source, do you even close stream. It's been a while,
but I remember that it could hang open if you don't read everything or break. libp2p handles open and closes in post loop cleanup. I know we had some issues because if you don't finish reading that post iteration cleanup did not occur.