Fix account_tx marker issue (#699)

Fixes #700
This commit is contained in:
cyan317
2023-06-16 12:29:34 +01:00
committed by GitHub
parent a960471ef4
commit 4cc3b3ec0f
3 changed files with 11 additions and 7 deletions

View File

@@ -528,21 +528,19 @@ public:
SELECT hash, seq_idx
FROM {}
WHERE account = ?
AND seq_idx <= ?
AND seq_idx < ?
LIMIT ?
)",
qualifiedTableName(settingsProvider_.get(), "account_tx")));
}();
// the smallest transaction idx is 0, we use uint to store the transaction index, so we shall use ">=" to
// include it(the transaction with idx 0) in the result
PreparedStatement selectAccountTxForward = [this]() {
return handle_.get().prepare(fmt::format(
R"(
SELECT hash, seq_idx
FROM {}
WHERE account = ?
AND seq_idx >= ?
AND seq_idx > ?
ORDER BY seq_idx ASC
LIMIT ?
)",

View File

@@ -73,8 +73,10 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
}
else
{
// if forward, start at minIndex - 1, because the SQL query is exclusive, we need to include the 0 transaction
// index of minIndex
if (input.forward)
cursor = {minIndex, 0};
cursor = {minIndex - 1, INT32_MAX};
else
cursor = {maxIndex, INT32_MAX};
}

View File

@@ -265,7 +265,7 @@ TEST_F(RPCAccountTxHandlerTest, IndexSpecificForwardTrue)
testing::_,
testing::_,
true,
testing::Optional(testing::Eq(TransactionsCursor{MINSEQ + 1, 0})),
testing::Optional(testing::Eq(TransactionsCursor{MINSEQ, INT32_MAX})),
testing::_))
.Times(1);
@@ -344,7 +344,11 @@ TEST_F(RPCAccountTxHandlerTest, IndexNotSpecificForwardTrue)
EXPECT_CALL(
*rawBackendPtr,
fetchAccountTransactions(
testing::_, testing::_, true, testing::Optional(testing::Eq(TransactionsCursor{MINSEQ, 0})), testing::_))
testing::_,
testing::_,
true,
testing::Optional(testing::Eq(TransactionsCursor{MINSEQ - 1, INT32_MAX})),
testing::_))
.Times(1);
runSpawn([&, this](auto& yield) {