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
+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.
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)"""
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'
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'
PD_VOL = 'w94d6qjry9wjp0pwqzxheora-passivedrip-engine-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'
HERE = '/root/stackpol-indexer'
URL = 'https://stackpol.com/api/ingest'
@@ -54,6 +62,26 @@ def ms(v):
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():
"""{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()
@@ -123,10 +151,21 @@ def main():
if pol <= 0:
continue
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
wu = iap_wallet_users()
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()
if addr and un and addr not in wu:
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 []:
opt.add(line.strip().lower().lstrip('@'))
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
opt |= {r['u'] for r in rows if r['u']}
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
# 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}
if pro and lsd:
if pro:
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()
if un in pro:
em[str(e).lower()] = un
bs = load(os.path.join(lsd, 'bannerspin.json'), {}).get('spins', []) or []
rt = load(os.path.join(lsd, 'rotator.json'), {}).get('rotations', []) or []
bs = doc('ls', 'bannerspin.json', {}).get('spins', []) or []
rt = doc('ls', 'rotator.json', {}).get('rotations', []) or []
for un in pro:
if un not in stacks:
continue