-
Notifications
You must be signed in to change notification settings - Fork 127
fix: trustless gateway returned blocks can be limited #791
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
Conversation
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.
self review
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.
LGTM, a few nits inline.
Co-authored-by: Alex Potsides <[email protected]>
Co-authored-by: Alex Potsides <[email protected]>
Co-authored-by: Alex Potsides <[email protected]>
Co-authored-by: Alex Potsides <[email protected]>
Co-authored-by: Alex Potsides <[email protected]>
use lowercase for logs; sentence case for error messages
FYI all of the requested changes have been made. lmk if I missed something. I'll look over all the code again now |
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.
self review
packages/block-brokers/src/trustless-gateway/trustless-gateway.ts
Outdated
Show resolved
Hide resolved
* If the response contains a content-length header greater than the limit or the actual bytes returned are greater than | ||
* the limit, an error is thrown. | ||
*/ | ||
export async function limitedResponse (response: Response, byteLimit: number, options?: LimitedResponseOptions): Promise<Uint8Array> { |
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 left the property name here as byteLimit
but could change to maxSize
if we want.. leaving for now
Title
fix: trustless gateway returned blocks can be limited
Description
Adds a new utility function
limitedResponse
that ensures the response body is less than a given byte limit.This is done by:
content-length
header is less than the limit, if not, an error is thrown.Fixes #790
Notes & open questions
Change checklist