Draft: distance result precomputation
Outputs the result of the distance computation for all identities in a json file in the form:
{"block":"0x432a43af2b2aef4ab33ac9a4323b1f084b86388bc46744f7ce5936a5bbcd07f6","results":{"4":4,"1":4,"3":4,"2":4},"referees":4}
This file can be computed regularly and served directly through nginx. This would allow the clients to have a recent estimate of the distance result before requesting evaluation.
The goal is to include the distance result in squid as suggested in MR nodes/duniter-squid!36.
This MR was taken over by Claude code:
Add distance-precompute command and standalone binary
This MR extracts the distance precomputation logic into a reusable public function and exposes it in two ways: as a standalone binary and as a duniter distance-precompute subcommand.
Changes
distance-oracle/src/lib.rs
- Added DistanceResult struct (serialized to JSON) with block as H256 hex, member_count, referees_count, min_certs_for_referee, and results: BTreeMap<u32, u32>
- Extracted pub async fn precompute(client, output) — computes the distance rule for all members and writes JSON to a file or stdout
distance-oracle/src/bin/distance_precompute.rs
- Thin CLI binary (distance-precompute) wrapping distance_oracle::precompute()
- Options: --rpc-url, --output, --log
node/src/cli.rs / node/src/command.rs
- Added DistancePrecompute subcommand to the duniter node, delegating to the same distance_oracle::precompute()
docker/Dockerfile.distance-precompute + docker/distance-precompute-entrypoint.sh
- Multi-stage Docker image publishing the binary as duniter/distance-precompute-{network}:{version}
- Entrypoint loops with configurable INTERVAL, writes output atomically via a .tmp + mv
docs/user/distance.md
- Documents how to run the precomputation standalone or via the node subcommand