Drip Runner trial: IAP hand-off, seeded runs with server replay check, self-funding POL pool (refuel ad share + hangar spends), chapter drips, threshold payouts via faucet (dry run), tester allowlist + briefing page, admin page, e2e test
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Tiny JSON store on the volume. Every collection is one file; writes are atomic (tmp + rename).
|
||||
// PolHunter's data is small (missions, completions, payouts) and a member's balance never lives
|
||||
// here, so a database would be ceremony. If it ever grows, this is the one file to swap.
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
let DIR = null;
|
||||
function init(dir) { DIR = dir; fs.mkdirSync(DIR, { recursive: true }); }
|
||||
const file = name => path.join(DIR, name + '.json');
|
||||
|
||||
function read(name, fallback) {
|
||||
try { return JSON.parse(fs.readFileSync(file(name), 'utf8')); } catch (e) { return fallback; }
|
||||
}
|
||||
function write(name, data) {
|
||||
const f = file(name), tmp = f + '.tmp';
|
||||
fs.writeFileSync(tmp, JSON.stringify(data));
|
||||
fs.renameSync(tmp, f);
|
||||
}
|
||||
// read-modify-write in one place so callers never race themselves
|
||||
function update(name, fallback, fn) {
|
||||
const cur = read(name, fallback);
|
||||
const out = fn(cur) || cur;
|
||||
write(name, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
module.exports = { init, read, write, update };
|
||||
Reference in New Issue
Block a user