Closed SgtPooki closed 2 months ago
nvm. This is to prevent modifying the readonly this.url
, but we could likely set gwURL
in the constructor, or modify the url there
we could also construct a request instance and use that in the fetch call. micro-optimization, but still
This is to prevent modifying the readonly this.url
Exactly, yes.
we could likely set gwURL in the constructor
We can't, because getRawBlock
is called multiple times, and that function modifies the URL object, so it needs to make a copy of it, to avoid modifying the internal state of the broker URL.
micro-optimization, but still
If you can measure it, and make a real-world performance improvement it's worth doing but I'm not sure in this case.
Closing as this isn't a bug.
https://github.com/ipfs/helia/blob/13daa26ec9bc6c1a1552b7b56597945c5b13a87b/packages/block-brokers/src/trustless-gateway/trustless-gateway.ts#L52
this.url
inTrustlessGateway
instances is already a URL (in constructor) and should not need to useconst gwUrl = new URL(this.url.toString())