mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-20 11:45:53 +00:00
add marker to book offers
This commit is contained in:
@@ -297,13 +297,26 @@ doBookOffers(
|
|||||||
request.at("limit").kind() == boost::json::kind::int64)
|
request.at("limit").kind() == boost::json::kind::int64)
|
||||||
limit = request.at("limit").as_int64();
|
limit = request.at("limit").as_int64();
|
||||||
|
|
||||||
|
ripple::uint256 cursor;
|
||||||
|
if (request.contains("cursor"))
|
||||||
|
{
|
||||||
|
cursor.parseHex(request.at("cursor").as_string().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
ripple::Book book = {
|
ripple::Book book = {
|
||||||
{pay_currency, pay_issuer}, {get_currency, get_issuer}};
|
{pay_currency, pay_issuer}, {get_currency, get_issuer}};
|
||||||
|
|
||||||
auto start = std::chrono::system_clock::now();
|
auto start = std::chrono::system_clock::now();
|
||||||
ripple::uint256 bookBase = getBookBase(book);
|
ripple::uint256 bookBase = getBookBase(book);
|
||||||
std::vector<CassandraFlatMapBackend::LedgerObject> offers =
|
std::vector<CassandraFlatMapBackend::LedgerObject> offers;
|
||||||
backend.doBookOffers(bookBase, *sequence);
|
if (!cursor.isZero())
|
||||||
|
{
|
||||||
|
offers = backend.doBookOffers(bookBase, *sequence, cursor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
offers = backend.doBookOffers(bookBase, *sequence);
|
||||||
|
}
|
||||||
auto end = std::chrono::system_clock::now();
|
auto end = std::chrono::system_clock::now();
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(warning) << "Time loading books from Postgres: "
|
BOOST_LOG_TRIVIAL(warning) << "Time loading books from Postgres: "
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ public:
|
|||||||
query << "CREATE TABLE IF NOT EXISTS " << tableName << "books"
|
query << "CREATE TABLE IF NOT EXISTS " << tableName << "books"
|
||||||
<< " ( book blob, sequence bigint, key blob, deleted_at "
|
<< " ( book blob, sequence bigint, key blob, deleted_at "
|
||||||
"bigint, PRIMARY KEY "
|
"bigint, PRIMARY KEY "
|
||||||
"(book, key))";
|
"(book, key)) WITH CLUSTERING ORDER BY (key ASC)";
|
||||||
statement = makeStatement(query.str().c_str(), 0);
|
statement = makeStatement(query.str().c_str(), 0);
|
||||||
fut = cass_session_execute(session_.get(), statement);
|
fut = cass_session_execute(session_.get(), statement);
|
||||||
rc = cass_future_error_code(fut);
|
rc = cass_future_error_code(fut);
|
||||||
@@ -810,8 +810,9 @@ public:
|
|||||||
|
|
||||||
query = {};
|
query = {};
|
||||||
query << "SELECT key FROM " << tableName << "books "
|
query << "SELECT key FROM " << tableName << "books "
|
||||||
<< " WHERE book = ? AND sequence <= ? AND deleted_at > ? "
|
<< " WHERE book = ? AND sequence <= ? AND deleted_at > ? AND"
|
||||||
"ALLOW FILTERING";
|
" key > ? "
|
||||||
|
" ORDER BY key ASC LIMIT 300 ALLOW FILTERING";
|
||||||
|
|
||||||
prepare_future =
|
prepare_future =
|
||||||
cass_session_prepare(session_.get(), query.str().c_str());
|
cass_session_prepare(session_.get(), query.str().c_str());
|
||||||
@@ -1242,7 +1243,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<LedgerObject>
|
std::vector<LedgerObject>
|
||||||
doBookOffers(ripple::uint256 const& book, uint32_t sequence) const
|
doBookOffers(
|
||||||
|
ripple::uint256 const& book,
|
||||||
|
uint32_t sequence,
|
||||||
|
ripple::uint256 const& cursor = {}) const
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug) << "Starting doBookOffers";
|
BOOST_LOG_TRIVIAL(debug) << "Starting doBookOffers";
|
||||||
CassStatement* statement = cass_prepared_bind(getBook_);
|
CassStatement* statement = cass_prepared_bind(getBook_);
|
||||||
@@ -1277,7 +1281,17 @@ public:
|
|||||||
<< ", " << cass_error_desc(rc);
|
<< ", " << cass_error_desc(rc);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
rc = cass_statement_bind_bytes(
|
||||||
|
statement, 3, static_cast<cass_byte_t const*>(cursor.data()), 32);
|
||||||
|
|
||||||
|
if (rc != CASS_OK)
|
||||||
|
{
|
||||||
|
cass_statement_free(statement);
|
||||||
|
BOOST_LOG_TRIVIAL(error)
|
||||||
|
<< "Binding Cassandra book to doBookOffers query: " << rc
|
||||||
|
<< ", " << cass_error_desc(rc);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
CassFuture* fut;
|
CassFuture* fut;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user