MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / flush_pending

Function flush_pending

src/cloud.rs:42–56  ·  view source on GitHub ↗

Uploads pending tokens to the worldwide counter. Returns the new worldwide total on success, or None on any failure.

(amount: u64)

Source from the content-addressed store, hash-verified

40/// Uploads pending tokens to the worldwide counter.
41/// Returns the new worldwide total on success, or None on any failure.
42pub fn flush_pending(amount: u64) -> Option<u64> {
43 if amount == 0 {
44 return None;
45 }
46 let body = serde_json::json!({ "amount": amount });
47 let agent = agent_with_timeout(FLUSH_TIMEOUT);
48 let parsed: WorkerResponse = agent
49 .post(&format!("{WORKER_URL}/increment"))
50 .send_json(&body)
51 .ok()?
52 .body_mut()
53 .read_json()
54 .ok()?;
55 Some(parsed.total)
56}
57
58/// Fetches the current worldwide total from the worker.
59/// Returns None on timeout, network error, or parse failure.

Callers 3

try_flushFunction · 0.85
maybe_flush_worldwideMethod · 0.85
shutdownMethod · 0.85

Calls 1

agent_with_timeoutFunction · 0.85

Tested by

no test coverage detected