BTC4Hits import, round 2: tank cap 10 at one time (setting tankAdoptCap) with tests; BTC4Hits origin kept on carried shells (joinedRef btc4hits) and the adoption note/email/auto-assign message say their BTC4Hits account moved here; imported spin links may carry every valid URL (admin route maxDests up to 2000, one save per batch), editor shows 50 rows of a big link with Show all, Check now runs in the background past 50, at most one pause email per link per day; chatbot knows /from/btc4hits + the cap (KNOWLEDGE_DATE 2026-11-11). qa: tank-cap 15/15, tank-hold all passed, btc4hits-bridge 21/21, sponsorfollow 30/30
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+7
-3
@@ -25,7 +25,7 @@ let DATA_DIR = null;
|
||||
let chain = null;
|
||||
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
|
||||
const CONTRACT = '0x26Bdc556b94399bEdd69ae3ACA5aA6c54D946e8b';
|
||||
const KNOWLEDGE_DATE = '2026-11-07'; // the day the CANNED answers and FACTS below were last checked against the site
|
||||
const KNOWLEDGE_DATE = '2026-11-11'; // the day the CANNED answers and FACTS below were last checked against the site
|
||||
|
||||
function init(opts) {
|
||||
if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; DATA_DIR = opts.dataDir; chain = opts.chain; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); }
|
||||
@@ -148,9 +148,12 @@ const CANNED = [
|
||||
{ id: 'tank-hold', title: 'Matched with a sponsor (payouts on hold)', q: ['Why can I not switch on payouts?', 'It says I am being matched with a sponsor'], tags: ['holding tank', 'switch on payouts', 'matched with a sponsor', 'ready to activate'],
|
||||
re: /(being matched|matched with a sponsor|(can.?t|cannot|unable to) (i )?(switch on|turn on|activate) (my )?payouts|activate (button|payouts) (is )?(gone|missing|hidden)|ready to activate)/i,
|
||||
a: 'You joined without a sponsor, so you are in the holding tank. If someone invited you, type their username in the Who invited you? box and this ends right away. The contract locks your sponsor for good the moment your payouts are switched on, so the site waits for a real member to pick you up instead of placing you under the company. First it checks the network: if InstantAdPay already has a sponsor for your email or wallet, you are placed under them right away. Otherwise members see you at the top of their holding tank with a Ready to activate badge once your wallet is linked, and if nobody adopts you within 24 hours the site assigns you to the next eligible member in turn (someone active with their own $25 package). As soon as you have a sponsor, the site switches your payouts on under them for you (no cost to you) and tells you, with the transaction link. Buying is never held: you can buy a package at any time, but a purchase made before you have a sponsor places you under the platform position for good.' },
|
||||
{ id: 'btc4hits', title: 'BTC4Hits moved to LinkSpin', q: ['I was a BTC4Hits member, where is my account?', 'What happened to BTC4Hits?', 'Where is my BTC4Hits rotator?'], tags: ['btc4hits', 'rotator', 'moved', 'old account'],
|
||||
re: /btc ?4 ?hits/i,
|
||||
a: 'BTC4Hits is now LinkSpin. If your BTC4Hits email checked out as deliverable, your account came over on 2026-11-11: sign in at linkspin.app/from/btc4hits with the same email (we send you a code, there is no password). Your BTC4Hits sponsor came with you when they were also a member here; if not, you wait in the holding tank, where a member can pick you up as your sponsor, or you can name the person who invited you in the Who invited you? box. Rotators that had visits in the last month are now LinkSpin spin links on your Links screen, named BTC4Hits rotator and the old number, and the old btc4hits.com rotator link forwards to them. Destination URLs that no longer worked were left out. Every other btc4hits.com page now opens linkspin.app/from/btc4hits. Pro upgrades and any old BTC4Hits commissions do not carry over.' },
|
||||
{ id: 'holding-tank', title: 'Holding tank and adoptions', q: ['What is the holding tank?', 'How do I adopt a member?'], tags: ['holding tank', 'adopt', 'no sponsor'],
|
||||
re: /(holding tank|adopt|no sponsor|without a sponsor|orphan)/i,
|
||||
a: 'Members who join from the public site with no sponsor wait in the holding tank under More, My line, unless the network already knows their sponsor (the same email or wallet on InstantAdPay), in which case they are placed under that sponsor. A new sign-up shows an Opens in badge with no Adopt button for their first 24 hours, so they have a day to tell us who invited them (the 24-hour safety net for wallet-linked members still runs on its own clock). After that, a member who has switched on payouts and bought their own qualifying package can adopt one, first come, with a 7-day window for the new member to link a wallet or buy; otherwise they return to the tank. Adopting sets the sponsor, and their first purchase then binds to the adopter on the contract. Members who have linked a wallet show a Ready to activate badge with the hours left and sit at the top of the list; adopting one switches their payouts on under you right away. If nobody adopts them within 24 hours, the site assigns them to the next eligible adopter in turn (own $25 package, fewer than 2 open adoptions, signed in within the last 7 days); the one assigned least recently goes first. Someone waiting in the InstantAdPay tank as well is assigned there, and the adoption carries over to LinkSpin.' },
|
||||
a: 'Members who join from the public site with no sponsor wait in the holding tank under More, My line, unless the network already knows their sponsor (the same email or wallet on InstantAdPay), in which case they are placed under that sponsor. A new sign-up shows an Opens in badge with no Adopt button for their first 24 hours, so they have a day to tell us who invited them (the 24-hour safety net for wallet-linked members still runs on its own clock). After that, a member who has switched on payouts and bought their own qualifying package can adopt one, first come, with a 7-day window for the new member to link a wallet or buy; otherwise they return to the tank. Adopting sets the sponsor, and their first purchase then binds to the adopter on the contract. Members who have linked a wallet show a Ready to activate badge with the hours left and sit at the top of the list; adopting one switches their payouts on under you right away. If nobody adopts them within 24 hours, the site assigns them to the next eligible adopter in turn (own $25 package, fewer than 10 people held from the tank who have not switched on payouts yet, signed in within the last 7 days); the one assigned least recently goes first. Someone waiting in the InstantAdPay tank as well is assigned there, and the adoption carries over to LinkSpin.' },
|
||||
{ id: 'team', title: 'My line: the Team screen', q: ['How do I see my downline?', 'Who is in my team?'], tags: ['team', 'my line', 'downline', 'levels'],
|
||||
re: /(my line|downline|my team|who (is|are) (in|on) my|three levels|level 1\b)/i,
|
||||
a: 'Team shows your line as a working table, three levels deep: who joined through your link, who has switched on payouts, who has bought, and how many qualifying buyers each person has. The chip count is what opens your levels: two qualifying buyers ($25 or larger) open level 2, five open level 3.' },
|
||||
@@ -205,9 +208,10 @@ ${refuelFact()}${synFact()}- PRODUCT, all free with an email account: SPIN LINKS
|
||||
- ACCOUNT: join at ${SITE_URL}/join with email only, a six-digit code, no password. Wallet linking happens inside the Control Room (Credits screen): one signature to link, then payouts switch on by activating (one transaction, gas only) or by buying any package. SafePal is the recommended wallet; MetaMask, Phantom (turn Polygon on first) and any WalletConnect wallet work; Trust Wallet blocks a buy that spends most of its POL. No card button on the site: members buy POL with a card on any major exchange or on-ramp, then send it to their own wallet on the Polygon network (guide at ${SITE_URL}/wallets); never name a specific exchange or on-ramp brand.
|
||||
- SPONSOR: the invite link opened most recently sets the sponsor (30-day cookie), shown on the join page, locked when the account is created; the contract binds the buyer to that sponsor at the first purchase. CARRY-OVER: Crypto Team Build Network members who sign in with the email they use on InstantAdPay get their InstantAdPay sponsor from the network registry automatically when no invite link was used. Wrong sponsor before the first purchase: the admin can move the account. Members should switch on payouts before their people buy.
|
||||
- CONTROL ROOM screens: Links, Pages, Zones (with Audiences), Ads, Credits, Reports, Team (three levels, who has payouts on, who bought, qualifying-buyer counts), Wallet (what was paid to this wallet, payout history). More at ${SITE_URL}/tools: Promo tools, Training, Pipeline (a follow-up board for prospects and directs), My line (including the holding tank: members who joined with no sponsor wait there and can be adopted by a member with payouts on and their own qualifying package), Profile.
|
||||
- BTC4HITS (2026-11-11): the closed BTC4Hits rotator site moved here. Its members with a deliverable email were imported as waiting accounts (InstantAdPay first, carried here by the registry sync), with their BTC4Hits sponsor when that sponsor was also imported or already a member, otherwise into the holding tank. Sign-in page: /from/btc4hits (same email, code sign-in, no welcome-back credits). Rotators with visits in the last month became spin links named 'BTC4Hits rotator #<old id>' on the owner's account with every working destination (dead, parked or erroring URLs left out), on a 'BTC4Hits' traffic source; btc4hits.com/ro.php?id=<id> forwards to the spin link, other btc4hits.com pages go to /from/btc4hits. Pro status and old BTC4Hits commissions do not carry over. HOLDING TANK CAP: an adopter may hold up to 10 people from the tank at one time (open adoptions whose person has not switched on payouts yet; was 2).
|
||||
- WHO INVITED YOU (2026-11-07, Marty approved): a member with no sponsor and no member number sees a Who invited you? box at the top of their Control Room screens. They type a username, confirm in an in-page box, and that member becomes their sponsor (it follows to InstantAdPay, lifts the hold, and the sponsor gets a new-referral email and notice); with a wallet already linked the site switches their payouts on under that sponsor right away. Refused: themselves, a username that does not exist, someone in their own line, a member who cannot take new members, a member with no payouts on and nobody above them on the contract, and anyone who already has a sponsor or a member number. Nobody invited me hides the box (a small link under More brings it back while they are in the tank) and changes nothing else. It never blocks the site. It is not an adoption: no 7-day window and it does not count toward the two.
|
||||
- SIGN-UP GRACE (2026-11-07): for 24 hours from sign-up nobody can adopt a member by hand. The 24-hour auto-assign is unchanged and runs from the wallet link, so a member who links a wallet in their first hour is matched about 24 hours after linking, with at most a short hand-adoption window first. Members back in the tank later have no grace.
|
||||
- HOLDING TANK ACTIVATION HOLD (2026-10-27): a member with no sponsor is first matched to their network sponsor (the same email or wallet with a sponsor on InstantAdPay). Nobody known: the free Switch on payouts waits for an adopter and the Credits screen says "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left; they show at the top of every holding tank with a green Ready to activate badge and the hours left, and the shared payments topic on Telegram is told. Nobody adopts in 24 hours: the site assigns them to the next eligible adopter in rotation (own $25+ package, fewer than 2 open adoptions, signed in within 7 days; least recently auto-assigned first), and the pickup is posted marked (auto-assigned). The moment they have a sponsor (adopted, assigned or matched), the site switches their payouts on under that sponsor (engine-paid) and sends them the transaction link. A PURCHASE IS NEVER HELD: a tank member can buy at any time; with no sponsor yet that purchase places them under the platform position for good. Someone who arrived through a sponsor link is never held.
|
||||
- HOLDING TANK ACTIVATION HOLD (2026-10-27): a member with no sponsor is first matched to their network sponsor (the same email or wallet with a sponsor on InstantAdPay). Nobody known: the free Switch on payouts waits for an adopter and the Credits screen says "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left; they show at the top of every holding tank with a green Ready to activate badge and the hours left, and the shared payments topic on Telegram is told. Nobody adopts in 24 hours: the site assigns them to the next eligible adopter in rotation (own $25+ package, fewer than 10 people held from the tank who have not switched on payouts yet, signed in within 7 days; least recently auto-assigned first), and the pickup is posted marked (auto-assigned). The moment they have a sponsor (adopted, assigned or matched), the site switches their payouts on under that sponsor (engine-paid) and sends them the transaction link. A PURCHASE IS NEVER HELD: a tank member can buy at any time; with no sponsor yet that purchase places them under the platform position for good. Someone who arrived through a sponsor link is never held.
|
||||
${launchFact()}
|
||||
- SUPPORT (LIVE 2026-10-16): members open Help in the Control Room (${SITE_URL}/help) to send Marty a ticket (pick a category, a subject, the message), see each ticket's status (Open, Waiting on you, Closed), and read and answer his replies; a badge on the Help item shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at ${SITE_URL}/support, gets a private link to follow the ticket without signing in, and can reply there. The chat can also pass a conversation to support ("Send this to support"). Marty answers every ticket himself; there is no support email address, point people to ${SITE_URL}/support instead. Tickets share one desk with the rest of the Crypto Team Build Network.
|
||||
- Leaderboard at ${SITE_URL}/leaderboard ranks members by packages sold to direct referrals (weekly, monthly, all time; weekly and monthly prizes are ad credits, never cash).
|
||||
|
||||
@@ -108,10 +108,12 @@ function apply(r, d, c) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const toldToday = new Set();
|
||||
async function tell(r, d, change) {
|
||||
if (!notify || !change || change.kind !== 'paused' || /^demo:/.test(r.owner)) return;
|
||||
const tk = r.id + ':' + ctDay(Date.now()); if (toldToday.has(tk)) return; toldToday.add(tk); if (toldToday.size > 5000) toldToday.clear(); // at most one pause email per link per day (2026-11-11: imported links carry hundreds of pages)
|
||||
const esc = s => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
const html = '<p>LinkSpin paused one destination in your link <b>' + esc(r.name) + '</b> (/r/' + esc(r.code) + ') because it failed three checks in a row.</p>'
|
||||
const html = '<p>LinkSpin paused one destination in your link <b>' + esc(r.name) + '</b> (/r/' + esc(r.code) + ') because it failed three checks in a row. (You get at most one of these emails per link per day; the link\'s Destinations tab shows every paused page.)</p>'
|
||||
+ '<p><span style="font-family:monospace">' + esc(d.url) + '</span><br>' + esc(d.health.note || d.health.state) + '</p>'
|
||||
+ '<p>Visitors keep flowing to your other destinations' + (r.fallback ? ' and the fallback' : '') + '. If the page comes back, LinkSpin resumes it on its own after two clean checks. You can also fix the address or resume it yourself under Links.</p>';
|
||||
try { await notify(r.owner, 'A destination in ' + r.name + ' was paused', html); } catch (e) {}
|
||||
@@ -241,6 +243,7 @@ async function checkRotation(owner, id) {
|
||||
lastManual.set(r.id, Date.now());
|
||||
const jobs = r.destinations.map(d => async () => { const c = await check(d.url); const ch = apply(r, d, c); if (ch) await tell(r, d, ch); });
|
||||
if (r.fallback) jobs.push(async () => { const c = await check(r.fallback); r.fallbackHealth = { state: c.state, code: c.code, ms: c.ms, checkedAt: Date.now(), note: c.note, frameBlocked: !!c.frameBlocked }; });
|
||||
if (jobs.length > 50) { runAll(jobs).then(() => rotator.save()).catch(() => {}); return { ok: true, background: true, rotation: rotator.pub(r) }; } // a big link would outlive the request
|
||||
await runAll(jobs); rotator.save();
|
||||
return { ok: true, rotation: rotator.pub(r) };
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
return 'Checked ' + ago(h.checkedAt) + ', ' + (h.note || h.state) + (d.active ? ', strike ' + h.fails + ' of 3' + (h.fails >= 3 ? ', kept live' : ', pauses at 3') : '');
|
||||
}
|
||||
let HE = null; // the destination editor that is open: { rid, did }
|
||||
const MANY = 60, FIRST = 50; const SHOWALL = new Set(); // big links (imported BTC4Hits rotators, hundreds of pages): first 50 rows until Show all
|
||||
|
||||
async function load(keep) {
|
||||
let r; try { r = await CR.get('/api/my/rotations'); } catch (e) { CR.sub('could not load'); return; }
|
||||
@@ -116,7 +117,8 @@
|
||||
const prevHost = $('destRows').querySelector('[data-he]'); const prev = prevHost && HE && Number(prevHost.dataset.he) === HE.did && prevHost.heState ? prevHost.heState() : null;
|
||||
$('autoNote').hidden = !auto.length;
|
||||
if (auto.length) $('autoNote').textContent = 'LinkSpin paused ' + (auto.length === 1 ? 'one destination' : auto.length + ' destinations') + ' automatically after three failed checks: ' + auto.map(d => (d.label || d.url.replace(/^https?:\/\//, '')).slice(0, 40)).join(', ') + '. It comes back on its own after two clean checks, or fix the address and press Resume.';
|
||||
$('destRows').innerHTML = r.destinations.length ? r.destinations.map(d => { const share = d.active ? Math.round(d.weight / total * 100) : 0; const h = d.health;
|
||||
const big = r.destinations.length > MANY && !SHOWALL.has(r.id); const rows = big ? r.destinations.slice(0, FIRST) : r.destinations;
|
||||
$('destRows').innerHTML = r.destinations.length ? rows.map(d => { const share = d.active ? Math.round(d.weight / total * 100) : 0; const h = d.health;
|
||||
return '<div class="rw" data-did="' + d.id + '"><div><div class="dl"><span class="hdot ' + healthCls(h) + '" title="' + esc(healthLine(d)) + '"></span><span style="font-weight:700">' + esc(d.label || d.url.replace(/^https?:\/\//, '').slice(0, 60)) + '</span>' + (d.hours ? '<button class="hchip set" type="button" data-hc="' + d.id + '" title="This destination has its own hours">' + esc(hoursText(d.hours)) + '</button>' : '') + (h && h.frameBlocked ? '<span class="tag warn" title="This page refuses to load inside a frame (X-Frame-Options or CSP). Traffic exchanges that frame your link will show it blank.">no frames</span>' : '') + '</div>'
|
||||
+ '<div class="mono muted" style="font-size:11px;overflow-wrap:anywhere">' + esc(d.url) + '</div><div class="muted" style="font-size:11px" data-hl="' + d.id + '">' + esc(healthLine(d)) + '</div></div>'
|
||||
+ '<div class="wrow"><div class="bar" style="width:70px"><i style="width:' + share + '%"></i></div><input class="field mono" type="number" min="1" max="100" value="' + d.weight + '" data-w="' + d.id + '" aria-label="Weight"><span class="mono muted" style="font-size:11px">' + share + '%</span></div>'
|
||||
@@ -124,8 +126,10 @@
|
||||
+ '<span class="tag ' + (d.active ? 'ok' : d.autoPaused ? 'bad' : 'dim') + '">' + (d.active ? 'LIVE' : d.autoPaused ? 'AUTO-PAUSED' : 'PAUSED') + '</span>'
|
||||
+ '<span style="display:flex;gap:6px;justify-content:flex-end"><button class="btn sm" type="button" data-hc="' + d.id + '" title="Hours for this destination" aria-label="Hours for this destination"><svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></button><button class="btn sm" type="button" data-t="' + d.id + '">' + (d.active ? 'Pause' : 'Resume') + '</button><button class="btn sm danger" type="button" data-x="' + d.id + '" aria-label="Remove">×</button></span></div>'
|
||||
+ (HE && HE.rid === r.id && HE.did === d.id ? '<div class="rw edit" data-he="' + d.id + '"></div>' : ''); }).join('')
|
||||
+ (big ? '<div class="rw"><span class="muted">Showing ' + FIRST + ' of ' + r.destinations.length + ' destinations (' + r.destinations.filter(d => d.active).length + ' live).</span> <button class="btn sm" type="button" id="destAll">Show all ' + r.destinations.length + '</button></div>' : '')
|
||||
: '<div class="rw"><span class="muted">No destinations yet. Add the first page below; until then the link sends people to the fallback.</span></div>';
|
||||
$('destFoot').textContent = 'weights are shares of the spin · fallback: ' + (r.fallback || 'none set') + ' · bots filtered on the server · one hop · health checked every 30 min';
|
||||
if ($('destAll')) $('destAll').addEventListener('click', () => { SHOWALL.add(r.id); renderDest(r); });
|
||||
const openEditor = did => { const d = r.destinations.find(q => q.id === did); if (!d) return; HE = { rid: r.id, did }; renderDest(r); };
|
||||
$('destRows').querySelectorAll('[data-hc]').forEach(b => b.addEventListener('click', () => { if (HE && HE.rid === r.id && HE.did === Number(b.dataset.hc)) { HE = null; renderDest(r); } else openEditor(Number(b.dataset.hc)); }));
|
||||
const heHost = $('destRows').querySelector('[data-he]');
|
||||
@@ -234,7 +238,7 @@
|
||||
$('hoursChip').addEventListener('click', () => { showTab('hours'); const h = $('rotHours'); if (h.scrollIntoView) h.scrollIntoView({ block: 'start', behavior: 'smooth' }); });
|
||||
$('checkBtn').addEventListener('click', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; const b = $('checkBtn'); b.disabled = true; b.textContent = 'Checking';
|
||||
try { const out = await api('/api/my/rotations/' + r.id + '/health'); const i = ROT.findIndex(x => x.id === r.id); if (i >= 0 && out.rotation) ROT[i] = out.rotation; const fresh = out.rotation || r; renderDest(fresh); select(r.id, true);
|
||||
const bad = fresh.destinations.filter(d => d.health && (d.health.state === 'dead' || d.health.state === 'parked')).length; toast('Checked ' + fresh.destinations.length + ' destination' + (fresh.destinations.length === 1 ? '' : 's') + (bad ? ', ' + bad + ' failing' : ', all answering')); }
|
||||
if (out.background) { toast('Checking all ' + fresh.destinations.length + ' destinations in the background. Open the link again in a few minutes to see the results.'); } else { const bad = fresh.destinations.filter(d => d.health && (d.health.state === 'dead' || d.health.state === 'parked')).length; toast('Checked ' + fresh.destinations.length + ' destination' + (fresh.destinations.length === 1 ? '' : 's') + (bad ? ', ' + bad + ' failing' : ', all answering')); } }
|
||||
catch (e) { toast(e.message, true); } b.disabled = false; b.textContent = 'Check now'; });
|
||||
$('pbNew').addEventListener('click', () => pbForm(null));
|
||||
$('backBtn').hidden = !window.matchMedia('(max-width:760px)').matches;
|
||||
|
||||
+1
-1
@@ -271,7 +271,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/cr-shell.js?v=20261110forum"></script>
|
||||
<script src="/assets/links.js?v=20261021t"></script>
|
||||
<script src="/assets/links.js?v=20261111big"></script>
|
||||
<script src="/assets/banner-spin.js?v=20261105sz"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// Holding-tank adoption cap + BTC4Hits wording (2026-11-11). No server: the real tank.js with in-memory accounts, a fake
|
||||
// chain and a capturing mailer/messages, on a throwaway dir. node qa/tank-cap.test.mjs
|
||||
// Marty: an adopter may hold up to 10 people from the tank at one time (not yet switched on payouts), as a setting;
|
||||
// a BTC4Hits import is told the truth (their BTC4Hits account moved here), never "You joined LinkSpin without a sponsor".
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { createRequire } from 'node:module';
|
||||
const SITE = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
|
||||
const require = createRequire(path.join(SITE, 'package.json'));
|
||||
delete process.env.DATABASE_URL;
|
||||
let fails = 0, passes = 0; const ok = (c, l, x) => { console.log((c ? 'PASS ' : 'FAIL ') + l + (x && !c ? ' ' + String(x).slice(0, 300) : '')); if (c) passes++; else fails++; };
|
||||
const DAY = 86400000;
|
||||
function bench(cap) {
|
||||
delete require.cache[require.resolve(path.join(SITE, 'tank.js'))];
|
||||
const tank = require(path.join(SITE, 'tank.js'));
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'ls-tankcap-'));
|
||||
const by = new Map(); let n = 100; const pub = a => a ? Object.assign({}, a) : null; const find = f => { for (const a of by.values()) if (f(a)) return pub(a); return null; };
|
||||
const accounts = { add(email, o) { by.set(email, Object.assign({ email, username: null, code: 'c' + (n++), sponsorRef: '', memberId: 0, address: null, created: Date.now() - 3 * DAY, lastSeen: 0, joinedVia: 'carried', joinedRef: 'network' }, o || {})); },
|
||||
async byEmail(e) { return pub(by.get(String(e || '').toLowerCase())); }, async byUsername(u) { return find(a => a.username === String(u || '').toLowerCase()); }, async byCode(c) { return find(a => a.code === String(c || '').toLowerCase()); },
|
||||
async byMemberId(id) { return find(a => Number(a.memberId) === Number(id) && id > 0); }, async setSponsorRef(e, ref) { const a = by.get(e); a.sponsorRef = String(ref || ''); return { ok: true }; },
|
||||
async listAll() { return [...by.values()].map(pub); }, async sponsorOf() { return null; }, _by: by };
|
||||
const events = []; const mails = []; const chats = [];
|
||||
tank.init({ dataDir: dir, accounts, chain: { recentEvents: () => events.slice(), getConfig: () => ({ explorer: 'https://polygonscan.com' }) },
|
||||
messages: { sendChat: async (id, from, to, text) => { chats.push({ to, text }); }, lastFrom: async () => 0 },
|
||||
mailer: { hasKey: () => true, send: async (to, subject, text) => { mails.push({ to, subject, text }); } }, site: 'https://linkspin.test',
|
||||
capOpen: cap === undefined ? undefined : () => cap, hooks: {} });
|
||||
accounts.add('adopter@x.co', { username: 'helper', memberId: 77, address: '0x' + '1'.repeat(40), lastSeen: Date.now() - 3600000, joinedVia: null, joinedRef: null });
|
||||
events.push({ type: 'Purchase', buyerId: 77, priceCents: 2500, block: 1 });
|
||||
return { tank, accounts, mails, chats };
|
||||
}
|
||||
{ // default cap 10, measured as people held who have not switched on payouts
|
||||
const B = bench(); const { tank, accounts, mails, chats } = B;
|
||||
for (let i = 0; i < 12; i++) accounts.add('m' + i + '@b4h.test', { joinedRef: i < 6 ? 'btc4hits' : 'network' });
|
||||
ok(tank.capOpen() === 10, 'default cap is 10');
|
||||
let okCount = 0; for (let i = 0; i < 10; i++) { const r = await tank.adopt('adopter@x.co', 'm' + i + '@b4h.test'); if (r.ok) okCount++; else console.log(' adopt ' + i + ': ' + r.error); }
|
||||
ok(okCount === 10, 'adopts 10 in a row');
|
||||
const r11 = await tank.adopt('adopter@x.co', 'm10@b4h.test');
|
||||
ok(r11.error && /helping 10 people/.test(r11.error) && /10 at one time is the most/.test(r11.error) && !/—/.test(r11.error), 'the 11th is refused with a clear message', JSON.stringify(r11));
|
||||
const v = await tank.view('adopter@x.co'); ok(v.cap === 10 && v.eligible === false && /10 at one time/.test(v.reason), 'tank view shows cap 10 and the reason');
|
||||
accounts._by.get('m3@b4h.test').memberId = 901; // one of them switched on payouts: the slot frees at once
|
||||
const r11b = await tank.adopt('adopter@x.co', 'm10@b4h.test'); ok(r11b.ok, 'a held member switching on payouts frees a slot right away', JSON.stringify(r11b));
|
||||
ok((await tank.adopt('adopter@x.co', 'm11@b4h.test')).error, 'and the cap holds again at 10 not yet switched on');
|
||||
// wording
|
||||
const imp = mails.filter(m => m.to === 'm0@b4h.test'); const reg = mails.filter(m => m.to === 'm7@b4h.test');
|
||||
ok(imp.length === 1 && reg.length === 1, 'exactly one email to each adoptee', JSON.stringify(mails.map(m => m.to)));
|
||||
ok(/BTC4Hits has moved to LinkSpin, and your BTC4Hits account came with you/.test(imp[0].text) && /\/from\/btc4hits/.test(imp[0].text) && !/You joined LinkSpin/.test(imp[0].text), 'BTC4Hits import: email says the account moved, points to /from/btc4hits', imp[0].text);
|
||||
ok(/Your BTC4Hits account moved to LinkSpin without a sponsor/.test((chats.find(c => c.to === 'm0@b4h.test') || {}).text || ''), 'BTC4Hits import: the default first chat reads right too');
|
||||
ok(/^You joined LinkSpin without a sponsor/.test(reg[0].text) && /\/my#messages/.test(reg[0].text), 'ordinary tank member keeps the old wording');
|
||||
ok(imp[0].subject === '@helper is now your sponsor on LinkSpin', 'subject unchanged', imp[0].subject);
|
||||
ok(!mails.some(m => /—/.test(m.text + m.subject)), 'no em dash in any adoption email');
|
||||
ok(!mails.some(m => m.to === 'adopter@x.co'), 'no email to the adopter on a hand adoption');
|
||||
}
|
||||
{ // the setting
|
||||
const B = bench(3); const { tank, accounts } = B;
|
||||
for (let i = 0; i < 4; i++) accounts.add('s' + i + '@b4h.test');
|
||||
for (let i = 0; i < 3; i++) await tank.adopt('adopter@x.co', 's' + i + '@b4h.test');
|
||||
const r = await tank.adopt('adopter@x.co', 's3@b4h.test'); ok(r.error && /3 at one time/.test(r.error), 'tankAdoptCap setting is respected (3)', JSON.stringify(r));
|
||||
const B2 = bench('junk'); ok(B2.tank.capOpen() === 10, 'a bad setting falls back to 10');
|
||||
}
|
||||
console.log('\n' + passes + ' passed, ' + fails + ' failed'); process.exit(fails ? 1 : 0);
|
||||
@@ -146,6 +146,8 @@ async function partA() {
|
||||
const f4b = await accounts.byEmail('free4@x.co');
|
||||
ok(f4b.memberId > 0 && sends.slice(n0).every(s => s.sponsorId === 11), 'retried on a later tick and switched on under A (#11), never #1', JSON.stringify(sends.slice(n0)));
|
||||
ok(chats.some(c => c.to === 'free4@x.co' && /Your LinkSpin payouts are now on under @a/.test(c.text)), 'follow-up chat once the retried activation lands');
|
||||
// since 2026-11-11 the cap is people held at one time who have not switched on payouts (default 10): fill A up by hand
|
||||
for (let i = 0; i < tank.capOpen(); i++) { accounts.add('fill' + i + '@x.co'); await tank.adopt('a@x.co', 'fill' + i + '@x.co'); }
|
||||
// A full (2 open), B + C stale: nobody eligible -> keep holding, one admin alert
|
||||
accounts._by.get('b@x.co').lastSeen = env.now - 8 * 86400000; accounts._by.get('c@x.co').lastSeen = env.now - 8 * 86400000;
|
||||
accounts.add('free5@x.co', { address: addr() }); await tank.readyTick(); env.now += 24 * H;
|
||||
|
||||
+8
-3
@@ -130,13 +130,18 @@ async function update(owner, id, body) {
|
||||
J.save(); return { ok: true, rotation: pub(r) };
|
||||
}
|
||||
async function remove(owner, id) { const n = J.db.rotations.length; J.db.rotations = J.db.rotations.filter(r => !(r.id === Number(id) && r.owner === norm(owner))); J.save(); return n !== J.db.rotations.length ? { ok: true } : { error: 'No such rotation.' }; }
|
||||
async function addDest(owner, id, body) {
|
||||
// opts.max: the admin import path only (BTC4Hits rotators, 2026-11-11) may go past the 25 a member can add, up to IMPORT_MAX
|
||||
const DEST_MAX = 25, IMPORT_MAX = 2000;
|
||||
async function addDest(owner, id, body, opts) {
|
||||
const r = J.db.rotations.find(r => r.id === Number(id) && r.owner === norm(owner)); if (!r) return { error: 'No such rotation.' };
|
||||
const url = cleanUrl(body.url); if (!url) return { error: 'Destination must be a full https:// address.' };
|
||||
if (r.destinations.length >= 25) return { error: 'Up to 25 destinations per rotation.' };
|
||||
const cap = opts && opts.max ? Math.min(IMPORT_MAX, Math.max(DEST_MAX, Math.round(Number(opts.max) || DEST_MAX))) : DEST_MAX;
|
||||
if (r.destinations.length >= cap) return { error: 'Up to ' + DEST_MAX + ' destinations per rotation.' };
|
||||
const w = Math.max(1, Math.min(100, Math.round(Number(body.weight) || 1)));
|
||||
const d = { id: r.nextDest++, url, label: String(body.label || '').trim().slice(0, 60), weight: w, active: true, added: Date.now() };
|
||||
r.destinations.push(d); J.save(); return { ok: true, rotation: pub(r) };
|
||||
r.destinations.push(d);
|
||||
if (opts && opts.defer) return { ok: true, id: d.id }; // bulk import: the caller saves once at the end (rotator.json holds every click, ~18 MB; one write per destination would stall the app)
|
||||
J.save(); return { ok: true, rotation: pub(r) };
|
||||
}
|
||||
async function updateDest(owner, id, did, body) {
|
||||
const r = J.db.rotations.find(r => r.id === Number(id) && r.owner === norm(owner)); if (!r) return { error: 'No such rotation.' };
|
||||
|
||||
@@ -829,7 +829,7 @@ function siteConfig() {
|
||||
memberWeeklyEmail: '0', // 1 = the weekly 'Your week on LinkSpin' email goes to every active member, not only sponsors with a line
|
||||
noPayoutIds: '', // LinkSpin member ids differ from InstantAdPay's (IAP #25 = Jim's compromised wallet; LinkSpin #25 is a real member, cleared 2026-10-15). Positions kept for linkage only (compromised wallets): no buys signed from them, no new joins routed under them or their upline chain (Marty, 2026-09-14)
|
||||
leaderboardWeeklyPrize: '', leaderboardMonthlyPrize: '', leaderboardWeeklyCredits: '1000,500,250', leaderboardMonthlyCredits: '5000,2500,1000', leaderboardAnnounceGeneral: '1', // referral contest prizes (text shown on /leaderboard; credits granted to the winner automatically at rollover)
|
||||
tankAdoptCap: 6, // holding tank: people one adopter may hold at one time (not yet switched on payouts), Marty 2026-11-11
|
||||
tankAdoptCap: 10, // holding tank: people one adopter may hold at one time (not yet switched on payouts), Marty 2026-11-11
|
||||
legacyCreditsAdvertiser: 500, legacyCreditsEarner: 150, // welcome-back credits for listed Faucet Wave / Tier One Ads emails arriving via /from/<brand>
|
||||
geoTier1: '', // comma-separated ISO country codes; empty = built-in default (US, CA, GB, AU, NZ, IE, DE, FR, NL, SE, NO, DK, FI, CH, AT, BE)
|
||||
geoTier2: '', // empty = built-in default (rest of Western/Central Europe, JP, KR, SG, HK, TW, IL, Gulf, ZA, BR, MX, AR, CL, CO ...); tier 3 = everything else
|
||||
@@ -2256,7 +2256,9 @@ const server = http.createServer(async (req, res) => {
|
||||
// several destinations (2026-11-11, BTC4Hits rotators): l.urls = [{ url, label }] at equal weight, up to the rotator's own cap of 25
|
||||
const list = Array.isArray(l.urls) && l.urls.length ? l.urls.map(x => typeof x === 'string' ? { url: x } : x) : [{ url: l.url, label: l.label }];
|
||||
if (l.fallback) await rotator.update(a.email, c.rotation.id, { fallback: String(l.fallback) });
|
||||
let added = 0; const destErrors = []; for (const x of list) { const d = await rotator.addDest(a.email, c.rotation.id, { url: String(x.url || ''), label: String(x.label || ''), weight: 1 }); if (d.error) destErrors.push({ url: String(x.url || '').slice(0, 120), error: d.error }); else added++; }
|
||||
const maxDests = Math.max(25, Math.min(2000, Number(b.maxDests) || 25)); // the import may go past the member cap of 25 (BTC4Hits rotators)
|
||||
let added = 0; const destErrors = []; for (const x of list) { const d = await rotator.addDest(a.email, c.rotation.id, { url: String(x.url || ''), label: String(x.label || ''), weight: 1 }, { max: maxDests, defer: true }); if (d.error) destErrors.push({ url: String(x.url || '').slice(0, 120), error: d.error }); else added++; }
|
||||
await rotator.update(a.email, c.rotation.id, {}); // one save for the whole batch of destinations
|
||||
if (!added) { await rotator.remove(a.email, c.rotation.id); out.push({ name: l.name, error: (destErrors[0] || {}).error || 'no destination' }); continue; }
|
||||
if (sourceId) { const up = await rotator.update(a.email, c.rotation.id, { sourceId }); if (up && up.error) out.push({ name: l.name, warn: 'source not attached: ' + up.error }); }
|
||||
out.push({ name: l.name, id: c.rotation.id, code: c.rotation.code, url: 'https://' + host + '/r/' + c.rotation.code, to: list[0].url, dests: added, destErrors });
|
||||
@@ -2969,7 +2971,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const e = String(r.email || '').trim().toLowerCase(); if (!e) continue;
|
||||
let a = await accounts.byEmail(e);
|
||||
const created = !a;
|
||||
if (!a) { const x = await accounts.ensure(e, '', 'carried', 'network'); if (x.created) shells++; a = await accounts.byEmail(e); }
|
||||
if (!a) { const x = await accounts.ensure(e, '', 'carried', r.origin === 'btc4hits' ? 'btc4hits' : 'network'); if (x.created) shells++; a = await accounts.byEmail(e); } // BTC4Hits imports keep their origin (tank mail wording)
|
||||
if (!a) continue;
|
||||
if (Object.prototype.hasOwnProperty.call(r, 'tank')) followStore.setRemote(e, r.tank); // network tank: InstantAdPay's own adoptions of them
|
||||
if (created && SF.incomingOf(r)) { const inc = SF.incomingOf(r); followStore.record(e, { at: inc.at, by: inc.by, sponsorEmail: inc.sponsorEmail, prevEmail: inc.prevEmail, origin: inc.origin || 'instantadpay' }); } // a new shell carries the same record (no echo)
|
||||
|
||||
@@ -12,10 +12,10 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const db = require('./db');
|
||||
|
||||
// How many people an adopter may hold from the tank AT ONE TIME (Marty 2026-11-11, for the ~1,200 BTC4Hits imports; was 2 open
|
||||
// How many people an adopter may hold from the tank AT ONE TIME (Marty 2026-11-11, for the ~1,200 BTC4Hits imports, 6 then 10 the same day; was 2 open
|
||||
// adoptions): open adoptions whose person has not switched payouts on yet (no member id). Activating frees the slot at once; the
|
||||
// 7-day window closes the rest as before. Site setting tankAdoptCap, default 6.
|
||||
const CAP_DEFAULT = 6; let capFn = () => CAP_DEFAULT;
|
||||
// 7-day window closes the rest as before. Site setting tankAdoptCap, default 10.
|
||||
const CAP_DEFAULT = 10; let capFn = () => CAP_DEFAULT;
|
||||
const capOpen = () => { const n = Math.round(Number(capFn())); return n >= 1 && n <= 50 ? n : CAP_DEFAULT; };
|
||||
async function holding(open) { const out = []; for (const ad of open || []) { const a = await accounts.byEmail(ad.adoptee); if (!(a && Number(a.memberId) > 0)) out.push(ad); } return out; }
|
||||
const TTL_MS = 7 * 86400000; // an adoption's window to convert
|
||||
@@ -143,7 +143,10 @@ async function adopt(adopterEmail, who, note, opts) {
|
||||
const r = await setSponsor(target.email, token, 'adopt');
|
||||
if (r.error) return r;
|
||||
const now = Date.now();
|
||||
const text = String(note || '').trim().slice(0, 600) || ('Hi, I am ' + nameOf(me) + '. You joined LinkSpin without a sponsor, so I picked you up from the holding tank. I will walk you through the first three steps whenever you are ready. Reply here.');
|
||||
const tgt0 = await accounts.byEmail(target.email); const b4h = !!(tgt0 && (tgt0.joinedRef === 'btc4hits' || tgt0.joinedVia === 'btc4hits')); // a BTC4Hits import (2026-11-11): they never joined LinkSpin themselves
|
||||
const text = String(note || '').trim().slice(0, 600) || (b4h
|
||||
? 'Hi, I am ' + nameOf(me) + '. Your BTC4Hits account moved to LinkSpin without a sponsor, so I picked you up from the holding tank. I will walk you through the first three steps whenever you are ready. Reply here.'
|
||||
: 'Hi, I am ' + nameOf(me) + '. You joined LinkSpin without a sponsor, so I picked you up from the holding tank. I will walk you through the first three steps whenever you are ready. Reply here.');
|
||||
const ad = await impl().add({ adoptee: target.email, adopter: e, ts: now, expires: now + TTL_MS, status: 'open', note: (opts && opts.recordNote) || text });
|
||||
{ const rr = RS.load().ready[target.email]; if (rr && !rr.done) { rr.done = clock(); rr.adoptedBy = e; RS.save(); } } // the hold lifts: their sponsor resolves now
|
||||
// wallet already linked: the engine switches their payouts on under the adopter right away (Marty approved 2026-10-27)
|
||||
@@ -158,7 +161,9 @@ async function adopt(adopterEmail, who, note, opts) {
|
||||
if (mailer && mailer.hasKey()) {
|
||||
try {
|
||||
await mailer.send(target.email, nameOf(me) + ' is now your sponsor on LinkSpin',
|
||||
'You joined LinkSpin without a sponsor. ' + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + payLine + '\n\nReply in your member area: ' + siteUrl + '/my#messages\n\nLinkSpin');
|
||||
b4h
|
||||
? 'BTC4Hits has moved to LinkSpin, and your BTC4Hits account came with you. ' + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + payLine + '\n\nSign in with the email you used on BTC4Hits (we send you a code, no password) and reply in your member area: ' + siteUrl + '/from/btc4hits\n\nLinkSpin'
|
||||
: 'You joined LinkSpin without a sponsor. ' + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + payLine + '\n\nReply in your member area: ' + siteUrl + '/my#messages\n\nLinkSpin');
|
||||
} catch (err) {}
|
||||
if (auto) {
|
||||
try {
|
||||
@@ -489,7 +494,7 @@ async function autoAssignRun() {
|
||||
if ((await holding(await impl().open(c.a.email))).length >= capOpen()) continue;
|
||||
if (hooks.payoutBlocked && await Promise.resolve(hooks.payoutBlocked(Number(c.a.memberId))).catch(() => true)) continue; // no-payout chain: they would fall to the company after all
|
||||
if (await inDownlineOf(e, c.a)) continue;
|
||||
const msg = 'Hi, I am ' + nameOf(c.a) + '. You joined LinkSpin without a sponsor and nobody picked you up from the holding tank within 24 hours, so you were matched with me. I will walk you through the first steps whenever you are ready. Reply here.';
|
||||
const msg = 'Hi, I am ' + nameOf(c.a) + '. ' + ((a.joinedVia === 'btc4hits' || a.joinedRef === 'btc4hits') ? 'Your BTC4Hits account moved to LinkSpin' : 'You joined LinkSpin') + ' without a sponsor and nobody picked you up from the holding tank within 24 hours, so you were matched with me. I will walk you through the first steps whenever you are ready. Reply here.';
|
||||
const r = await adopt(c.a.email, a.username || e, msg, { auto: true, recordNote: 'auto-assigned after 24 hours in the tank' });
|
||||
if (r && r.ok) { done = { adoptee: e, adopter: c.a.email, adopterName: r.adopterName, adopteeName: r.adopteeName }; break; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user