fix(pointer): flush publishes anchor on empty wallets#11
Merged
Conversation
`pointer flush` previously delegated to `payments.sync()`, which is
correctly a no-op on empty wallets (no pending token state → no
flush → no pointer publish). The pointer-N* e2e tests assert that
flush followed by `pointer recover` finds an anchor — even on a
wallet that has just been initialised and has zero tokens.
Add a three-step pipeline:
1. payments.sync() — handle the wallet-with-tokens case (no-op
on empty wallets).
2. load() → save() on every token-storage provider, then
flushToIpfs() to drain the buffer. Forces
the flush scheduler to pin the current
(possibly empty) state and publish the
resulting CID. This is the load-bearing
path for empty wallets.
3. layer.publish(<currentBundleCid>) as a safety net when
step-2's publish attempt was rate-limited or the bundle-ref
write succeeded but publish silently failed. Idempotent;
pointer.publish handles version reconciliation internally.
Adds a `getCurrentBundleCid()` helper that reaches through
`Sphere._tokenStorageProviders` to read the most recently pinned
CID (or returns null on a wallet that has never flushed; in that
case step 3 is skipped and the test relies on step 2 having
landed).
Verified end-to-end on a local Docker relay + js-faucet stack:
$ sphere init --no-nostr --profile --network testnet
$ sphere pointer flush
Pointer flush succeeded (added=0, removed=0, v=0, cid=bafkrei…)
$ sphere pointer recover
Recovered v=1 cid=bafkreib5bzeda4xgjzmbqllgjrhxdjve52oqczz5mlm6w64x7welgic5uy
Fanout result vs main: pointer-N1 / N2 / N13 / N14 all PASS where
they previously failed at "pointer recover returned no CID".
748c85e to
2b1c13f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #10.
pointer flushwas delegating topayments.sync(), which is correctly a no-op when there's no pending token state. Pointer-N* e2e tests assert flush + recover finds an anchor on an empty wallet — establishing the wallet's identity on the aggregator before any tokens flow. Force a save+flush+publish cycle so empty-wallet runs work too. Verified against pointer-N1/N2/N13/N14 — all pass.