YourProgramBuilder, the Seed Bed (Marty 2026-11-17: "keep fleshing it out"): STAGING build
Plant a program free (referral link with {id}, link check green / yellow / red, daily recheck, reports), members save their
referral IDs in its packet, a sponsor-first link (member page / ?r= / the hub sponsor line, then the planter), the sprout meter
to REVIEW_SAVES (DEFAULT 25) -> Marty's review queue -> approved packets exported for the CTB builder / DownlineHydra wild heads
with every saved ID. Dormant old programs confirmed by their owner, old-link redirects (oldrefs), Spotlight on YPBShop (NOT
deployed; DEFAULT $10 / 1,000 views, 20/5/5/5/5, company 60), verified views with Spotlight delivery, trust pack (ledger,
contract, toasts, Telegram card, terms / disclaimer / privacy, TrustClickz only), network footer row, chatbot, promo kit,
Guides, PolHunter slot, LinkSpin tracked-link and zone hooks, AI writer through the hub. Seed-catalog look from the approved
mockup. Tests: qa/unit.test.cjs 33/33, qa/e2e.mjs 121/121 on a local anvil chain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
// A member's sponsor line from the network hub (the one source of truth, Marty 2026-11-13/14). Walks hubpeople.sponsorOf()
|
||||
// up to `max` places, nearest first: [{ depth, id, username, wallet }]. Used two ways:
|
||||
// - member pages (viraladblitz.com/<username>): the ads of the first 5 people above with a live ad here
|
||||
// - Boost vouchers: the wallets of the line, bound on chain on the buyer's first Boost (VABShop binds link by link)
|
||||
// Answers are cached 5 minutes per start person. {ok: false} = the hub did not answer all the way (the line is partial); the
|
||||
// caller decides (pages fall back to the last good line; vouchers are not signed on a partial line).
|
||||
'use strict';
|
||||
const hubpeople = require('./hubpeople');
|
||||
|
||||
const TTL = () => Number(process.env.HUB_CACHE_MS || 5 * 60000);
|
||||
const cache = new Map(); const lastGood = new Map();
|
||||
|
||||
async function walk(person, max) {
|
||||
const line = []; const seen = new Set([person.id]); let p = person;
|
||||
for (let depth = 1; depth <= max; depth++) {
|
||||
if (!p.sponsor || !p.sponsor.id) return { ok: true, line };
|
||||
if (seen.has(p.sponsor.id)) return { ok: true, line, loop: true }; // a loop in the hub data: stop
|
||||
// the raw hub answer (blocked people included) so the walk goes on past a blocked sponsor; callers skip `blocked` entries
|
||||
// (Boost orders: a blocked member earns nothing and the level passes up, Marty 2026-11-17)
|
||||
if (!/^h_[0-9a-f]{16}$/.test(String(p.sponsor.id))) return { ok: true, line };
|
||||
const r = await hubpeople.resolve({ id: String(p.sponsor.id) }); if (!r.ok) return { ok: false, line };
|
||||
if (!r.person) return { ok: true, line };
|
||||
seen.add(r.person.id);
|
||||
line.push({ depth, id: r.person.id, username: r.person.username ? String(r.person.username) : null, wallet: hubpeople.wallet(r.person), blocked: !!r.person.blocked });
|
||||
p = r.person;
|
||||
}
|
||||
return { ok: true, line };
|
||||
}
|
||||
|
||||
// start = { ref: username } | { wallet }. -> { ok, person, line, stale? }
|
||||
async function lineOf(start, max) {
|
||||
const k = JSON.stringify(start) + '|' + max; const hit = cache.get(k);
|
||||
if (hit && Date.now() - hit.at < TTL()) return hit.v;
|
||||
const me = start.wallet ? await hubpeople.byWallet(start.wallet) : await hubpeople.byRef(start.ref);
|
||||
let v;
|
||||
if (!me.ok) v = { ok: false, person: null, line: [] };
|
||||
else if (!me.person) v = { ok: true, person: null, line: [] };
|
||||
else { const w = await walk(me.person, max); v = { ok: w.ok, person: me.person, line: w.line }; }
|
||||
if (v.ok) { cache.set(k, { at: Date.now(), v }); lastGood.set(k, v); if (cache.size > 20000) cache.clear(); if (lastGood.size > 20000) lastGood.clear(); return v; }
|
||||
const lg = lastGood.get(k); return lg ? Object.assign({}, lg, { ok: false, stale: true }) : v;
|
||||
}
|
||||
|
||||
module.exports = { lineOf, walk, _reset: () => { cache.clear(); lastGood.clear(); } };
|
||||
Reference in New Issue
Block a user