mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-22 03:55:53 +00:00
Properly handle configurations where use_tx_tables = 0
This commit is contained in:
@@ -277,7 +277,11 @@ getTxHistory(
|
|||||||
* @param j Journal.
|
* @param j Journal.
|
||||||
* @return Vector of pairs of found transactions and their metadata
|
* @return Vector of pairs of found transactions and their metadata
|
||||||
* sorted in ascending order by account sequence.
|
* sorted in ascending order by account sequence.
|
||||||
* Also number of transactions processed.
|
* Also number of transactions processed or skpiied.
|
||||||
|
* If this number is >= 0, then it means number of transactions
|
||||||
|
* processed, if it is < 0, then ~number means number of transactions
|
||||||
|
* skipped. We need to skip some quantity of transactions if option
|
||||||
|
* offset is > 0 in the options structure.
|
||||||
*/
|
*/
|
||||||
std::pair<RelationalDBInterface::AccountTxs, int>
|
std::pair<RelationalDBInterface::AccountTxs, int>
|
||||||
getOldestAccountTxs(
|
getOldestAccountTxs(
|
||||||
@@ -304,7 +308,11 @@ getOldestAccountTxs(
|
|||||||
* @param j Journal.
|
* @param j Journal.
|
||||||
* @return Vector of pairs of found transactions and their metadata
|
* @return Vector of pairs of found transactions and their metadata
|
||||||
* sorted in descending order by account sequence.
|
* sorted in descending order by account sequence.
|
||||||
* Also number of transactions processed.
|
* Also number of transactions processed or skipped.
|
||||||
|
* If this number is >= 0, then it means number of transactions
|
||||||
|
* processed, if it is < 0, then ~number means number of transactions
|
||||||
|
* skipped. We need to skip some quantity of transactions if option
|
||||||
|
* offset is > 0 in the options structure.
|
||||||
*/
|
*/
|
||||||
std::pair<RelationalDBInterface::AccountTxs, int>
|
std::pair<RelationalDBInterface::AccountTxs, int>
|
||||||
getNewestAccountTxs(
|
getNewestAccountTxs(
|
||||||
@@ -331,7 +339,11 @@ getNewestAccountTxs(
|
|||||||
* @param j Journal.
|
* @param j Journal.
|
||||||
* @return Vector of tuples of found transactions, their metadata and
|
* @return Vector of tuples of found transactions, their metadata and
|
||||||
* account sequences sorted in ascending order by account
|
* account sequences sorted in ascending order by account
|
||||||
* sequence. Also number of transactions processed.
|
* sequence. Also number of transactions processed or skpiied.
|
||||||
|
* If this number is >= 0, then it means number of transactions
|
||||||
|
* processed, if it is < 0, then ~number means number of transactions
|
||||||
|
* skipped. We need to skip some quantity of transactions if option
|
||||||
|
* offset is > 0 in the options structure.
|
||||||
*/
|
*/
|
||||||
std::pair<std::vector<RelationalDBInterface::txnMetaLedgerType>, int>
|
std::pair<std::vector<RelationalDBInterface::txnMetaLedgerType>, int>
|
||||||
getOldestAccountTxsB(
|
getOldestAccountTxsB(
|
||||||
@@ -357,7 +369,11 @@ getOldestAccountTxsB(
|
|||||||
* @param j Journal.
|
* @param j Journal.
|
||||||
* @return Vector of tuples of found transactions, their metadata and
|
* @return Vector of tuples of found transactions, their metadata and
|
||||||
* account sequences sorted in descending order by account
|
* account sequences sorted in descending order by account
|
||||||
* sequence. Also number of transactions processed.
|
* sequence. Also number of transactions processed or skpiied.
|
||||||
|
* If this number is >= 0, then it means number of transactions
|
||||||
|
* processed, if it is < 0, then ~number means number of transactions
|
||||||
|
* skipped. We need to skip some quantity of transactions if option
|
||||||
|
* offset is > 0 in the options structure.
|
||||||
*/
|
*/
|
||||||
std::pair<std::vector<RelationalDBInterface::txnMetaLedgerType>, int>
|
std::pair<std::vector<RelationalDBInterface::txnMetaLedgerType>, int>
|
||||||
getNewestAccountTxsB(
|
getNewestAccountTxsB(
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ public:
|
|||||||
Application& app,
|
Application& app,
|
||||||
Config const& config,
|
Config const& config,
|
||||||
JobQueue& jobQueue)
|
JobQueue& jobQueue)
|
||||||
: app_(app), j_(app_.journal("Ledger"))
|
: app_(app)
|
||||||
|
, useTxTables_(config.useTxTables())
|
||||||
|
, j_(app_.journal("Ledger"))
|
||||||
{
|
{
|
||||||
DatabaseCon::Setup setup = setup_DatabaseCon(config, j_);
|
DatabaseCon::Setup setup = setup_DatabaseCon(config, j_);
|
||||||
if (!makeLedgerDBs(
|
if (!makeLedgerDBs(
|
||||||
@@ -191,6 +193,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Application& app_;
|
Application& app_;
|
||||||
|
bool useTxTables_;
|
||||||
beast::Journal j_;
|
beast::Journal j_;
|
||||||
std::unique_ptr<DatabaseCon> lgrdb_, txdb_;
|
std::unique_ptr<DatabaseCon> lgrdb_, txdb_;
|
||||||
std::unique_ptr<DatabaseCon> lgrMetaDB_, txMetaDB_;
|
std::unique_ptr<DatabaseCon> lgrMetaDB_, txMetaDB_;
|
||||||
@@ -257,23 +260,43 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief checkoutLedger Checks if node ledger DB exists.
|
* @brief existsLedger Checks if node ledger DB exists.
|
||||||
* @return True if node ledger DB exists.
|
* @return True if node ledger DB exists.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
existsLedger()
|
existsLedger()
|
||||||
{
|
{
|
||||||
return !!lgrdb_;
|
return (bool)lgrdb_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief checkoutTransaction Checks if node transaction DB exists.
|
* @brief existsTransaction Checks if node transaction DB exists.
|
||||||
* @return True if node transaction DB exists.
|
* @return True if node transaction DB exists.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
existsTransaction()
|
existsTransaction()
|
||||||
{
|
{
|
||||||
return !!txdb_;
|
return (bool)txdb_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief existsShardLedger Checks if shard ledger DBs exist.
|
||||||
|
* @return True if node ledger DB exists.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
existsShardLedger()
|
||||||
|
{
|
||||||
|
return app_.getShardStore() != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief existsShardTransaction Checks if shard transaction DBs exist.
|
||||||
|
* @return True if node transaction DB exists.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
existsShardTransaction()
|
||||||
|
{
|
||||||
|
return useTxTables_ && app_.getShardStore() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -457,7 +480,9 @@ RelationalDBInterfaceSqliteImp::getMinLedgerSeq()
|
|||||||
return ripple::getMinLedgerSeq(*db, TableType::Ledgers);
|
return ripple::getMinLedgerSeq(*db, TableType::Ledgers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
std::optional<LedgerIndex> res;
|
std::optional<LedgerIndex> res;
|
||||||
iterateLedgerForward(
|
iterateLedgerForward(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -467,6 +492,10 @@ RelationalDBInterfaceSqliteImp::getMinLedgerSeq()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<LedgerIndex>
|
std::optional<LedgerIndex>
|
||||||
RelationalDBInterfaceSqliteImp::getTransactionsMinLedgerSeq()
|
RelationalDBInterfaceSqliteImp::getTransactionsMinLedgerSeq()
|
||||||
{
|
{
|
||||||
@@ -477,7 +506,9 @@ RelationalDBInterfaceSqliteImp::getTransactionsMinLedgerSeq()
|
|||||||
return ripple::getMinLedgerSeq(*db, TableType::Transactions);
|
return ripple::getMinLedgerSeq(*db, TableType::Transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
std::optional<LedgerIndex> res;
|
std::optional<LedgerIndex> res;
|
||||||
iterateTransactionForward(
|
iterateTransactionForward(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -487,6 +518,10 @@ RelationalDBInterfaceSqliteImp::getTransactionsMinLedgerSeq()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<LedgerIndex>
|
std::optional<LedgerIndex>
|
||||||
RelationalDBInterfaceSqliteImp::getAccountTransactionsMinLedgerSeq()
|
RelationalDBInterfaceSqliteImp::getAccountTransactionsMinLedgerSeq()
|
||||||
{
|
{
|
||||||
@@ -497,7 +532,9 @@ RelationalDBInterfaceSqliteImp::getAccountTransactionsMinLedgerSeq()
|
|||||||
return ripple::getMinLedgerSeq(*db, TableType::AccountTransactions);
|
return ripple::getMinLedgerSeq(*db, TableType::AccountTransactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
std::optional<LedgerIndex> res;
|
std::optional<LedgerIndex> res;
|
||||||
iterateTransactionForward(
|
iterateTransactionForward(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -508,6 +545,10 @@ RelationalDBInterfaceSqliteImp::getAccountTransactionsMinLedgerSeq()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<LedgerIndex>
|
std::optional<LedgerIndex>
|
||||||
RelationalDBInterfaceSqliteImp::getMaxLedgerSeq()
|
RelationalDBInterfaceSqliteImp::getMaxLedgerSeq()
|
||||||
{
|
{
|
||||||
@@ -518,7 +559,9 @@ RelationalDBInterfaceSqliteImp::getMaxLedgerSeq()
|
|||||||
return ripple::getMaxLedgerSeq(*db, TableType::Ledgers);
|
return ripple::getMaxLedgerSeq(*db, TableType::Ledgers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
std::optional<LedgerIndex> res;
|
std::optional<LedgerIndex> res;
|
||||||
iterateLedgerBack(
|
iterateLedgerBack(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -528,6 +571,10 @@ RelationalDBInterfaceSqliteImp::getMaxLedgerSeq()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RelationalDBInterfaceSqliteImp::deleteTransactionByLedgerSeq(
|
RelationalDBInterfaceSqliteImp::deleteTransactionByLedgerSeq(
|
||||||
LedgerIndex ledgerSeq)
|
LedgerIndex ledgerSeq)
|
||||||
@@ -540,13 +587,19 @@ RelationalDBInterfaceSqliteImp::deleteTransactionByLedgerSeq(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard database */
|
/* else use shard database, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
doTransaction(ledgerSeq, [&](soci::session& session) {
|
doTransaction(ledgerSeq, [&](soci::session& session) {
|
||||||
ripple::deleteByLedgerSeq(session, TableType::Transactions, ledgerSeq);
|
ripple::deleteByLedgerSeq(
|
||||||
|
session, TableType::Transactions, ledgerSeq);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else nothing to do */
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RelationalDBInterfaceSqliteImp::deleteBeforeLedgerSeq(LedgerIndex ledgerSeq)
|
RelationalDBInterfaceSqliteImp::deleteBeforeLedgerSeq(LedgerIndex ledgerSeq)
|
||||||
{
|
{
|
||||||
@@ -558,7 +611,9 @@ RelationalDBInterfaceSqliteImp::deleteBeforeLedgerSeq(LedgerIndex ledgerSeq)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
iterateLedgerBack(
|
iterateLedgerBack(
|
||||||
seqToShardIndex(ledgerSeq),
|
seqToShardIndex(ledgerSeq),
|
||||||
[&](soci::session& session, std::uint32_t shardIndex) {
|
[&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -568,6 +623,9 @@ RelationalDBInterfaceSqliteImp::deleteBeforeLedgerSeq(LedgerIndex ledgerSeq)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else nothing to do */
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RelationalDBInterfaceSqliteImp::deleteTransactionsBeforeLedgerSeq(
|
RelationalDBInterfaceSqliteImp::deleteTransactionsBeforeLedgerSeq(
|
||||||
LedgerIndex ledgerSeq)
|
LedgerIndex ledgerSeq)
|
||||||
@@ -580,7 +638,9 @@ RelationalDBInterfaceSqliteImp::deleteTransactionsBeforeLedgerSeq(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
iterateTransactionBack(
|
iterateTransactionBack(
|
||||||
seqToShardIndex(ledgerSeq),
|
seqToShardIndex(ledgerSeq),
|
||||||
[&](soci::session& session, std::uint32_t shardIndex) {
|
[&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -590,6 +650,9 @@ RelationalDBInterfaceSqliteImp::deleteTransactionsBeforeLedgerSeq(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else nothing to do */
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RelationalDBInterfaceSqliteImp::deleteAccountTransactionsBeforeLedgerSeq(
|
RelationalDBInterfaceSqliteImp::deleteAccountTransactionsBeforeLedgerSeq(
|
||||||
LedgerIndex ledgerSeq)
|
LedgerIndex ledgerSeq)
|
||||||
@@ -603,7 +666,9 @@ RelationalDBInterfaceSqliteImp::deleteAccountTransactionsBeforeLedgerSeq(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
iterateTransactionBack(
|
iterateTransactionBack(
|
||||||
seqToShardIndex(ledgerSeq),
|
seqToShardIndex(ledgerSeq),
|
||||||
[&](soci::session& session, std::uint32_t shardIndex) {
|
[&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -613,6 +678,9 @@ RelationalDBInterfaceSqliteImp::deleteAccountTransactionsBeforeLedgerSeq(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else nothing to do */
|
||||||
|
}
|
||||||
|
|
||||||
std::size_t
|
std::size_t
|
||||||
RelationalDBInterfaceSqliteImp::getTransactionCount()
|
RelationalDBInterfaceSqliteImp::getTransactionCount()
|
||||||
{
|
{
|
||||||
@@ -623,7 +691,9 @@ RelationalDBInterfaceSqliteImp::getTransactionCount()
|
|||||||
return ripple::getRows(*db, TableType::Transactions);
|
return ripple::getRows(*db, TableType::Transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
std::size_t rows = 0;
|
std::size_t rows = 0;
|
||||||
iterateTransactionForward(
|
iterateTransactionForward(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -633,6 +703,10 @@ RelationalDBInterfaceSqliteImp::getTransactionCount()
|
|||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return 0 */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::size_t
|
std::size_t
|
||||||
RelationalDBInterfaceSqliteImp::getAccountTransactionCount()
|
RelationalDBInterfaceSqliteImp::getAccountTransactionCount()
|
||||||
{
|
{
|
||||||
@@ -643,16 +717,23 @@ RelationalDBInterfaceSqliteImp::getAccountTransactionCount()
|
|||||||
return ripple::getRows(*db, TableType::AccountTransactions);
|
return ripple::getRows(*db, TableType::AccountTransactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
std::size_t rows = 0;
|
std::size_t rows = 0;
|
||||||
iterateTransactionForward(
|
iterateTransactionForward(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
rows += ripple::getRows(session, TableType::AccountTransactions);
|
rows +=
|
||||||
|
ripple::getRows(session, TableType::AccountTransactions);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return 0 */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
RelationalDBInterface::CountMinMax
|
RelationalDBInterface::CountMinMax
|
||||||
RelationalDBInterfaceSqliteImp::getLedgerCountMinMax()
|
RelationalDBInterfaceSqliteImp::getLedgerCountMinMax()
|
||||||
{
|
{
|
||||||
@@ -663,7 +744,9 @@ RelationalDBInterfaceSqliteImp::getLedgerCountMinMax()
|
|||||||
return ripple::getRowsMinMax(*db, TableType::Ledgers);
|
return ripple::getRowsMinMax(*db, TableType::Ledgers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
CountMinMax res{0, 0, 0};
|
CountMinMax res{0, 0, 0};
|
||||||
iterateLedgerForward(
|
iterateLedgerForward(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -680,6 +763,10 @@ RelationalDBInterfaceSqliteImp::getLedgerCountMinMax()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return zero values */
|
||||||
|
return {0, 0, 0};
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
RelationalDBInterfaceSqliteImp::saveValidatedLedger(
|
RelationalDBInterfaceSqliteImp::saveValidatedLedger(
|
||||||
std::shared_ptr<Ledger const> const& ledger,
|
std::shared_ptr<Ledger const> const& ledger,
|
||||||
@@ -693,7 +780,9 @@ RelationalDBInterfaceSqliteImp::saveValidatedLedger(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto shardStore = app_.getShardStore())
|
/* else use shard databases, if available */
|
||||||
|
if (auto shardStore = app_.getShardStore();
|
||||||
|
shardStore && existsShardTransaction())
|
||||||
{
|
{
|
||||||
if (ledger->info().seq < shardStore->earliestLedgerSeq())
|
if (ledger->info().seq < shardStore->earliestLedgerSeq())
|
||||||
// For the moment return false only when the ShardStore
|
// For the moment return false only when the ShardStore
|
||||||
@@ -727,7 +816,9 @@ RelationalDBInterfaceSqliteImp::getLedgerInfoByIndex(LedgerIndex ledgerSeq)
|
|||||||
return ripple::getLedgerInfoByIndex(*db, ledgerSeq, j_);
|
return ripple::getLedgerInfoByIndex(*db, ledgerSeq, j_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard database */
|
/* else use shard database, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
std::optional<LedgerInfo> res;
|
std::optional<LedgerInfo> res;
|
||||||
doLedger(ledgerSeq, [&](soci::session& session) {
|
doLedger(ledgerSeq, [&](soci::session& session) {
|
||||||
res = ripple::getLedgerInfoByIndex(session, ledgerSeq, j_);
|
res = ripple::getLedgerInfoByIndex(session, ledgerSeq, j_);
|
||||||
@@ -736,6 +827,10 @@ RelationalDBInterfaceSqliteImp::getLedgerInfoByIndex(LedgerIndex ledgerSeq)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<LedgerInfo>
|
std::optional<LedgerInfo>
|
||||||
RelationalDBInterfaceSqliteImp::getNewestLedgerInfo()
|
RelationalDBInterfaceSqliteImp::getNewestLedgerInfo()
|
||||||
{
|
{
|
||||||
@@ -746,7 +841,9 @@ RelationalDBInterfaceSqliteImp::getNewestLedgerInfo()
|
|||||||
return ripple::getNewestLedgerInfo(*db, j_);
|
return ripple::getNewestLedgerInfo(*db, j_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
std::optional<LedgerInfo> res;
|
std::optional<LedgerInfo> res;
|
||||||
iterateLedgerBack(
|
iterateLedgerBack(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -761,6 +858,10 @@ RelationalDBInterfaceSqliteImp::getNewestLedgerInfo()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<LedgerInfo>
|
std::optional<LedgerInfo>
|
||||||
RelationalDBInterfaceSqliteImp::getLimitedOldestLedgerInfo(
|
RelationalDBInterfaceSqliteImp::getLimitedOldestLedgerInfo(
|
||||||
LedgerIndex ledgerFirstIndex)
|
LedgerIndex ledgerFirstIndex)
|
||||||
@@ -772,7 +873,9 @@ RelationalDBInterfaceSqliteImp::getLimitedOldestLedgerInfo(
|
|||||||
return ripple::getLimitedOldestLedgerInfo(*db, ledgerFirstIndex, j_);
|
return ripple::getLimitedOldestLedgerInfo(*db, ledgerFirstIndex, j_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
std::optional<LedgerInfo> res;
|
std::optional<LedgerInfo> res;
|
||||||
iterateLedgerForward(
|
iterateLedgerForward(
|
||||||
seqToShardIndex(ledgerFirstIndex),
|
seqToShardIndex(ledgerFirstIndex),
|
||||||
@@ -789,6 +892,10 @@ RelationalDBInterfaceSqliteImp::getLimitedOldestLedgerInfo(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<LedgerInfo>
|
std::optional<LedgerInfo>
|
||||||
RelationalDBInterfaceSqliteImp::getLimitedNewestLedgerInfo(
|
RelationalDBInterfaceSqliteImp::getLimitedNewestLedgerInfo(
|
||||||
LedgerIndex ledgerFirstIndex)
|
LedgerIndex ledgerFirstIndex)
|
||||||
@@ -800,7 +907,9 @@ RelationalDBInterfaceSqliteImp::getLimitedNewestLedgerInfo(
|
|||||||
return ripple::getLimitedNewestLedgerInfo(*db, ledgerFirstIndex, j_);
|
return ripple::getLimitedNewestLedgerInfo(*db, ledgerFirstIndex, j_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
std::optional<LedgerInfo> res;
|
std::optional<LedgerInfo> res;
|
||||||
iterateLedgerBack(
|
iterateLedgerBack(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -816,6 +925,10 @@ RelationalDBInterfaceSqliteImp::getLimitedNewestLedgerInfo(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<LedgerInfo>
|
std::optional<LedgerInfo>
|
||||||
RelationalDBInterfaceSqliteImp::getLedgerInfoByHash(uint256 const& ledgerHash)
|
RelationalDBInterfaceSqliteImp::getLedgerInfoByHash(uint256 const& ledgerHash)
|
||||||
{
|
{
|
||||||
@@ -826,7 +939,7 @@ RelationalDBInterfaceSqliteImp::getLedgerInfoByHash(uint256 const& ledgerHash)
|
|||||||
return ripple::getLedgerInfoByHash(*db, ledgerHash, j_);
|
return ripple::getLedgerInfoByHash(*db, ledgerHash, j_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
if (auto shardStore = app_.getShardStore())
|
if (auto shardStore = app_.getShardStore())
|
||||||
{
|
{
|
||||||
std::optional<LedgerInfo> res;
|
std::optional<LedgerInfo> res;
|
||||||
@@ -845,6 +958,7 @@ RelationalDBInterfaceSqliteImp::getLedgerInfoByHash(uint256 const& ledgerHash)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,7 +972,9 @@ RelationalDBInterfaceSqliteImp::getHashByIndex(LedgerIndex ledgerIndex)
|
|||||||
return ripple::getHashByIndex(*db, ledgerIndex);
|
return ripple::getHashByIndex(*db, ledgerIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard database */
|
/* else use shard database, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
doLedger(ledgerIndex, [&](soci::session& session) {
|
doLedger(ledgerIndex, [&](soci::session& session) {
|
||||||
hash = ripple::getHashByIndex(session, ledgerIndex);
|
hash = ripple::getHashByIndex(session, ledgerIndex);
|
||||||
@@ -867,6 +983,10 @@ RelationalDBInterfaceSqliteImp::getHashByIndex(LedgerIndex ledgerIndex)
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return zero value */
|
||||||
|
return uint256();
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<LedgerHashPair>
|
std::optional<LedgerHashPair>
|
||||||
RelationalDBInterfaceSqliteImp::getHashesByIndex(LedgerIndex ledgerIndex)
|
RelationalDBInterfaceSqliteImp::getHashesByIndex(LedgerIndex ledgerIndex)
|
||||||
{
|
{
|
||||||
@@ -877,7 +997,9 @@ RelationalDBInterfaceSqliteImp::getHashesByIndex(LedgerIndex ledgerIndex)
|
|||||||
return ripple::getHashesByIndex(*db, ledgerIndex, j_);
|
return ripple::getHashesByIndex(*db, ledgerIndex, j_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard database */
|
/* else use shard database, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
std::optional<LedgerHashPair> res;
|
std::optional<LedgerHashPair> res;
|
||||||
doLedger(ledgerIndex, [&](soci::session& session) {
|
doLedger(ledgerIndex, [&](soci::session& session) {
|
||||||
res = ripple::getHashesByIndex(session, ledgerIndex, j_);
|
res = ripple::getHashesByIndex(session, ledgerIndex, j_);
|
||||||
@@ -886,6 +1008,10 @@ RelationalDBInterfaceSqliteImp::getHashesByIndex(LedgerIndex ledgerIndex)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::map<LedgerIndex, LedgerHashPair>
|
std::map<LedgerIndex, LedgerHashPair>
|
||||||
RelationalDBInterfaceSqliteImp::getHashesByIndex(
|
RelationalDBInterfaceSqliteImp::getHashesByIndex(
|
||||||
LedgerIndex minSeq,
|
LedgerIndex minSeq,
|
||||||
@@ -898,7 +1024,9 @@ RelationalDBInterfaceSqliteImp::getHashesByIndex(
|
|||||||
return ripple::getHashesByIndex(*db, minSeq, maxSeq, j_);
|
return ripple::getHashesByIndex(*db, minSeq, maxSeq, j_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
std::map<LedgerIndex, LedgerHashPair> res;
|
std::map<LedgerIndex, LedgerHashPair> res;
|
||||||
while (minSeq <= maxSeq)
|
while (minSeq <= maxSeq)
|
||||||
{
|
{
|
||||||
@@ -906,7 +1034,8 @@ RelationalDBInterfaceSqliteImp::getHashesByIndex(
|
|||||||
if (shardMaxSeq > maxSeq)
|
if (shardMaxSeq > maxSeq)
|
||||||
shardMaxSeq = maxSeq;
|
shardMaxSeq = maxSeq;
|
||||||
doLedger(minSeq, [&](soci::session& session) {
|
doLedger(minSeq, [&](soci::session& session) {
|
||||||
auto r = ripple::getHashesByIndex(session, minSeq, shardMaxSeq, j_);
|
auto r =
|
||||||
|
ripple::getHashesByIndex(session, minSeq, shardMaxSeq, j_);
|
||||||
res.insert(r.begin(), r.end());
|
res.insert(r.begin(), r.end());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -916,6 +1045,10 @@ RelationalDBInterfaceSqliteImp::getHashesByIndex(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Transaction>>
|
std::vector<std::shared_ptr<Transaction>>
|
||||||
RelationalDBInterfaceSqliteImp::getTxHistory(LedgerIndex startIndex)
|
RelationalDBInterfaceSqliteImp::getTxHistory(LedgerIndex startIndex)
|
||||||
{
|
{
|
||||||
@@ -926,13 +1059,15 @@ RelationalDBInterfaceSqliteImp::getTxHistory(LedgerIndex startIndex)
|
|||||||
return ripple::getTxHistory(*db, app_, startIndex, 20, false).first;
|
return ripple::getTxHistory(*db, app_, startIndex, 20, false).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
std::vector<std::shared_ptr<Transaction>> txs;
|
std::vector<std::shared_ptr<Transaction>> txs;
|
||||||
int quantity = 20;
|
int quantity = 20;
|
||||||
iterateTransactionBack(
|
iterateTransactionBack(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
auto [tx, total] =
|
auto [tx, total] = ripple::getTxHistory(
|
||||||
ripple::getTxHistory(session, app_, startIndex, quantity, true);
|
session, app_, startIndex, quantity, true);
|
||||||
txs.insert(txs.end(), tx.begin(), tx.end());
|
txs.insert(txs.end(), tx.begin(), tx.end());
|
||||||
if (total > 0)
|
if (total > 0)
|
||||||
{
|
{
|
||||||
@@ -951,6 +1086,10 @@ RelationalDBInterfaceSqliteImp::getTxHistory(LedgerIndex startIndex)
|
|||||||
return txs;
|
return txs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
RelationalDBInterface::AccountTxs
|
RelationalDBInterface::AccountTxs
|
||||||
RelationalDBInterfaceSqliteImp::getOldestAccountTxs(
|
RelationalDBInterfaceSqliteImp::getOldestAccountTxs(
|
||||||
AccountTxOptions const& options)
|
AccountTxOptions const& options)
|
||||||
@@ -966,7 +1105,9 @@ RelationalDBInterfaceSqliteImp::getOldestAccountTxs(
|
|||||||
.first;
|
.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
AccountTxs ret;
|
AccountTxs ret;
|
||||||
AccountTxOptions opt = options;
|
AccountTxOptions opt = options;
|
||||||
int limit_used = 0;
|
int limit_used = 0;
|
||||||
@@ -974,7 +1115,8 @@ RelationalDBInterfaceSqliteImp::getOldestAccountTxs(
|
|||||||
opt.minLedger ? seqToShardIndex(opt.minLedger)
|
opt.minLedger ? seqToShardIndex(opt.minLedger)
|
||||||
: std::optional<std::uint32_t>(),
|
: std::optional<std::uint32_t>(),
|
||||||
[&](soci::session& session, std::uint32_t shardIndex) {
|
[&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
if (opt.maxLedger && shardIndex > seqToShardIndex(opt.maxLedger))
|
if (opt.maxLedger &&
|
||||||
|
shardIndex > seqToShardIndex(opt.maxLedger))
|
||||||
return false;
|
return false;
|
||||||
auto [r, total] = ripple::getOldestAccountTxs(
|
auto [r, total] = ripple::getOldestAccountTxs(
|
||||||
session, app_, ledgerMaster, opt, limit_used, j_);
|
session, app_, ledgerMaster, opt, limit_used, j_);
|
||||||
@@ -988,6 +1130,11 @@ RelationalDBInterfaceSqliteImp::getOldestAccountTxs(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* If total < 0, then ~total means number of transactions
|
||||||
|
* skipped, see definition of return value of function
|
||||||
|
* ripple::getOldestAccountTxs().
|
||||||
|
*/
|
||||||
total = ~total;
|
total = ~total;
|
||||||
if (opt.offset <= total)
|
if (opt.offset <= total)
|
||||||
opt.offset = 0;
|
opt.offset = 0;
|
||||||
@@ -1000,6 +1147,10 @@ RelationalDBInterfaceSqliteImp::getOldestAccountTxs(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
RelationalDBInterface::AccountTxs
|
RelationalDBInterface::AccountTxs
|
||||||
RelationalDBInterfaceSqliteImp::getNewestAccountTxs(
|
RelationalDBInterfaceSqliteImp::getNewestAccountTxs(
|
||||||
AccountTxOptions const& options)
|
AccountTxOptions const& options)
|
||||||
@@ -1015,7 +1166,9 @@ RelationalDBInterfaceSqliteImp::getNewestAccountTxs(
|
|||||||
.first;
|
.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
AccountTxs ret;
|
AccountTxs ret;
|
||||||
AccountTxOptions opt = options;
|
AccountTxOptions opt = options;
|
||||||
int limit_used = 0;
|
int limit_used = 0;
|
||||||
@@ -1023,7 +1176,8 @@ RelationalDBInterfaceSqliteImp::getNewestAccountTxs(
|
|||||||
opt.maxLedger ? seqToShardIndex(opt.maxLedger)
|
opt.maxLedger ? seqToShardIndex(opt.maxLedger)
|
||||||
: std::optional<std::uint32_t>(),
|
: std::optional<std::uint32_t>(),
|
||||||
[&](soci::session& session, std::uint32_t shardIndex) {
|
[&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
if (opt.minLedger && shardIndex < seqToShardIndex(opt.minLedger))
|
if (opt.minLedger &&
|
||||||
|
shardIndex < seqToShardIndex(opt.minLedger))
|
||||||
return false;
|
return false;
|
||||||
auto [r, total] = ripple::getNewestAccountTxs(
|
auto [r, total] = ripple::getNewestAccountTxs(
|
||||||
session, app_, ledgerMaster, opt, limit_used, j_);
|
session, app_, ledgerMaster, opt, limit_used, j_);
|
||||||
@@ -1037,6 +1191,11 @@ RelationalDBInterfaceSqliteImp::getNewestAccountTxs(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* If total < 0, then ~total means number of transactions
|
||||||
|
* skipped, see definition of return value of function
|
||||||
|
* ripple::getNewestAccountTxs().
|
||||||
|
*/
|
||||||
total = ~total;
|
total = ~total;
|
||||||
if (opt.offset <= total)
|
if (opt.offset <= total)
|
||||||
opt.offset = 0;
|
opt.offset = 0;
|
||||||
@@ -1049,6 +1208,10 @@ RelationalDBInterfaceSqliteImp::getNewestAccountTxs(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
RelationalDBInterface::MetaTxsList
|
RelationalDBInterface::MetaTxsList
|
||||||
RelationalDBInterfaceSqliteImp::getOldestAccountTxsB(
|
RelationalDBInterfaceSqliteImp::getOldestAccountTxsB(
|
||||||
AccountTxOptions const& options)
|
AccountTxOptions const& options)
|
||||||
@@ -1060,7 +1223,9 @@ RelationalDBInterfaceSqliteImp::getOldestAccountTxsB(
|
|||||||
return ripple::getOldestAccountTxsB(*db, app_, options, {}, j_).first;
|
return ripple::getOldestAccountTxsB(*db, app_, options, {}, j_).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
MetaTxsList ret;
|
MetaTxsList ret;
|
||||||
AccountTxOptions opt = options;
|
AccountTxOptions opt = options;
|
||||||
int limit_used = 0;
|
int limit_used = 0;
|
||||||
@@ -1068,7 +1233,8 @@ RelationalDBInterfaceSqliteImp::getOldestAccountTxsB(
|
|||||||
opt.minLedger ? seqToShardIndex(opt.minLedger)
|
opt.minLedger ? seqToShardIndex(opt.minLedger)
|
||||||
: std::optional<std::uint32_t>(),
|
: std::optional<std::uint32_t>(),
|
||||||
[&](soci::session& session, std::uint32_t shardIndex) {
|
[&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
if (opt.maxLedger && shardIndex > seqToShardIndex(opt.maxLedger))
|
if (opt.maxLedger &&
|
||||||
|
shardIndex > seqToShardIndex(opt.maxLedger))
|
||||||
return false;
|
return false;
|
||||||
auto [r, total] = ripple::getOldestAccountTxsB(
|
auto [r, total] = ripple::getOldestAccountTxsB(
|
||||||
session, app_, opt, limit_used, j_);
|
session, app_, opt, limit_used, j_);
|
||||||
@@ -1082,6 +1248,11 @@ RelationalDBInterfaceSqliteImp::getOldestAccountTxsB(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* If total < 0, then ~total means number of transactions
|
||||||
|
* skipped, see definition of return value of function
|
||||||
|
* ripple::getOldestAccountTxsB().
|
||||||
|
*/
|
||||||
total = ~total;
|
total = ~total;
|
||||||
if (opt.offset <= total)
|
if (opt.offset <= total)
|
||||||
opt.offset = 0;
|
opt.offset = 0;
|
||||||
@@ -1094,6 +1265,10 @@ RelationalDBInterfaceSqliteImp::getOldestAccountTxsB(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
RelationalDBInterface::MetaTxsList
|
RelationalDBInterface::MetaTxsList
|
||||||
RelationalDBInterfaceSqliteImp::getNewestAccountTxsB(
|
RelationalDBInterfaceSqliteImp::getNewestAccountTxsB(
|
||||||
AccountTxOptions const& options)
|
AccountTxOptions const& options)
|
||||||
@@ -1105,7 +1280,9 @@ RelationalDBInterfaceSqliteImp::getNewestAccountTxsB(
|
|||||||
return ripple::getNewestAccountTxsB(*db, app_, options, {}, j_).first;
|
return ripple::getNewestAccountTxsB(*db, app_, options, {}, j_).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
MetaTxsList ret;
|
MetaTxsList ret;
|
||||||
AccountTxOptions opt = options;
|
AccountTxOptions opt = options;
|
||||||
int limit_used = 0;
|
int limit_used = 0;
|
||||||
@@ -1113,7 +1290,8 @@ RelationalDBInterfaceSqliteImp::getNewestAccountTxsB(
|
|||||||
opt.maxLedger ? seqToShardIndex(opt.maxLedger)
|
opt.maxLedger ? seqToShardIndex(opt.maxLedger)
|
||||||
: std::optional<std::uint32_t>(),
|
: std::optional<std::uint32_t>(),
|
||||||
[&](soci::session& session, std::uint32_t shardIndex) {
|
[&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
if (opt.minLedger && shardIndex < seqToShardIndex(opt.minLedger))
|
if (opt.minLedger &&
|
||||||
|
shardIndex < seqToShardIndex(opt.minLedger))
|
||||||
return false;
|
return false;
|
||||||
auto [r, total] = ripple::getNewestAccountTxsB(
|
auto [r, total] = ripple::getNewestAccountTxsB(
|
||||||
session, app_, opt, limit_used, j_);
|
session, app_, opt, limit_used, j_);
|
||||||
@@ -1127,6 +1305,11 @@ RelationalDBInterfaceSqliteImp::getNewestAccountTxsB(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* If total < 0, then ~total means number of transactions
|
||||||
|
* skipped, see definition of return value of function
|
||||||
|
* ripple::getNewestAccountTxsB().
|
||||||
|
*/
|
||||||
total = ~total;
|
total = ~total;
|
||||||
if (opt.offset <= total)
|
if (opt.offset <= total)
|
||||||
opt.offset = 0;
|
opt.offset = 0;
|
||||||
@@ -1139,6 +1322,10 @@ RelationalDBInterfaceSqliteImp::getNewestAccountTxsB(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<
|
std::pair<
|
||||||
RelationalDBInterface::AccountTxs,
|
RelationalDBInterface::AccountTxs,
|
||||||
std::optional<RelationalDBInterface::AccountTxMarker>>
|
std::optional<RelationalDBInterface::AccountTxMarker>>
|
||||||
@@ -1175,7 +1362,9 @@ RelationalDBInterfaceSqliteImp::oldestAccountTxPage(
|
|||||||
return {ret, newmarker};
|
return {ret, newmarker};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
AccountTxPageOptions opt = options;
|
AccountTxPageOptions opt = options;
|
||||||
int limit_used = 0;
|
int limit_used = 0;
|
||||||
iterateTransactionForward(
|
iterateTransactionForward(
|
||||||
@@ -1203,6 +1392,10 @@ RelationalDBInterfaceSqliteImp::oldestAccountTxPage(
|
|||||||
return {ret, opt.marker};
|
return {ret, opt.marker};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<
|
std::pair<
|
||||||
RelationalDBInterface::AccountTxs,
|
RelationalDBInterface::AccountTxs,
|
||||||
std::optional<RelationalDBInterface::AccountTxMarker>>
|
std::optional<RelationalDBInterface::AccountTxMarker>>
|
||||||
@@ -1239,14 +1432,17 @@ RelationalDBInterfaceSqliteImp::newestAccountTxPage(
|
|||||||
return {ret, newmarker};
|
return {ret, newmarker};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
AccountTxPageOptions opt = options;
|
AccountTxPageOptions opt = options;
|
||||||
int limit_used = 0;
|
int limit_used = 0;
|
||||||
iterateTransactionBack(
|
iterateTransactionBack(
|
||||||
opt.maxLedger != UINT32_MAX ? seqToShardIndex(opt.maxLedger)
|
opt.maxLedger != UINT32_MAX ? seqToShardIndex(opt.maxLedger)
|
||||||
: std::optional<std::uint32_t>(),
|
: std::optional<std::uint32_t>(),
|
||||||
[&](soci::session& session, std::uint32_t shardIndex) {
|
[&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
if (opt.minLedger && shardIndex < seqToShardIndex(opt.minLedger))
|
if (opt.minLedger &&
|
||||||
|
shardIndex < seqToShardIndex(opt.minLedger))
|
||||||
return false;
|
return false;
|
||||||
auto [marker, total] = ripple::newestAccountTxPage(
|
auto [marker, total] = ripple::newestAccountTxPage(
|
||||||
session,
|
session,
|
||||||
@@ -1266,6 +1462,10 @@ RelationalDBInterfaceSqliteImp::newestAccountTxPage(
|
|||||||
return {ret, opt.marker};
|
return {ret, opt.marker};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<
|
std::pair<
|
||||||
RelationalDBInterface::MetaTxsList,
|
RelationalDBInterface::MetaTxsList,
|
||||||
std::optional<RelationalDBInterface::AccountTxMarker>>
|
std::optional<RelationalDBInterface::AccountTxMarker>>
|
||||||
@@ -1301,7 +1501,9 @@ RelationalDBInterfaceSqliteImp::oldestAccountTxPageB(
|
|||||||
return {ret, newmarker};
|
return {ret, newmarker};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
AccountTxPageOptions opt = options;
|
AccountTxPageOptions opt = options;
|
||||||
int limit_used = 0;
|
int limit_used = 0;
|
||||||
iterateTransactionForward(
|
iterateTransactionForward(
|
||||||
@@ -1329,6 +1531,10 @@ RelationalDBInterfaceSqliteImp::oldestAccountTxPageB(
|
|||||||
return {ret, opt.marker};
|
return {ret, opt.marker};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<
|
std::pair<
|
||||||
RelationalDBInterface::MetaTxsList,
|
RelationalDBInterface::MetaTxsList,
|
||||||
std::optional<RelationalDBInterface::AccountTxMarker>>
|
std::optional<RelationalDBInterface::AccountTxMarker>>
|
||||||
@@ -1364,14 +1570,17 @@ RelationalDBInterfaceSqliteImp::newestAccountTxPageB(
|
|||||||
return {ret, newmarker};
|
return {ret, newmarker};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
AccountTxPageOptions opt = options;
|
AccountTxPageOptions opt = options;
|
||||||
int limit_used = 0;
|
int limit_used = 0;
|
||||||
iterateTransactionBack(
|
iterateTransactionBack(
|
||||||
opt.maxLedger != UINT32_MAX ? seqToShardIndex(opt.maxLedger)
|
opt.maxLedger != UINT32_MAX ? seqToShardIndex(opt.maxLedger)
|
||||||
: std::optional<std::uint32_t>(),
|
: std::optional<std::uint32_t>(),
|
||||||
[&](soci::session& session, std::uint32_t shardIndex) {
|
[&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
if (opt.minLedger && shardIndex < seqToShardIndex(opt.minLedger))
|
if (opt.minLedger &&
|
||||||
|
shardIndex < seqToShardIndex(opt.minLedger))
|
||||||
return false;
|
return false;
|
||||||
auto [marker, total] = ripple::newestAccountTxPage(
|
auto [marker, total] = ripple::newestAccountTxPage(
|
||||||
session,
|
session,
|
||||||
@@ -1391,6 +1600,10 @@ RelationalDBInterfaceSqliteImp::newestAccountTxPageB(
|
|||||||
return {ret, opt.marker};
|
return {ret, opt.marker};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return empty value */
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::variant<RelationalDBInterface::AccountTx, TxSearched>
|
std::variant<RelationalDBInterface::AccountTx, TxSearched>
|
||||||
RelationalDBInterfaceSqliteImp::getTransaction(
|
RelationalDBInterfaceSqliteImp::getTransaction(
|
||||||
uint256 const& id,
|
uint256 const& id,
|
||||||
@@ -1404,8 +1617,9 @@ RelationalDBInterfaceSqliteImp::getTransaction(
|
|||||||
return ripple::getTransaction(*db, app_, id, range, ec);
|
return ripple::getTransaction(*db, app_, id, range, ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
if (auto shardStore = app_.getShardStore())
|
if (auto shardStore = app_.getShardStore();
|
||||||
|
shardStore && existsShardTransaction())
|
||||||
{
|
{
|
||||||
std::variant<AccountTx, TxSearched> res(TxSearched::unknown);
|
std::variant<AccountTx, TxSearched> res(TxSearched::unknown);
|
||||||
auto txMetaSession = txMetaDB_->checkoutDb();
|
auto txMetaSession = txMetaDB_->checkoutDb();
|
||||||
@@ -1436,7 +1650,8 @@ RelationalDBInterfaceSqliteImp::getTransaction(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {TxSearched::unknown};
|
/* else return unknown value */
|
||||||
|
return TxSearched::unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -1449,13 +1664,19 @@ RelationalDBInterfaceSqliteImp::ledgerDbHasSpace(Config const& config)
|
|||||||
return ripple::dbHasSpace(*db, config, j_);
|
return ripple::dbHasSpace(*db, config, j_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
return iterateLedgerBack(
|
return iterateLedgerBack(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
return ripple::dbHasSpace(session, config, j_);
|
return ripple::dbHasSpace(session, config, j_);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return true */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
RelationalDBInterfaceSqliteImp::transactionDbHasSpace(Config const& config)
|
RelationalDBInterfaceSqliteImp::transactionDbHasSpace(Config const& config)
|
||||||
{
|
{
|
||||||
@@ -1466,13 +1687,19 @@ RelationalDBInterfaceSqliteImp::transactionDbHasSpace(Config const& config)
|
|||||||
return ripple::dbHasSpace(*db, config, j_);
|
return ripple::dbHasSpace(*db, config, j_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
return iterateTransactionBack(
|
return iterateTransactionBack(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
return ripple::dbHasSpace(session, config, j_);
|
return ripple::dbHasSpace(session, config, j_);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return true */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::uint32_t
|
std::uint32_t
|
||||||
RelationalDBInterfaceSqliteImp::getKBUsedAll()
|
RelationalDBInterfaceSqliteImp::getKBUsedAll()
|
||||||
{
|
{
|
||||||
@@ -1482,7 +1709,9 @@ RelationalDBInterfaceSqliteImp::getKBUsedAll()
|
|||||||
return ripple::getKBUsedAll(lgrdb_->getSession());
|
return ripple::getKBUsedAll(lgrdb_->getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
std::uint32_t sum = 0;
|
std::uint32_t sum = 0;
|
||||||
iterateLedgerBack(
|
iterateLedgerBack(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -1492,6 +1721,10 @@ RelationalDBInterfaceSqliteImp::getKBUsedAll()
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return zero */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::uint32_t
|
std::uint32_t
|
||||||
RelationalDBInterfaceSqliteImp::getKBUsedLedger()
|
RelationalDBInterfaceSqliteImp::getKBUsedLedger()
|
||||||
{
|
{
|
||||||
@@ -1501,7 +1734,9 @@ RelationalDBInterfaceSqliteImp::getKBUsedLedger()
|
|||||||
return ripple::getKBUsedDB(lgrdb_->getSession());
|
return ripple::getKBUsedDB(lgrdb_->getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardLedger())
|
||||||
|
{
|
||||||
std::uint32_t sum = 0;
|
std::uint32_t sum = 0;
|
||||||
iterateLedgerBack(
|
iterateLedgerBack(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -1511,6 +1746,10 @@ RelationalDBInterfaceSqliteImp::getKBUsedLedger()
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return zero */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::uint32_t
|
std::uint32_t
|
||||||
RelationalDBInterfaceSqliteImp::getKBUsedTransaction()
|
RelationalDBInterfaceSqliteImp::getKBUsedTransaction()
|
||||||
{
|
{
|
||||||
@@ -1520,7 +1759,9 @@ RelationalDBInterfaceSqliteImp::getKBUsedTransaction()
|
|||||||
return ripple::getKBUsedDB(txdb_->getSession());
|
return ripple::getKBUsedDB(txdb_->getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else use shard databases */
|
/* else use shard databases, if available */
|
||||||
|
if (existsShardTransaction())
|
||||||
|
{
|
||||||
std::uint32_t sum = 0;
|
std::uint32_t sum = 0;
|
||||||
iterateTransactionBack(
|
iterateTransactionBack(
|
||||||
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
{}, [&](soci::session& session, std::uint32_t shardIndex) {
|
||||||
@@ -1530,6 +1771,10 @@ RelationalDBInterfaceSqliteImp::getKBUsedTransaction()
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* else return zero */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RelationalDBInterfaceSqliteImp::closeLedgerDB()
|
RelationalDBInterfaceSqliteImp::closeLedgerDB()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -798,7 +798,11 @@ transactionsSQL(
|
|||||||
* @param j Journal.
|
* @param j Journal.
|
||||||
* @return Vector of pairs of found transactions and its metadata
|
* @return Vector of pairs of found transactions and its metadata
|
||||||
* sorted in given order by account sequence.
|
* sorted in given order by account sequence.
|
||||||
* Also number of transactions processed.
|
* Also the number of transactions processed or skipped.
|
||||||
|
* If this number is >= 0, then it means number of transactions
|
||||||
|
* processed, if it is < 0, then ~number means number of transactions
|
||||||
|
* skipped. We need to skip some quantity of transactions if option
|
||||||
|
* offset is > 0 in the options structure.
|
||||||
*/
|
*/
|
||||||
static std::pair<RelationalDBInterface::AccountTxs, int>
|
static std::pair<RelationalDBInterface::AccountTxs, int>
|
||||||
getAccountTxs(
|
getAccountTxs(
|
||||||
@@ -937,7 +941,11 @@ getNewestAccountTxs(
|
|||||||
* @param j Journal.
|
* @param j Journal.
|
||||||
* @return Vector of tuples of found transactions, its metadata and
|
* @return Vector of tuples of found transactions, its metadata and
|
||||||
* account sequences sorted in given order by account
|
* account sequences sorted in given order by account
|
||||||
* sequence. Also number of transactions processed.
|
* sequence. Also number of transactions processed or skipped.
|
||||||
|
* If this number is >= 0, then it means number of transactions
|
||||||
|
* processed, if it is < 0, then ~number means number of transactions
|
||||||
|
* skipped. We need to skip some quantity of transactions if option
|
||||||
|
* offset is > 0 in the options structure.
|
||||||
*/
|
*/
|
||||||
static std::pair<std::vector<RelationalDBInterface::txnMetaLedgerType>, int>
|
static std::pair<std::vector<RelationalDBInterface::txnMetaLedgerType>, int>
|
||||||
getAccountTxsB(
|
getAccountTxsB(
|
||||||
|
|||||||
Reference in New Issue
Block a user