Stack POL: Downline Banners program (member payouts = contract Paid events to sponsors and line spots, company + fund excluded); indexer reads LinkSpin/InstantAdPay data from MySQL (docstore docs table, via each app's DOCSTORE_URL) since those files moved there 2026-11-13: LinkSpin accounts, Banner Spins, spin links and InstantAdPay stack-optin (switch-offs + Pro)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-13 10:37:52 -06:00
parent 3d74fa8195
commit 8bde289c39
2 changed files with 49 additions and 7 deletions
+3
View File
@@ -10,6 +10,9 @@ const PROGRAMS = [
{ k: 'ls', slug: 'linkspin', n: 'LinkSpin', c: '#3b82f6', kind: 'Link tools', site: 'https://linkspin.app', join: u => 'https://linkspin.app/join/' + encodeURIComponent(u), { k: 'ls', slug: 'linkspin', n: 'LinkSpin', c: '#3b82f6', kind: 'Link tools', site: 'https://linkspin.app', join: u => 'https://linkspin.app/join/' + encodeURIComponent(u),
d: 'Free link tools: spin links that rotate your traffic, bridge pages built from any offer link, banner spins and ad zones. Package sales pay the sponsor line in POL in the same transaction.', d: 'Free link tools: spin links that rotate your traffic, bridge pages built from any offer link, banner spins and ad zones. Package sales pay the sponsor line in POL in the same transaction.',
how: 'Payouts here are the referral payments the LinkSpin smart contract sends up the sponsor line when a package sells, in the same transaction as the purchase.' }, how: 'Payouts here are the referral payments the LinkSpin smart contract sends up the sponsor line when a package sells, in the same transaction as the purchase.' },
{ k: 'dlb', slug: 'downline-banners', n: 'Downline Banners', c: '#c6f432', kind: 'Banner board', site: 'https://downlinebanners.com', join: u => 'https://downlinebanners.com/?ref=' + encodeURIComponent(u),
d: 'The network banner board on Polygon. A $5 spot buys 300 guaranteed views on the board and a place in one line; when later spots sell, the contract pays the 10 spots above them and the buyer\'s sponsor in the same transaction. Nothing is promised.',
how: 'Payouts here are the payments the Downline Banners smart contract sends to the buyer\'s sponsor and to the 10 spots above each new spot, in the same transaction as the sale. Company and momentum-fund shares are not counted.' },
{ k: 'ph', slug: 'polhunter', n: 'PolHunter', c: '#a3e635', kind: 'Scavenger hunt', site: 'https://polhunter.com', join: g('polhunter'), { k: 'ph', slug: 'polhunter', n: 'PolHunter', c: '#a3e635', kind: 'Scavenger hunt', site: 'https://polhunter.com', join: g('polhunter'),
d: 'Hunt hidden codes on sites across the network. Every find drips POL straight to your wallet.' }, d: 'Hunt hidden codes on sites across the network. Every find drips POL straight to your wallet.' },
{ k: 'ec', slug: 'earners-corner', n: 'Earners Corner', c: '#a78bfa', kind: 'Community forum', site: 'https://earnerscorner.com', join: u => 'https://instantadpay.com/forum/join/' + encodeURIComponent(u), { k: 'ec', slug: 'earners-corner', n: 'Earners Corner', c: '#a78bfa', kind: 'Community forum', site: 'https://earnerscorner.com', join: u => 'https://instantadpay.com/forum/join/' + encodeURIComponent(u),
+46 -7
View File
@@ -9,7 +9,8 @@ It builds one snapshot (network totals, per-program totals, last 7 days, latest
POSTs it to https://stackpol.com/api/ingest with the key in /root/.stackpol-ingest-key. Nothing is written anywhere else. POSTs it to https://stackpol.com/api/ingest with the key in /root/.stackpol-ingest-key. Nothing is written anywhere else.
The ledger shows each payout's username (Marty 2026-11-09); only opted-in members get a public stack page. The ledger shows each payout's username (Marty 2026-11-09); only opted-in members get a public stack page.
Usage: indexer.py [--dry] (print a summary, no POST)""" Usage: indexer.py [--dry] (print a summary, no POST)"""
import json, os, subprocess, sys, time, urllib.request, glob import json
import re, os, subprocess, sys, time, urllib.request, glob
VOL = '/var/lib/docker/volumes' VOL = '/var/lib/docker/volumes'
GAMES = { # key: (volume dir glob, file) GAMES = { # key: (volume dir glob, file)
@@ -27,6 +28,13 @@ GAMES = { # key: (volume dir glob, file)
EC_PAYOUTS = 'http://10.100.0.2:18950/payouts' EC_PAYOUTS = 'http://10.100.0.2:18950/payouts'
PD_VOL = 'w94d6qjry9wjp0pwqzxheora-passivedrip-engine-data' PD_VOL = 'w94d6qjry9wjp0pwqzxheora-passivedrip-engine-data'
CHAINS = {'iap': 'h8jd2hmt9y3c1gco9ed5nmva-instantadpay-data', 'ls': 'c10c6soppcsowxsgbrufqb01-*linkspin-prod-data'} CHAINS = {'iap': 'h8jd2hmt9y3c1gco9ed5nmva-instantadpay-data', 'ls': 'c10c6soppcsowxsgbrufqb01-*linkspin-prod-data'}
# Downline Banners (2026-11-13): its chain index (a file on purpose, a rebuildable cache); member payouts = Paid events with role 0
# (sponsor) or 1 (line level) to anyone but the contract and the two company wallets
DLB_VOL = 'gwjsodgtgtc2drdja1ndm0q7*bannerline-data'
DLB_HOUSE = {'0x6c77fc0664f58cf17e81966160fc80005a110f9b', '0x7627fc78876948ac9d95c1c9eb061e7d6d647b70', '0x8b7d33849a2c4d92c985be31e46dc564ba901ad2'}
# The sites keep their data documents in MySQL since 2026-11-13 (docstore.js, table docs). doc() reads one through the app's own
# DOCSTORE_URL, inside the database container; falls back to the volume file for an app still on files.
APPS = {'iap': 'h8jd2hmt9y3c1gco9ed5nmva', 'ls': 'c10c6soppcsowxsgbrufqb01'}
IAP_UUID = 'h8jd2hmt9y3c1gco9ed5nmva' IAP_UUID = 'h8jd2hmt9y3c1gco9ed5nmva'
HERE = '/root/stackpol-indexer' HERE = '/root/stackpol-indexer'
URL = 'https://stackpol.com/api/ingest' URL = 'https://stackpol.com/api/ingest'
@@ -54,6 +62,26 @@ def ms(v):
return int(v if v > 1e12 else v * 1000) return int(v if v > 1e12 else v * 1000)
def doc(app, name, default):
c = subprocess.run(['docker', 'ps', '--format', '{{.Names}}'], capture_output=True, text=True).stdout.split()
cont = next((x for x in c if x.startswith(APPS[app])), None)
url = subprocess.run(['docker', 'exec', cont, 'printenv', 'DOCSTORE_URL'], capture_output=True, text=True).stdout.strip() if cont else ''
if not url:
d = voldir(CHAINS[app])
return load(os.path.join(d, name), default) if d else default
m = re.match(r'mysql://([^:]+):([^@]+)@([^:/]+)(?::\d+)?/([A-Za-z0-9_]+)', url)
if not m:
return default
user, pw, host, db = m.groups()
r = subprocess.run(['docker', 'exec', '-i', '-e', 'MYSQL_PWD=' + pw, host, 'mysql', '--default-character-set=utf8mb4', '-u' + user, db, '-N', '-B', '--raw', '-e',
"SELECT body FROM docs WHERE name='%s'" % name.replace("'", "")], capture_output=True, timeout=60, stdin=subprocess.DEVNULL)
try:
out = r.stdout.decode('utf-8')
return json.loads(out) if out.strip() else default
except Exception:
return default
def iap_wallet_users(): def iap_wallet_users():
"""{address_lower: username} from IAP accounts + positions, via the IAP container (its DATABASE_URL never leaves it).""" """{address_lower: username} from IAP accounts + positions, via the IAP container (its DATABASE_URL never leaves it)."""
c = subprocess.run(['docker', 'ps', '--format', '{{.Names}}'], capture_output=True, text=True).stdout.split() c = subprocess.run(['docker', 'ps', '--format', '{{.Names}}'], capture_output=True, text=True).stdout.split()
@@ -123,10 +151,21 @@ def main():
if pol <= 0: if pol <= 0:
continue continue
rows.append({'k': k, 'pol': pol, 'tx': e['tx'], 'ts': ms(e.get('ts')), 'w': acct.get(e.get('recipientId'), ''), 'gu': ''}) rows.append({'k': k, 'pol': pol, 'tx': e['tx'], 'ts': ms(e.get('ts')), 'w': acct.get(e.get('recipientId'), ''), 'gu': ''})
d = voldir(DLB_VOL)
for e in (load(os.path.join(d, 'chain-index.json'), {}) if d else {}).get('events', []) or []:
if e.get('type') != 'Paid' or e.get('role') not in (0, 1) or str(e.get('to', '')).lower() in DLB_HOUSE:
continue
try:
pol = int(e.get('amount') or 0) / 1e18
except Exception:
continue
if pol > 0:
rows.append({'k': 'dlb', 'pol': pol, 'tx': e['tx'], 'ts': ms(e.get('ts') or 0), 'w': str(e.get('to') or '').lower(), 'gu': ''})
# wallet -> username # wallet -> username
wu = iap_wallet_users() wu = iap_wallet_users()
lsd = voldir(CHAINS['ls']) lsd = voldir(CHAINS['ls'])
for a in (load(os.path.join(lsd, 'accounts.json'), {}).get('byEmail', {}) or {}).values() if lsd else []: ls_accounts = doc('ls', 'accounts.json', {})
for a in (ls_accounts.get('byEmail', {}) or {}).values():
addr, un = str(a.get('address') or '').lower(), str(a.get('username') or '').lower() addr, un = str(a.get('address') or '').lower(), str(a.get('username') or '').lower()
if addr and un and addr not in wu: if addr and un and addr not in wu:
wu[addr] = un wu[addr] = un
@@ -137,7 +176,7 @@ def main():
for line in open(os.path.join(HERE, 'optin.txt'), encoding='utf-8').read().split() if os.path.exists(os.path.join(HERE, 'optin.txt')) else []: for line in open(os.path.join(HERE, 'optin.txt'), encoding='utf-8').read().split() if os.path.exists(os.path.join(HERE, 'optin.txt')) else []:
opt.add(line.strip().lower().lstrip('@')) opt.add(line.strip().lower().lstrip('@'))
iapd = voldir(CHAINS['iap']) iapd = voldir(CHAINS['iap'])
so = load(os.path.join(iapd, 'stack-optin.json'), {}) if iapd else {} so = doc('iap', 'stack-optin.json', {})
# on by default (Marty 2026-11-09): every member who has been paid gets a page; an explicit switch-off in IAP hides it # on by default (Marty 2026-11-09): every member who has been paid gets a page; an explicit switch-off in IAP hides it
opt |= {r['u'] for r in rows if r['u']} opt |= {r['u'] for r in rows if r['u']}
for un, on in (so.get('users', {}) if isinstance(so, dict) else {}).items(): for un, on in (so.get('users', {}) if isinstance(so, dict) else {}).items():
@@ -173,14 +212,14 @@ def main():
# Stack POL Pro (2026-11-09): a paid one-time unlock in IAP. Pro pages (and blog/program pages opened from one) show the member's own # Stack POL Pro (2026-11-09): a paid one-time unlock in IAP. Pro pages (and blog/program pages opened from one) show the member's own
# LinkSpin Banner Spins and spin links in place of the network zones. Matched by username (one identity across IAP and LinkSpin). # LinkSpin Banner Spins and spin links in place of the network zones. Matched by username (one identity across IAP and LinkSpin).
pro = {str(k).lower() for k, v in ((so.get('pro') or {}) if isinstance(so, dict) else {}).items() if v} pro = {str(k).lower() for k, v in ((so.get('pro') or {}) if isinstance(so, dict) else {}).items() if v}
if pro and lsd: if pro:
em = {} em = {}
for e, a in (load(os.path.join(lsd, 'accounts.json'), {}).get('byEmail', {}) or {}).items(): for e, a in (ls_accounts.get('byEmail', {}) or {}).items():
un = str(a.get('username') or '').lower() un = str(a.get('username') or '').lower()
if un in pro: if un in pro:
em[str(e).lower()] = un em[str(e).lower()] = un
bs = load(os.path.join(lsd, 'bannerspin.json'), {}).get('spins', []) or [] bs = doc('ls', 'bannerspin.json', {}).get('spins', []) or []
rt = load(os.path.join(lsd, 'rotator.json'), {}).get('rotations', []) or [] rt = doc('ls', 'rotator.json', {}).get('rotations', []) or []
for un in pro: for un in pro:
if un not in stacks: if un not in stacks:
continue continue