Skip to content

Commit

Permalink
swaps: Don't insert into or select empty addresses from cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
s373nZ committed Dec 10, 2024
1 parent e8cc280 commit 4c7a5f2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Boss/Mod/SwapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
;
Expand Down Expand Up @@ -626,12 +628,14 @@ class SwapManager::Impl {
auto address = std::string();
for (auto& r : fetch)
address = r.get<std::string>(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(
Expand Down

0 comments on commit 4c7a5f2

Please sign in to comment.