upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/rpc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc.cpp')
-rw-r--r--src/rpc.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/rpc.cpp b/src/rpc.cpp
index 3b2dae9..6f81153 100644
--- a/src/rpc.cpp
+++ b/src/rpc.cpp
@@ -341,8 +341,18 @@ static void QueuePayouts(int blockHeight,
341} 341}
342 342
343// Called from event loop: move matured entries to the exec queue (fast). 343// Called from event loop: move matured entries to the exec queue (fast).
344// Save BEFORE moving to exec queue: if we crash between the save and SendMoney, 344// NOT crash-safe, despite the ordering below looking like it is.
345// LoadPendingPayouts re-queues them from the exec-queue section of the file. 345//
346// A matured payout is erased from gPendingPayouts, the file is rewritten
347// without it, and only then does it reach the exec queue -- which lives in
348// memory alone. SavePendingPayouts writes gPendingPayouts and nothing else;
349// there is no exec-queue section of the file to recover from. Die anywhere
350// between the rewrite and SendMoney and those miners are simply never paid,
351// with no record that they were owed anything.
352//
353// Making this safe needs the payment to be idempotent -- record the txid and
354// check the wallet for it on restart -- rather than a reordering, since
355// re-queueing blindly would double-pay whoever was already sent to.
346static void FlushMaturePayouts() 356static void FlushMaturePayouts()
347{ 357{
348 std::vector<PendingPayout> ready; 358 std::vector<PendingPayout> ready;