MCPcopy Create free account
hub / github.com/EvoMap/evolver / _writeLedger

Function _writeLedger

src/atp/autoBuyer.js:132–143  ·  view source on GitHub ↗
(ledger)

Source from the content-addressed store, hash-verified

130}
131
132function _writeLedger(ledger) {
133 try {
134 const dir = getMemoryDir();
135 if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
136 const tmp = _ledgerPath() + '.tmp';
137 fs.writeFileSync(tmp, JSON.stringify(ledger, null, 2));
138 fs.renameSync(tmp, _ledgerPath());
139 } catch (_) {
140 // Non-fatal: ledger persistence failure means next process restart
141 // re-reads previous ledger (so existing caps still apply).
142 }
143}
144
145function _rotateIfNewDay(ledger, now) {
146 const today = _todayKey(now);

Callers 2

startFunction · 0.70
_considerOrderSerializedFunction · 0.70

Calls 2

getMemoryDirFunction · 0.85
_ledgerPathFunction · 0.70

Tested by

no test coverage detected