hubsync: a tank adoption-window expiry (sponsorfollow label 'expire') now reaches the hub as a sponsor change by 'expiry' (the hub's name); before, these moves were silently skipped. qa/hubsync.test.cjs 20/20 (new test fails without the fix)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+8
-4
@@ -26,7 +26,7 @@
|
||||
// Gaps closed 2026-11-13 (Marty: "let's get the gaps report built"), all still one way:
|
||||
// - any later change to a member's username or sponsor goes to /v1/join again (names them; a sponsor only lands where the
|
||||
// hub has none), old members included, not only accounts made since the flag went on;
|
||||
// - a DELIBERATE sponsor change (sponsorfollow: adopt, rescue, release, expiry, admin) goes to /v1/sponsor-change;
|
||||
// - a DELIBERATE sponsor change (sponsorfollow: adopt, rescue, release, expire->expiry, admin) goes to /v1/sponsor-change;
|
||||
// - every MemberActivated on the InstantAdPay contract goes to /v1/contract-bind (contract 'iap', the sponsor by wallet),
|
||||
// by email when the wallet belongs to an account here, else by wallet alone.
|
||||
// - every paid Purchase goes to /v1/contract-spend (2026-11-14, rule 2: the contract with money spent decides the network
|
||||
@@ -41,7 +41,7 @@ const path = require('path');
|
||||
let R = null, st = null, chain_ = Promise.resolve(), timer = null, sending = false, interval = null;
|
||||
const MAX_UP = 25, EVENT_TRIES = 5, OUT_TRIES = 20, KEEP_DONE = 5000;
|
||||
const SHELL_ORIGINS = new Set(['linkspin', 'btc4hits', 'hub']);
|
||||
const DELIBERATE = new Set(['adopt', 'rescue', 'release', 'expiry', 'admin']); // sponsorfollow.js kinds the hub accepts // came here from another site: that site tells the hub itself
|
||||
const DELIBERATE = new Set(['adopt', 'rescue', 'release', 'expire', 'expiry', 'admin']); // sponsorfollow.js kinds the hub accepts // came here from another site: that site tells the hub itself
|
||||
const enabled = () => /^(1|true|yes|on)$/i.test(String(process.env.HUB_ENABLED || '').trim());
|
||||
const URL_ = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
|
||||
const SECRET = () => String(process.env.HUB_SECRET || '').trim();
|
||||
@@ -226,6 +226,10 @@ function wallet(email) {
|
||||
if (a && a.address && !R.accounts.isUnclaimedShell(a)) enqueue('wallet', norm(email)); // a waiting account's wallet came from a sync
|
||||
})().catch(err => console.error('hubsync wallet', err.message));
|
||||
}
|
||||
// sponsorfollow / tank.js label a window expiry 'expire'; the hub (and its DELIBERATE list) calls it 'expiry' (fixed 2026-11-15:
|
||||
// before, IAP window-expiry moves never reached the hub as a sponsor change)
|
||||
const HUB_BY = { expire: 'expiry' };
|
||||
const hubBy = by => HUB_BY[by] || by;
|
||||
const ROUTE = { join: '/v1/join', wallet: '/v1/wallet', sponsor: '/v1/sponsor-change', bind: '/v1/contract-bind', spend: '/v1/contract-spend' };
|
||||
async function bodyFor(item) {
|
||||
if (item.kind === 'spend') {
|
||||
@@ -240,7 +244,7 @@ async function bodyFor(item) {
|
||||
if (item.kind === 'sponsor') {
|
||||
const sp = await R.accounts.sponsorOf(a.email); const rec = R.follow && R.follow.get ? R.follow.get(a.email) : null;
|
||||
if (!rec || !DELIBERATE.has(rec.by) || norm(rec.sponsorEmail) !== (sp ? norm(sp.email) : '')) return null; // superseded since
|
||||
return { email: a.email, sponsorEmail: sp ? sp.email : null, by: rec.by };
|
||||
return { email: a.email, sponsorEmail: sp ? sp.email : null, by: hubBy(rec.by) };
|
||||
}
|
||||
if (item.kind === 'wallet') return a.address ? { email: a.email, wallet: a.address } : null;
|
||||
const sp = await R.accounts.sponsorOf(a.email);
|
||||
@@ -355,4 +359,4 @@ function adminView() {
|
||||
return Object.assign({ enabled: enabled(), on: on(), site: SITE(), url: URL_(), since: s.since, outbox: s.outbox.length, retrying: Object.keys(s.tries).length,
|
||||
disagree: Object.keys(s.disagree).length, tankCache: held.size, tankHubDownUntil: heldDownUntil || null }, s.stats, { disagreements: Object.entries(s.disagree).slice(-25).map(([email, d]) => Object.assign({ email }, d)), recent: s.log.slice(-25).reverse() });
|
||||
}
|
||||
module.exports = { init, enabled, on, receive, touch, wallet, onChain, flush, reconcile, start, adminView, heldAmong, lockedAnywhere, hubSponsor, hubInfo, resolvePerson: q => resolve(q), _sign: sign, _heldReset: () => { held.clear(); heldDownUntil = 0; }, _heldAge: ms => { for (const c of held.values()) c.at -= ms; } };
|
||||
module.exports = { _hubBy: hubBy, init, enabled, on, receive, touch, wallet, onChain, flush, reconcile, start, adminView, heldAmong, lockedAnywhere, hubSponsor, hubInfo, resolvePerson: q => resolve(q), _sign: sign, _heldReset: () => { held.clear(); heldDownUntil = 0; }, _heldAge: ms => { for (const c of held.values()) c.at -= ms; } };
|
||||
|
||||
Reference in New Issue
Block a user