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

Function _persistState

src/gep/validator/stakeBootstrap.js:140–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

138}
139
140function _persistState() {
141 // NOTE(windows): mode 0o700 / 0o600 are silently ignored on Windows.
142 // The stake-state file will NOT be access-restricted to the current user.
143 // Only user-profile directory ACLs provide isolation on Windows.
144 try {
145 const file = _stateFile();
146 const dir = path.dirname(file);
147 if (!fs.existsSync(dir)) {
148 fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
149 }
150 const snapshot = {
151 nextAttemptAt: _state.nextAttemptAt,
152 transientFailures: _state.transientFailures,
153 fundsFailures: _state.fundsFailures,
154 lastSuccessAt: _state.lastSuccessAt,
155 // disabledUntilRestart intentionally omitted
156 savedAt: Date.now(),
157 };
158 fs.writeFileSync(file, JSON.stringify(snapshot), { encoding: 'utf8', mode: 0o600 });
159 } catch (_) {
160 // best-effort: ignore disk failures (e.g. read-only FS in sandbox)
161 }
162}
163
164function resetBackoff() {
165 _state.transientFailures = 0;

Callers 1

ensureValidatorStakeFunction · 0.85

Calls 1

_stateFileFunction · 0.70

Tested by

no test coverage detected