boxo icon indicating copy to clipboard operation
boxo copied to clipboard

feat: basic support for Ipfs-Path-Affinity from IPIP-462

Open lidel opened this issue 1 year ago • 1 comments

This PR aims to kick-off discussion how we would support IPIP-462 in boxo/gateway.

For more info and header semantics, see https://github.com/ipfs/specs/pull/462

proposed scope

What I want to do for now is to add minimal code to start leveraging Ipfs-Path-Affinity hints within existing boxo/gateway codebase, so we cna deploy it to our gateways and allow clients like service-worker-gateway or ipfs-chromium to pass hint and retrieve content even when internal CID was not announced directly.

  • [x] support percent-encoded values
  • [x] limit to 3 hints per request
  • [x] cancel work if original request finished
  • [x] skip work that would not produce any benefit in routing (if path from hint is already cached it won't trigger any additional provider lookups)

future scope

We may formalize this by extending IPFSBackend with explicit place to pass this hint, and then wire it up into routing system of Kubo, but it feels more involved and would like to do that in follow-up, rather than block on it here.

lidel avatar Mar 22 '24 23:03 lidel

Codecov Report

Attention: Patch coverage is 11.11111% with 64 lines in your changes are missing coverage. Please review.

Project coverage is 59.69%. Comparing base (b101ba0) to head (39a8bd7).

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #592      +/-   ##
==========================================
- Coverage   59.78%   59.69%   -0.10%     
==========================================
  Files         232      232              
  Lines       28124    28197      +73     
==========================================
+ Hits        16815    16833      +18     
- Misses       9837     9892      +55     
  Partials     1472     1472              
Files Coverage Δ
gateway/handler.go 70.63% <11.11%> (-7.65%) :arrow_down:

... and 15 files with indirect coverage changes

codecov[bot] avatar Mar 23 '24 00:03 codecov[bot]