-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: reduce dagPb and dagCbor handler complexity #45
fix: reduce dagPb and dagCbor handler complexity #45
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
// this should never happen, but if it does, we should log it and return notSupportedResponse | ||
this.log.error('terminal element is not a dag-cbor node') | ||
return notSupportedResponse(resource, 'Terminal element is not a dag-cbor node') |
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.
not sure if this is the right thing to do here, or if we want to allow walking the path to fail and still query helia.blockstore.get(cid, options)
…pb-and-handledagcbor
…pb-and-handledagcbor
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
export type RequestFormatShorthand = 'raw' | 'car' | 'tar' | 'ipns-record' | 'dag-json' | 'dag-cbor' | 'json' | 'cbor' | ||
|
||
export type SupportedBodyTypes = string | ArrayBuffer | Blob | ReadableStream<Uint8Array> | null | ||
|
||
export interface FetchHandlerFunctionArg { |
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.
note: cacheKey was removed
* If a terminal element is not found, a notFoundResponse is returned | ||
* If another unknown error occurs, a badGatewayResponse is returned | ||
*/ | ||
export async function handlePathWalking ({ cid, path, resource, options, blockstore, log }: Omit<FetchHandlerFunctionArg, 'session'> & { blockstore: Blockstore, log: Logger }): Promise<PathWalkerResponse | Response> { |
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.
this was moved to walk-path.ts
from verified-fetch.ts
because that file is getting much too large
@@ -156,7 +126,8 @@ export class VerifiedFetch { | |||
this.log.trace('created VerifiedFetch instance') | |||
} | |||
|
|||
private getBlockstore (root: CID, key: string, useSession: boolean, options?: AbortOptions): Blockstore { | |||
private getBlockstore (root: CID, resource: string | CID, useSession: boolean, options?: AbortOptions): Blockstore { | |||
const key = resourceToSessionCacheKey(resource) |
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.
instead of constructing the key in fetch
function, construct in here and just use the resource that FetchHandlerFunctionArg
already has.
…pb-and-handledagcbor
…pb-and-handledagcbor
## @helia/verified-fetch [1.4.2](https://github.com/ipfs/helia-verified-fetch/compare/@helia/verified-fetch-1.4.1...@helia/verified-fetch-1.4.2) (2024-05-16) ### Bug Fixes * reduce dagPb and dagCbor handler complexity ([#45](#45)) ([3b41752](3b41752))
🎉 This PR is included in version 1.4.2 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.1.0 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.24.0 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
Title
fix: reduce dagPb and dagCbor handler complexity
Description
fixes #43
setIpfsRoots
functionNotes & open questions
I'm not 100% sure about how to handle the
isObjectNode === false
case.Change checklist