better healthcheck log

Stephen Paul Weber created

Change summary

bin/process_pending_btc_transactions | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

Detailed changes

bin/process_pending_btc_transactions 🔗

@@ -32,7 +32,7 @@ CONFIG =
 	.new(safe: Dhall::Coder::JSON_LIKE + [Symbol, Proc])
 	.load(ARGV[0], transform_keys: :to_sym)
 
-Net::HTTP.post_form(URI("#{CONFIG[:healthchecks_url]}/start"), {})
+Net::HTTP.post(URI("#{CONFIG[:healthchecks_url]}/start"), "")
 
 REDIS = Redis.new
 ELECTRUM = Electrum.new(**CONFIG[:electrum])
@@ -243,7 +243,7 @@ class Customer
 	end
 end
 
-REDIS.hgetall("pending_btc_transactions").each do |(txid, customer_id)|
+done = REDIS.hgetall("pending_btc_transactions").map do |(txid, customer_id)|
 	tx_hash, address = txid.split("/", 2)
 	transaction = ELECTRUM.gettransaction(tx_hash)
 	next unless transaction.confirmations >= CONFIG[:required_confirmations]
@@ -259,10 +259,11 @@ REDIS.hgetall("pending_btc_transactions").each do |(txid, customer_id)|
 			customer.add_btc_credit(txid, btc, amount)
 			customer.plan.activate_any_pending_plan!
 			REDIS.hdel("pending_btc_transactions", txid)
+			txid
 		else
 			warn "No plan for #{customer_id} cannot save #{txid}"
 		end
 	end
 end
 
-Net::HTTP.post_form(URI(CONFIG[:healthchecks_url].to_s), {})
+Net::HTTP.post(URI(CONFIG[:healthchecks_url].to_s), done.compact.join("\n"))