From 58f96fc3c55bb24f4d351600948078d1caa7b115 Mon Sep 17 00:00:00 2001 From: Se7enZ Date: Fri, 25 Oct 2024 14:32:34 +0200 Subject: [PATCH] swaps: Don't insert into or select empty addresses from cache. --- Boss/Mod/SwapManager.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Boss/Mod/SwapManager.cpp b/Boss/Mod/SwapManager.cpp index 22467a9c1..f4a7b5c91 100644 --- a/Boss/Mod/SwapManager.cpp +++ b/Boss/Mod/SwapManager.cpp @@ -280,6 +280,8 @@ class SwapManager::Impl { /* First, try to get an address from the addrcache. */ auto check = tx.query(R"QRY( SELECT id, address FROM "SwapManager_addrcache" + WHERE address IS NOT NULL + AND address <> '' ORDER BY id LIMIT 1 ; @@ -626,12 +628,14 @@ class SwapManager::Impl { auto address = std::string(); for (auto& r : fetch) address = r.get(0); - tx.query(R"QRY( - INSERT INTO "SwapManager_addrcache" - VALUES(NULL, :address); - )QRY") - .bind(":address", address) - .execute(); + if (!address.empty()) { + tx.query(R"QRY( + INSERT INTO "SwapManager_addrcache" + VALUES(NULL, :address); + )QRY") + .bind(":address", address) + .execute(); + } /* Delete the swap itself. */ tx.query(R"QRY(