mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
ledger rpc accepts more flags. binary options for all rpcs. tests to verify ledger and account_info
This commit is contained in:
@@ -19,6 +19,7 @@ struct TransactionAndMetadata
|
||||
{
|
||||
Blob transaction;
|
||||
Blob metadata;
|
||||
uint32_t ledgerSequence;
|
||||
};
|
||||
|
||||
struct AccountTransactionsCursor
|
||||
@@ -57,6 +58,9 @@ public:
|
||||
virtual std::vector<TransactionAndMetadata>
|
||||
fetchAllTransactionsInLedger(uint32_t ledgerSequence) const = 0;
|
||||
|
||||
virtual std::vector<ripple::uint256>
|
||||
fetchAllTransactionHashesInLedger(uint32_t ledgerSequence) const = 0;
|
||||
|
||||
virtual LedgerPage
|
||||
fetchLedgerPage(
|
||||
std::optional<ripple::uint256> const& cursor,
|
||||
|
||||
@@ -178,7 +178,8 @@ flatMapReadCallback(CassFuture* fut, void* cbData)
|
||||
|
||||
if (!!result)
|
||||
{
|
||||
requestParams.result = {result.getBytes(), result.getBytes()};
|
||||
requestParams.result = {
|
||||
result.getBytes(), result.getBytes(), result.getUInt32()};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,10 +240,30 @@ CassandraBackend::fetchAllTransactionsInLedger(uint32_t ledgerSequence) const
|
||||
std::vector<TransactionAndMetadata> txns;
|
||||
do
|
||||
{
|
||||
txns.push_back({result.getBytes(), result.getBytes()});
|
||||
txns.push_back(
|
||||
{result.getBytes(), result.getBytes(), result.getUInt32()});
|
||||
} while (result.nextRow());
|
||||
return txns;
|
||||
}
|
||||
std::vector<ripple::uint256>
|
||||
CassandraBackend::fetchAllTransactionHashesInLedger(
|
||||
uint32_t ledgerSequence) const
|
||||
{
|
||||
CassandraStatement statement{selectAllTransactionHashesInLedger_};
|
||||
statement.bindInt(ledgerSequence);
|
||||
CassandraResult result = executeSyncRead(statement);
|
||||
if (!result)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(error) << __func__ << " - no rows";
|
||||
return {};
|
||||
}
|
||||
std::vector<ripple::uint256> hashes;
|
||||
do
|
||||
{
|
||||
hashes.push_back(result.getUInt256());
|
||||
} while (result.nextRow());
|
||||
return hashes;
|
||||
}
|
||||
|
||||
void
|
||||
CassandraBackend::open()
|
||||
@@ -622,19 +643,25 @@ CassandraBackend::open()
|
||||
continue;
|
||||
|
||||
query = {};
|
||||
query << "SELECT transaction,metadata FROM " << tablePrefix
|
||||
<< "transactions"
|
||||
query << "SELECT transaction, metadata, ledger_sequence FROM "
|
||||
<< tablePrefix << "transactions"
|
||||
<< " WHERE hash = ?";
|
||||
if (!selectTransaction_.prepareStatement(query, session_.get()))
|
||||
continue;
|
||||
|
||||
query = {};
|
||||
query << "SELECT transaction,metadata FROM " << tablePrefix
|
||||
<< "transactions"
|
||||
query << "SELECT transaction, metadata, ledger_sequence FROM "
|
||||
<< tablePrefix << "transactions"
|
||||
<< " WHERE ledger_sequence = ?";
|
||||
if (!selectAllTransactionsInLedger_.prepareStatement(
|
||||
query, session_.get()))
|
||||
continue;
|
||||
query = {};
|
||||
query << "SELECT hash FROM " << tablePrefix << "transactions"
|
||||
<< " WHERE ledger_sequence = ?";
|
||||
if (!selectAllTransactionHashesInLedger_.prepareStatement(
|
||||
query, session_.get()))
|
||||
continue;
|
||||
|
||||
query = {};
|
||||
query << "SELECT key FROM " << tablePrefix << "keys "
|
||||
|
||||
@@ -542,6 +542,7 @@ private:
|
||||
CassandraPreparedStatement insertTransaction_;
|
||||
CassandraPreparedStatement selectTransaction_;
|
||||
CassandraPreparedStatement selectAllTransactionsInLedger_;
|
||||
CassandraPreparedStatement selectAllTransactionHashesInLedger_;
|
||||
CassandraPreparedStatement selectObject_;
|
||||
CassandraPreparedStatement selectLedgerPageKeys_;
|
||||
CassandraPreparedStatement selectLedgerPage_;
|
||||
@@ -806,6 +807,9 @@ public:
|
||||
std::vector<TransactionAndMetadata>
|
||||
fetchAllTransactionsInLedger(uint32_t ledgerSequence) const override;
|
||||
|
||||
std::vector<ripple::uint256>
|
||||
fetchAllTransactionHashesInLedger(uint32_t ledgerSequence) const override;
|
||||
|
||||
// Synchronously fetch the object with key key and store the result in
|
||||
// pno
|
||||
// @param key the key of the object
|
||||
@@ -859,7 +863,7 @@ public:
|
||||
BOOST_LOG_TRIVIAL(error) << __func__ << " - no rows";
|
||||
return {};
|
||||
}
|
||||
return {{result.getBytes(), result.getBytes()}};
|
||||
return {{result.getBytes(), result.getBytes(), result.getUInt32()}};
|
||||
}
|
||||
LedgerPage
|
||||
fetchLedgerPage2(
|
||||
@@ -1212,8 +1216,8 @@ public:
|
||||
, isDeleted(isDeleted)
|
||||
, book(std::move(book))
|
||||
{
|
||||
if (isCreated or isDeleted)
|
||||
++refs;
|
||||
// if (isCreated or isDeleted)
|
||||
// ++refs;
|
||||
if (book)
|
||||
++refs;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,10 @@ PostgresBackend::fetchTransaction(ripple::uint256 const& hash) const
|
||||
auto res = pgQuery(sql.str().data());
|
||||
if (checkResult(res, 3))
|
||||
{
|
||||
return {{res.asUnHexedBlob(0, 0), res.asUnHexedBlob(0, 1)}};
|
||||
return {
|
||||
{res.asUnHexedBlob(0, 0),
|
||||
res.asUnHexedBlob(0, 1),
|
||||
res.asBigInt(0, 2)}};
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -281,12 +284,35 @@ PostgresBackend::fetchAllTransactionsInLedger(uint32_t ledgerSequence) const
|
||||
std::vector<TransactionAndMetadata> txns;
|
||||
for (size_t i = 0; i < numRows; ++i)
|
||||
{
|
||||
txns.push_back({res.asUnHexedBlob(i, 0), res.asUnHexedBlob(i, 1)});
|
||||
txns.push_back(
|
||||
{res.asUnHexedBlob(i, 0),
|
||||
res.asUnHexedBlob(i, 1),
|
||||
res.asBigInt(i, 2)});
|
||||
}
|
||||
return txns;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
std::vector<ripple::uint256>
|
||||
PostgresBackend::fetchAllTransactionHashesInLedger(
|
||||
uint32_t ledgerSequence) const
|
||||
{
|
||||
PgQuery pgQuery(pgPool_);
|
||||
std::stringstream sql;
|
||||
sql << "SELECT hash FROM transactions WHERE "
|
||||
<< "ledger_seq = " << std::to_string(ledgerSequence);
|
||||
auto res = pgQuery(sql.str().data());
|
||||
if (size_t numRows = checkResult(res, 3))
|
||||
{
|
||||
std::vector<ripple::uint256> hashes;
|
||||
for (size_t i = 0; i < numRows; ++i)
|
||||
{
|
||||
hashes.push_back(res.asUInt256(i, 0));
|
||||
}
|
||||
return hashes;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
LedgerPage
|
||||
PostgresBackend::fetchLedgerPage(
|
||||
@@ -384,7 +410,9 @@ PostgresBackend::fetchTransactions(
|
||||
for (size_t i = 0; i < numRows; ++i)
|
||||
{
|
||||
results.push_back(
|
||||
{res.asUnHexedBlob(i, 0), res.asUnHexedBlob(i, 1)});
|
||||
{res.asUnHexedBlob(i, 0),
|
||||
res.asUnHexedBlob(i, 1),
|
||||
res.asBigInt(i, 2)});
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,9 @@ public:
|
||||
std::vector<TransactionAndMetadata>
|
||||
fetchAllTransactionsInLedger(uint32_t ledgerSequence) const override;
|
||||
|
||||
std::vector<ripple::uint256>
|
||||
fetchAllTransactionHashesInLedger(uint32_t ledgerSequence) const override;
|
||||
|
||||
LedgerPage
|
||||
fetchLedgerPage(
|
||||
std::optional<ripple::uint256> const& cursor,
|
||||
|
||||
@@ -643,5 +643,7 @@ ReportingETL::ReportingETL(
|
||||
ioc)
|
||||
{
|
||||
flatMapBackend_->open();
|
||||
if (config.contains("start_sequence"))
|
||||
startSequence_ = config.at("start_sequence").as_int64();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user