Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions node/gpu_render_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,19 @@ def gpu_release():
db.rollback()
return jsonify({"error": "Job was already processed"}), 409

# Transfer to provider
db.execute("UPDATE balances SET balance_rtc = balance_rtc + ? WHERE miner_pk = ?", (job["amount_rtc"], job["to_wallet"]))
db.commit()
return jsonify({"ok": True, "status": "released"})
# Transfer to provider — verify the provider has a balances row
credited = db.execute(
"UPDATE balances SET balance_rtc = balance_rtc + ? WHERE miner_pk = ?",
(job["amount_rtc"], job["to_wallet"]),
)
if credited.rowcount != 1:
# Provider has no balances row — create one before crediting
db.execute(
"INSERT INTO balances (miner_pk, balance_rtc) VALUES (?, ?)",
(job["to_wallet"], job["amount_rtc"]),
)
db.commit()
return jsonify({"ok": True, "status": "released"})
except sqlite3.Error as e:
return jsonify({"error": str(e)}), 500
finally:
Expand Down