Skip to main content

Module post_bundle_healing

Module post_bundle_healing 

Source
Expand description

§Peer-to-peer reconciliation of divergent post bundles

When multiple peers return different versions of the same post bundle — one might hold posts the others have missed — this module spawns a background task that sends each laggard peer the posts it’s missing.

The sync is a two-phase, PoW-gated protocol:

  1. Claim (HealPostBundleClaimV1) — the initiator describes what it holds; the remote server returns which post IDs it’s still missing and issues a commit token authorising the follow-up upload.
  2. Commit (HealPostBundleCommitV1) — the initiator uploads just those missing post bytes under the token.

Splitting into claim + commit keeps the bandwidth-hungry upload from happening until the receiver has confirmed it actually wants the data, and it makes per-server response authentication cheap (the token is what the commit carries).

Functions§

heal_post_bundles
Selects and returns the best bundle (most posts), then spawns a background task that serially heals every server whose bundle is missing posts that any other server has. Returns None if bundles is empty.