diff --git a/PostgresDatabase_8cpp_source.html b/PostgresDatabase_8cpp_source.html
index 6009e5c56a..0a82d81a21 100644
--- a/PostgresDatabase_8cpp_source.html
+++ b/PostgresDatabase_8cpp_source.html
@@ -236,898 +236,894 @@ $(function() {
175 "total_coins, closing_time, prev_closing_time, close_time_res, "
176 "close_flags, ledger_seq FROM ledgers ";
- 178 uint32_t expNumResults = 1;
-
- 180 if (
auto ledgerSeq = std::get_if<uint32_t>(&whichLedger))
-
-
-
- 184 else if (
auto ledgerHash = std::get_if<uint256>(&whichLedger))
-
- 186 sql << (
"WHERE ledger_hash = \'\\x" +
strHex(*ledgerHash) +
"\'");
-
-
-
-
-
- 192 expNumResults = minAndMax->second - minAndMax->first;
-
-
-
-
+ 178 if (
auto ledgerSeq = std::get_if<uint32_t>(&whichLedger))
+
+
+
+ 182 else if (
auto ledgerHash = std::get_if<uint256>(&whichLedger))
+
+ 184 sql << (
"WHERE ledger_hash = \'\\x" +
strHex(*ledgerHash) +
"\'");
+
+
+
+
+
+
+
+
+
+
+
+ 196 sql << (
"ORDER BY ledger_seq desc LIMIT 1");
-
-
- 200 sql << (
"ORDER BY ledger_seq desc LIMIT 1");
-
-
-
- 204 JLOG(log.trace()) << __func__ <<
" : sql = " << sql.
str();
-
- 206 auto res = PgQuery(pgPool)(sql.
str().data());
-
-
- 209 JLOG(log.error()) << __func__ <<
" : Postgres response is null - sql = "
-
-
-
-
- 214 else if (res.status() != PGRES_TUPLES_OK)
-
- 216 JLOG(log.error()) << __func__
- 217 <<
" : Postgres response should have been "
- 218 "PGRES_TUPLES_OK but instead was "
- 219 << res.status() <<
" - msg = " << res.msg()
- 220 <<
" - sql = " << sql.
str();
-
-
-
-
- 225 JLOG(log.trace()) << __func__ <<
" Postgres result msg : " << res.msg();
-
- 227 if (res.isNull() || res.ntuples() == 0)
-
- 229 JLOG(log.debug()) << __func__
- 230 <<
" : Ledger not found. sql = " << sql.
str();
-
-
- 233 else if (res.ntuples() > 0)
-
- 235 if (res.nfields() != 10)
-
- 237 JLOG(log.error()) << __func__
- 238 <<
" : Wrong number of fields in Postgres "
- 239 "response. Expected 10, but got "
- 240 << res.nfields() <<
" . sql = " << sql.
str();
-
-
-
-
-
- 246 for (
size_t i = 0; i < res.ntuples(); ++i)
-
- 248 char const* hash = res.c_str(i, 0);
- 249 char const* prevHash = res.c_str(i, 1);
- 250 char const* accountHash = res.c_str(i, 2);
- 251 char const* txHash = res.c_str(i, 3);
-
-
-
-
-
-
-
- 259 JLOG(log.trace()) << __func__ <<
" - Postgres response = " << hash
- 260 <<
" , " << prevHash <<
" , " << accountHash <<
" , "
- 261 << txHash <<
" , " << totalCoins <<
", " << closeTime
- 262 <<
", " << parentCloseTime <<
", " << closeTimeRes
- 263 <<
", " << closeFlags <<
", " << ledgerSeq
- 264 <<
" - sql = " << sql.
str();
- 265 JLOG(log.debug()) << __func__
- 266 <<
" - Successfully fetched ledger with sequence = "
- 267 << ledgerSeq <<
" from Postgres";
-
-
-
-
-
-
+
+
+ 200 JLOG(log.trace()) << __func__ <<
" : sql = " << sql.
str();
+
+ 202 auto res = PgQuery(pgPool)(sql.
str().data());
+
+
+ 205 JLOG(log.error()) << __func__ <<
" : Postgres response is null - sql = "
+
+
+
+
+ 210 else if (res.status() != PGRES_TUPLES_OK)
+
+ 212 JLOG(log.error()) << __func__
+ 213 <<
" : Postgres response should have been "
+ 214 "PGRES_TUPLES_OK but instead was "
+ 215 << res.status() <<
" - msg = " << res.msg()
+ 216 <<
" - sql = " << sql.
str();
+
+
+
+
+ 221 JLOG(log.trace()) << __func__ <<
" Postgres result msg : " << res.msg();
+
+ 223 if (res.isNull() || res.ntuples() == 0)
+
+ 225 JLOG(log.debug()) << __func__
+ 226 <<
" : Ledger not found. sql = " << sql.
str();
+
+
+ 229 else if (res.ntuples() > 0)
+
+ 231 if (res.nfields() != 10)
+
+ 233 JLOG(log.error()) << __func__
+ 234 <<
" : Wrong number of fields in Postgres "
+ 235 "response. Expected 10, but got "
+ 236 << res.nfields() <<
" . sql = " << sql.
str();
+
+
+
+
+
+ 242 for (
size_t i = 0; i < res.ntuples(); ++i)
+
+ 244 char const* hash = res.c_str(i, 0);
+ 245 char const* prevHash = res.c_str(i, 1);
+ 246 char const* accountHash = res.c_str(i, 2);
+ 247 char const* txHash = res.c_str(i, 3);
+
+
+
+
+
+
+
+ 255 JLOG(log.trace()) << __func__ <<
" - Postgres response = " << hash
+ 256 <<
" , " << prevHash <<
" , " << accountHash <<
" , "
+ 257 << txHash <<
" , " << totalCoins <<
", " << closeTime
+ 258 <<
", " << parentCloseTime <<
", " << closeTimeRes
+ 259 <<
", " << closeFlags <<
", " << ledgerSeq
+ 260 <<
" - sql = " << sql.
str();
+ 261 JLOG(log.debug()) << __func__
+ 262 <<
" - Successfully fetched ledger with sequence = "
+ 263 << ledgerSeq <<
" from Postgres";
+
+
+
+
+
+
+
+
+
+
-
-
-
-
- 279 info.
drops = totalCoins;
- 280 info.
closeTime = time_point{duration{closeTime}};
-
-
-
- 284 info.
seq = ledgerSeq;
-
-
-
-
-
+ 275 info.
drops = totalCoins;
+ 276 info.
closeTime = time_point{duration{closeTime}};
+
+
+
+ 280 info.
seq = ledgerSeq;
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
- 311 [&infos, &app, &pgPool](
auto&& arg) {
-
-
-
- 315 assert(infos.
size() <= 1);
-
-
-
-
-
- 321 #ifdef RIPPLED_REPORTING
-
-
-
- 325 JLOG(j.
debug()) << __func__;
- 326 auto cmd = boost::format(
- 327 R
"(INSERT INTO ledgers
- 328 VALUES (%u,'\x%s', '\x%s',%u,%u,%u,%u,%u,'\x%s','\x%s'))");
-
- 330 auto ledgerInsert = boost::str(
- 331 cmd % info.seq %
strHex(info.hash) %
strHex(info.parentHash) %
- 332 info.drops.drops() % info.closeTime.time_since_epoch().count() %
- 333 info.parentCloseTime.time_since_epoch().count() %
- 334 info.closeTimeResolution.count() % info.closeFlags %
-
- 336 JLOG(j.
trace()) << __func__ <<
" : "
-
- 338 <<
"query string = " << ledgerInsert;
-
- 340 auto res = pgQuery(ledgerInsert.data());
-
-
-
-
- 345 enum class DataFormat { binary, expanded };
-
-
-
-
-
-
-
-
- 354 if (format == DataFormat::binary)
-
-
-
-
-
-
-
- 362 for (
size_t i = 0; i < txns.size(); ++i)
-
- 364 auto& [txn, meta] = txns[i];
- 365 if (format == DataFormat::binary)
-
- 367 auto& transactions = std::get<TxnsDataBinary>(ret);
- 368 Serializer txnSer = txn->getSerializer();
- 369 Serializer metaSer = meta->getSerializer();
-
- 371 Blob txnBlob = txnSer.getData();
- 372 Blob metaBlob = metaSer.getData();
-
-
-
-
-
- 378 auto& transactions = std::get<TxnsData>(ret);
-
- 380 auto txnRet = std::make_shared<Transaction>(txn, reason, app);
- 381 txnRet->setLedger(ledgerSequences[i]);
-
- 383 auto txMeta = std::make_shared<TxMeta>(
- 384 txnRet->getID(), ledgerSequences[i], *meta);
-
-
-
-
-
-
-
- 392 processAccountTxStoredProcedureResult(
- 393 RelationalDatabase::AccountTxArgs
const& args,
-
-
-
-
-
- 399 ret.limit = args.limit;
-
-
-
- 403 if (result.
isMember(
"transactions"))
-
-
-
- 407 for (
auto& t : result[
"transactions"])
-
- 409 if (t.isMember(
"ledger_seq") && t.isMember(
"nodestore_hash"))
-
- 411 uint32_t ledgerSequence = t[
"ledger_seq"].asUInt();
-
- 413 t[
"nodestore_hash"].asString();
- 414 nodestoreHashHex.
erase(0, 2);
-
- 416 if (!nodestoreHash.parseHex(nodestoreHashHex))
-
-
- 419 if (nodestoreHash.isNonZero())
-
- 421 ledgerSequences.
push_back(ledgerSequence);
- 422 nodestoreHashes.
push_back(nodestoreHash);
-
-
-
-
- 427 return {ret, {
rpcINTERNAL,
"nodestoreHash is zero"}};
-
-
-
-
-
- 433 return {ret, {
rpcINTERNAL,
"missing postgres fields"}};
-
-
-
- 437 assert(nodestoreHashes.
size() == ledgerSequences.
size());
-
-
-
-
- 442 args.binary ? DataFormat::binary : DataFormat::expanded);
-
- 444 JLOG(j.
trace()) << __func__ <<
" : processed db results";
-
- 446 if (result.isMember(
"marker"))
-
- 448 auto& marker = result[
"marker"];
- 449 assert(marker.isMember(
"ledger"));
- 450 assert(marker.isMember(
"seq"));
-
- 452 marker[
"ledger"].asUInt(), marker[
"seq"].asUInt()};
-
- 454 assert(result.isMember(
"ledger_index_min"));
- 455 assert(result.isMember(
"ledger_index_max"));
-
- 457 result[
"ledger_index_min"].asUInt(),
- 458 result[
"ledger_index_max"].asUInt()};
-
-
- 461 else if (result.isMember(
"error"))
-
-
- 464 << __func__ <<
" : error = " << result[
"error"].asString();
-
-
-
+
+
+
+
+
+
+
+
+ 307 [&infos, &app, &pgPool](
auto&& arg) {
+
+
+
+ 311 assert(infos.
size() <= 1);
+
+
+
+
+
+ 317 #ifdef RIPPLED_REPORTING
+
+
+
+ 321 JLOG(j.
debug()) << __func__;
+ 322 auto cmd = boost::format(
+ 323 R
"(INSERT INTO ledgers
+ 324 VALUES (%u,'\x%s', '\x%s',%u,%u,%u,%u,%u,'\x%s','\x%s'))");
+
+ 326 auto ledgerInsert = boost::str(
+ 327 cmd % info.seq %
strHex(info.hash) %
strHex(info.parentHash) %
+ 328 info.drops.drops() % info.closeTime.time_since_epoch().count() %
+ 329 info.parentCloseTime.time_since_epoch().count() %
+ 330 info.closeTimeResolution.count() % info.closeFlags %
+
+ 332 JLOG(j.
trace()) << __func__ <<
" : "
+
+ 334 <<
"query string = " << ledgerInsert;
+
+ 336 auto res = pgQuery(ledgerInsert.data());
+
+
+
+
+ 341 enum class DataFormat { binary, expanded };
+
+
+
+
+
+
+
+
+ 350 if (format == DataFormat::binary)
+
+
+
+
+
+
+
+ 358 for (
size_t i = 0; i < txns.size(); ++i)
+
+ 360 auto& [txn, meta] = txns[i];
+ 361 if (format == DataFormat::binary)
+
+ 363 auto& transactions = std::get<TxnsDataBinary>(ret);
+ 364 Serializer txnSer = txn->getSerializer();
+ 365 Serializer metaSer = meta->getSerializer();
+
+ 367 Blob txnBlob = txnSer.getData();
+ 368 Blob metaBlob = metaSer.getData();
+
+
+
+
+
+ 374 auto& transactions = std::get<TxnsData>(ret);
+
+ 376 auto txnRet = std::make_shared<Transaction>(txn, reason, app);
+ 377 txnRet->setLedger(ledgerSequences[i]);
+
+ 379 auto txMeta = std::make_shared<TxMeta>(
+ 380 txnRet->getID(), ledgerSequences[i], *meta);
+
+
+
+
+
+
+
+ 388 processAccountTxStoredProcedureResult(
+ 389 RelationalDatabase::AccountTxArgs
const& args,
+
+
+
+
+
+ 395 ret.limit = args.limit;
+
+
+
+ 399 if (result.
isMember(
"transactions"))
+
+
+
+ 403 for (
auto& t : result[
"transactions"])
+
+ 405 if (t.isMember(
"ledger_seq") && t.isMember(
"nodestore_hash"))
+
+ 407 uint32_t ledgerSequence = t[
"ledger_seq"].asUInt();
+
+ 409 t[
"nodestore_hash"].asString();
+ 410 nodestoreHashHex.
erase(0, 2);
+
+ 412 if (!nodestoreHash.parseHex(nodestoreHashHex))
+
+
+ 415 if (nodestoreHash.isNonZero())
+
+ 417 ledgerSequences.
push_back(ledgerSequence);
+ 418 nodestoreHashes.
push_back(nodestoreHash);
+
+
+
+
+ 423 return {ret, {
rpcINTERNAL,
"nodestoreHash is zero"}};
+
+
+
+
+
+ 429 return {ret, {
rpcINTERNAL,
"missing postgres fields"}};
+
+
+
+ 433 assert(nodestoreHashes.
size() == ledgerSequences.
size());
+
+
+
+
+ 438 args.binary ? DataFormat::binary : DataFormat::expanded);
+
+ 440 JLOG(j.
trace()) << __func__ <<
" : processed db results";
+
+ 442 if (result.isMember(
"marker"))
+
+ 444 auto& marker = result[
"marker"];
+ 445 assert(marker.isMember(
"ledger"));
+ 446 assert(marker.isMember(
"seq"));
+
+ 448 marker[
"ledger"].asUInt(), marker[
"seq"].asUInt()};
+
+ 450 assert(result.isMember(
"ledger_index_min"));
+ 451 assert(result.isMember(
"ledger_index_max"));
+
+ 453 result[
"ledger_index_min"].asUInt(),
+ 454 result[
"ledger_index_max"].asUInt()};
+
+
+ 457 else if (result.isMember(
"error"))
+
+
+ 460 << __func__ <<
" : error = " << result[
"error"].asString();
+
+
+
+
+
+
+ 467 return {ret, {
rpcINTERNAL,
"unexpected Postgres response"}};
-
-
- 471 return {ret, {
rpcINTERNAL,
"unexpected Postgres response"}};
-
-
-
-
- 476 JLOG(j.
debug()) << __func__ <<
" : "
- 477 <<
"Caught exception : " << e.
what();
-
-
-
-
-
-
-
-
- 486 #ifdef RIPPLED_REPORTING
-
-
-
-
-
-
-
- 494 #ifdef RIPPLED_REPORTING
- 495 auto seq = PgQuery(
pgPool_)(
"SELECT min_ledger()");
-
-
- 498 JLOG(
j_.
error()) <<
"Error querying minimum ledger sequence.";
-
- 500 else if (!seq.isNull())
-
-
-
-
-
-
-
-
- 509 #ifdef RIPPLED_REPORTING
- 510 auto seq = PgQuery(
pgPool_)(
"SELECT max_ledger()");
- 511 if (seq && !seq.isNull())
- 512 return seq.asBigInt();
-
-
-
-
-
-
-
- 520 #ifdef RIPPLED_REPORTING
- 521 auto range = PgQuery(
pgPool_)(
"SELECT complete_ledgers()");
-
- 523 return range.c_str();
-
-
-
-
-
-
-
- 531 using namespace std::chrono_literals;
- 532 #ifdef RIPPLED_REPORTING
- 533 auto age = PgQuery(
pgPool_)(
"SELECT age()");
- 534 if (!age || age.isNull())
- 535 JLOG(
j_.
debug()) <<
"No ledgers in database";
-
-
-
-
-
-
-
-
-
-
-
- 547 #ifdef RIPPLED_REPORTING
- 548 JLOG(
j_.
debug()) << __func__ <<
" : "
- 549 <<
"Beginning write to Postgres";
-
-
-
-
-
-
- 556 auto res = pg(
"BEGIN");
- 557 if (!res || res.status() != PGRES_COMMAND_OK)
-
-
- 560 msg <<
"bulkWriteToTable : Postgres insert error: " << res.msg();
- 561 Throw<std::runtime_error>(msg.
str());
-
-
-
-
-
- 567 if (!writeToLedgersDB(info, pg,
j_))
-
- 569 JLOG(
j_.
warn()) << __func__ <<
" : "
- 570 <<
"Failed to write to ledgers database.";
-
-
-
-
-
- 576 for (
auto const& data : accountTxData)
-
-
-
- 580 auto idx = data.transactionIndex;
- 581 auto ledgerSeq = data.ledgerSequence;
-
-
-
- 585 << txHash <<
'\t' <<
"\\\\x" << nodestoreHash
-
-
- 588 for (
auto const& a : data.accounts)
-
-
- 591 accountTransactionsCopyBuffer
-
-
-
-
+
+
+
+ 472 JLOG(j.
debug()) << __func__ <<
" : "
+ 473 <<
"Caught exception : " << e.
what();
+
+
+
+
+
+
+
+
+ 482 #ifdef RIPPLED_REPORTING
+
+
+
+
+
+
+
+ 490 #ifdef RIPPLED_REPORTING
+ 491 auto seq = PgQuery(
pgPool_)(
"SELECT min_ledger()");
+
+
+ 494 JLOG(
j_.
error()) <<
"Error querying minimum ledger sequence.";
+
+ 496 else if (!seq.isNull())
+
+
+
+
+
+
+
+
+ 505 #ifdef RIPPLED_REPORTING
+ 506 auto seq = PgQuery(
pgPool_)(
"SELECT max_ledger()");
+ 507 if (seq && !seq.isNull())
+ 508 return seq.asBigInt();
+
+
+
+
+
+
+
+ 516 #ifdef RIPPLED_REPORTING
+ 517 auto range = PgQuery(
pgPool_)(
"SELECT complete_ledgers()");
+
+ 519 return range.c_str();
+
+
+
+
+
+
+
+ 527 using namespace std::chrono_literals;
+ 528 #ifdef RIPPLED_REPORTING
+ 529 auto age = PgQuery(
pgPool_)(
"SELECT age()");
+ 530 if (!age || age.isNull())
+ 531 JLOG(
j_.
debug()) <<
"No ledgers in database";
+
+
+
+
+
+
+
+
+
+
+
+ 543 #ifdef RIPPLED_REPORTING
+ 544 JLOG(
j_.
debug()) << __func__ <<
" : "
+ 545 <<
"Beginning write to Postgres";
+
+
+
+
+
+
+ 552 auto res = pg(
"BEGIN");
+ 553 if (!res || res.status() != PGRES_COMMAND_OK)
+
+
+ 556 msg <<
"bulkWriteToTable : Postgres insert error: " << res.msg();
+ 557 Throw<std::runtime_error>(msg.
str());
+
+
+
+
+
+ 563 if (!writeToLedgersDB(info, pg,
j_))
+
+ 565 JLOG(
j_.
warn()) << __func__ <<
" : "
+ 566 <<
"Failed to write to ledgers database.";
+
+
+
+
+
+ 572 for (
auto const& data : accountTxData)
+
+
+
+ 576 auto idx = data.transactionIndex;
+ 577 auto ledgerSeq = data.ledgerSequence;
+
+
+
+ 581 << txHash <<
'\t' <<
"\\\\x" << nodestoreHash
+
+
+ 584 for (
auto const& a : data.accounts)
+
+
+ 587 accountTransactionsCopyBuffer
+
+
+
+
+
+ 593 pg.bulkInsert(
"transactions", transactionsCopyBuffer.
str());
+
+ 595 "account_transactions", accountTransactionsCopyBuffer.
str());
- 597 pg.bulkInsert(
"transactions", transactionsCopyBuffer.
str());
-
- 599 "account_transactions", accountTransactionsCopyBuffer.
str());
-
-
- 602 if (!res || res.status() != PGRES_COMMAND_OK)
-
-
- 605 msg <<
"bulkWriteToTable : Postgres insert error: " << res.msg();
-
- 607 Throw<std::runtime_error>(msg.
str());
-
-
- 610 JLOG(
j_.
info()) << __func__ <<
" : "
- 611 <<
"Successfully wrote to Postgres";
-
-
-
-
-
- 617 <<
"Caught exception writing to Postgres : "
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 649 assert(infos.size() <= 1);
-
- 651 return infos[0].hash;
-
-
-
-
-
-
-
-
- 660 assert(infos.size() <= 1);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 675 for (
auto& info : infos)
-
- 677 ret[info.seq] = {info.hash, info.parentHash};
-
-
-
-
-
-
-
-
-
- 687 #ifdef RIPPLED_REPORTING
-
-
-
- 691 "SELECT nodestore_hash"
- 692 " FROM transactions "
- 693 " WHERE ledger_seq = " +
-
-
-
-
-
- 699 JLOG(log.error()) << __func__
- 700 <<
" : Postgres response is null - query = " << query;
-
-
-
- 704 else if (res.status() != PGRES_TUPLES_OK)
-
- 706 JLOG(log.error()) << __func__
- 707 <<
" : Postgres response should have been "
- 708 "PGRES_TUPLES_OK but instead was "
- 709 << res.status() <<
" - msg = " << res.msg()
- 710 <<
" - query = " << query;
-
-
-
-
- 715 JLOG(log.trace()) << __func__ <<
" Postgres result msg : " << res.msg();
-
- 717 if (res.isNull() || res.ntuples() == 0)
-
- 719 JLOG(log.debug()) << __func__
- 720 <<
" : Ledger not found. query = " << query;
-
-
- 723 else if (res.ntuples() > 0)
-
- 725 if (res.nfields() != 1)
-
- 727 JLOG(log.error()) << __func__
- 728 <<
" : Wrong number of fields in Postgres "
- 729 "response. Expected 1, but got "
- 730 << res.nfields() <<
" . query = " << query;
-
-
-
-
-
- 736 JLOG(log.trace()) << __func__ <<
" : result = " << res.c_str()
- 737 <<
" : query = " << query;
- 738 for (
size_t i = 0; i < res.ntuples(); ++i)
-
- 740 char const* nodestoreHash = res.
c_str(i, 0);
-
- 742 if (!hash.
parseHex(nodestoreHash + 2))
-
+
+ 598 if (!res || res.status() != PGRES_COMMAND_OK)
+
+
+ 601 msg <<
"bulkWriteToTable : Postgres insert error: " << res.msg();
+
+ 603 Throw<std::runtime_error>(msg.
str());
+
+
+ 606 JLOG(
j_.
info()) << __func__ <<
" : "
+ 607 <<
"Successfully wrote to Postgres";
+
+
+
+
+
+ 613 <<
"Caught exception writing to Postgres : "
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 645 assert(infos.size() <= 1);
+
+ 647 return infos[0].hash;
+
+
+
+
+
+
+
+
+ 656 assert(infos.size() <= 1);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 671 for (
auto& info : infos)
+
+ 673 ret[info.seq] = {info.hash, info.parentHash};
+
+
+
+
+
+
+
+
+
+ 683 #ifdef RIPPLED_REPORTING
+
+
+
+ 687 "SELECT nodestore_hash"
+ 688 " FROM transactions "
+ 689 " WHERE ledger_seq = " +
+
+
+
+
+
+ 695 JLOG(log.error()) << __func__
+ 696 <<
" : Postgres response is null - query = " << query;
+
+
+
+ 700 else if (res.status() != PGRES_TUPLES_OK)
+
+ 702 JLOG(log.error()) << __func__
+ 703 <<
" : Postgres response should have been "
+ 704 "PGRES_TUPLES_OK but instead was "
+ 705 << res.status() <<
" - msg = " << res.msg()
+ 706 <<
" - query = " << query;
+
+
+
+
+ 711 JLOG(log.trace()) << __func__ <<
" Postgres result msg : " << res.msg();
+
+ 713 if (res.isNull() || res.ntuples() == 0)
+
+ 715 JLOG(log.debug()) << __func__
+ 716 <<
" : Ledger not found. query = " << query;
+
+
+ 719 else if (res.ntuples() > 0)
+
+ 721 if (res.nfields() != 1)
+
+ 723 JLOG(log.error()) << __func__
+ 724 <<
" : Wrong number of fields in Postgres "
+ 725 "response. Expected 1, but got "
+ 726 << res.nfields() <<
" . query = " << query;
+
+
+
+
+
+ 732 JLOG(log.trace()) << __func__ <<
" : result = " << res.c_str()
+ 733 <<
" : query = " << query;
+ 734 for (
size_t i = 0; i < res.ntuples(); ++i)
+
+ 736 char const* nodestoreHash = res.
c_str(i, 0);
+
+ 738 if (!hash.
parseHex(nodestoreHash + 2))
+
+
+
+
+
-
-
-
-
- 749 return nodestoreHashes;
-
-
-
-
-
-
-
- 757 #ifdef RIPPLED_REPORTING
-
-
-
- 761 Throw<std::runtime_error>(
- 762 "called getTxHistory but not in reporting mode");
-
-
-
- 766 boost::format(
"SELECT nodestore_hash, ledger_seq "
-
- 768 " ORDER BY ledger_seq DESC LIMIT 20 "
-
-
-
-
-
-
-
-
- 777 <<
" : Postgres response is null - sql = " << sql;
-
-
-
- 781 else if (res.status() != PGRES_TUPLES_OK)
-
-
- 784 <<
" : Postgres response should have been "
- 785 "PGRES_TUPLES_OK but instead was "
- 786 << res.status() <<
" - msg = " << res.msg()
- 787 <<
" - sql = " << sql;
-
-
-
-
- 792 JLOG(
j_.
trace()) << __func__ <<
" Postgres result msg : " << res.msg();
-
- 794 if (res.isNull() || res.ntuples() == 0)
-
- 796 JLOG(
j_.
debug()) << __func__ <<
" : Empty postgres response";
-
-
-
- 800 else if (res.ntuples() > 0)
-
- 802 if (res.nfields() != 2)
-
-
- 805 <<
" : Wrong number of fields in Postgres "
- 806 "response. Expected 1, but got "
- 807 << res.nfields() <<
" . sql = " << sql;
-
-
-
-
-
- 813 JLOG(
j_.
trace()) << __func__ <<
" : Postgres result = " << res.c_str();
-
-
-
- 817 for (
size_t i = 0; i < res.ntuples(); ++i)
-
-
- 820 if (!hash.
parseHex(res.c_str(i, 0) + 2))
-
-
- 823 ledgerSequences.
push_back(res.asBigInt(i, 1));
-
-
-
- 827 for (
size_t i = 0; i < txns.size(); ++i)
-
- 829 auto const& [sttx, meta] = txns[i];
-
-
-
- 833 auto txn = std::make_shared<Transaction>(sttx, reason,
app_);
- 834 txn->setLedger(ledgerSequences[i]);
-
-
-
+ 745 return nodestoreHashes;
+
+
+
+
+
+
+
+ 753 #ifdef RIPPLED_REPORTING
+
+
+
+ 757 Throw<std::runtime_error>(
+ 758 "called getTxHistory but not in reporting mode");
+
+
+
+ 762 boost::format(
"SELECT nodestore_hash, ledger_seq "
+
+ 764 " ORDER BY ledger_seq DESC LIMIT 20 "
+
+
+
+
+
+
+
+
+ 773 <<
" : Postgres response is null - sql = " << sql;
+
+
+
+ 777 else if (res.status() != PGRES_TUPLES_OK)
+
+
+ 780 <<
" : Postgres response should have been "
+ 781 "PGRES_TUPLES_OK but instead was "
+ 782 << res.status() <<
" - msg = " << res.msg()
+ 783 <<
" - sql = " << sql;
+
+
+
+
+ 788 JLOG(
j_.
trace()) << __func__ <<
" Postgres result msg : " << res.msg();
+
+ 790 if (res.isNull() || res.ntuples() == 0)
+
+ 792 JLOG(
j_.
debug()) << __func__ <<
" : Empty postgres response";
+
+
+
+ 796 else if (res.ntuples() > 0)
+
+ 798 if (res.nfields() != 2)
+
+
+ 801 <<
" : Wrong number of fields in Postgres "
+ 802 "response. Expected 1, but got "
+ 803 << res.nfields() <<
" . sql = " << sql;
+
+
+
+
+
+ 809 JLOG(
j_.
trace()) << __func__ <<
" : Postgres result = " << res.c_str();
+
+
+
+ 813 for (
size_t i = 0; i < res.ntuples(); ++i)
+
+
+ 816 if (!hash.
parseHex(res.c_str(i, 0) + 2))
+
+
+ 819 ledgerSequences.
push_back(res.asBigInt(i, 1));
+
+
+
+ 823 for (
size_t i = 0; i < txns.size(); ++i)
+
+ 825 auto const& [sttx, meta] = txns[i];
+
+
+
+ 829 auto txn = std::make_shared<Transaction>(sttx, reason,
app_);
+ 830 txn->setLedger(ledgerSequences[i]);
+
+
+
+
+
+
+
-
-
-
-
-
-
-
- 846 #ifdef RIPPLED_REPORTING
-
-
- 849 char const*& command = dbParams.first;
-
-
- 852 "SELECT account_tx($1::bytea, $2::bool, "
- 853 "$3::bigint, $4::bigint, $5::bigint, $6::bytea, "
- 854 "$7::bigint, $8::bool, $9::bigint, $10::bigint)";
-
-
- 857 values[1] = args.
forward ?
"true" :
"false";
-
-
- 860 if (args.
limit == 0 || args.
limit > page_length)
-
-
-
-
-
-
- 867 if (
auto range = std::get_if<LedgerRange>(&args.
ledger.value()))
-
-
-
+
+
+
+ 842 #ifdef RIPPLED_REPORTING
+
+
+ 845 char const*& command = dbParams.first;
+
+
+ 848 "SELECT account_tx($1::bytea, $2::bool, "
+ 849 "$3::bigint, $4::bigint, $5::bigint, $6::bytea, "
+ 850 "$7::bigint, $8::bool, $9::bigint, $10::bigint)";
+
+
+ 853 values[1] = args.
forward ?
"true" :
"false";
+
+
+ 856 if (args.
limit == 0 || args.
limit > page_length)
+
+
+
+
+
+
+ 863 if (
auto range = std::get_if<LedgerRange>(&args.
ledger.value()))
+
+
+
+
+ 868 else if (
auto hash = std::get_if<LedgerHash>(&args.
ledger.value()))
+
+ 870 values[5] = (
"\\x" +
strHex(*hash));
- 872 else if (
auto hash = std::get_if<LedgerHash>(&args.
ledger.value()))
-
- 874 values[5] = (
"\\x" +
strHex(*hash));
-
-
- 877 auto sequence = std::get_if<LedgerSequence>(&args.
ledger.value()))
+
+ 873 auto sequence = std::get_if<LedgerSequence>(&args.
ledger.value()))
+
+
+
+ 877 else if (std::get_if<LedgerShortcut>(&args.
ledger.value()))
-
-
- 881 else if (std::get_if<LedgerShortcut>(&args.
ledger.value()))
-
-
-
-
-
-
- 888 JLOG(
j_.
error()) <<
"doAccountTxStoredProcedure - "
- 889 <<
"Error parsing ledger args";
-
-
-
-
-
-
-
-
-
- 899 for (
size_t i = 0; i < values.
size(); ++i)
-
-
- 902 << (values[i] ? values[i].value() :
"null");
-
-
- 905 auto res = PgQuery(
pgPool_)(dbParams);
-
-
-
- 909 <<
" : Postgres response is null - account = "
-
-
-
-
- 914 else if (res.status() != PGRES_TUPLES_OK)
-
-
- 917 <<
" : Postgres response should have been "
- 918 "PGRES_TUPLES_OK but instead was "
- 919 << res.status() <<
" - msg = " << res.msg()
-
-
-
-
-
- 925 JLOG(
j_.
trace()) << __func__ <<
" Postgres result msg : " << res.msg();
- 926 if (res.isNull() || res.ntuples() == 0)
-
-
- 929 <<
" : No data returned from Postgres : account = "
-
+
+
+
+
+
+ 884 JLOG(
j_.
error()) <<
"doAccountTxStoredProcedure - "
+ 885 <<
"Error parsing ledger args";
+
+
+
+
+
+
+
+
+
+ 895 for (
size_t i = 0; i < values.
size(); ++i)
+
+
+ 898 << (values[i] ? values[i].value() :
"null");
+
+
+ 901 auto res = PgQuery(
pgPool_)(dbParams);
+
+
+
+ 905 <<
" : Postgres response is null - account = "
+
+
+
+
+ 910 else if (res.status() != PGRES_TUPLES_OK)
+
+
+ 913 <<
" : Postgres response should have been "
+ 914 "PGRES_TUPLES_OK but instead was "
+ 915 << res.status() <<
" - msg = " << res.msg()
+
+
+
+
+
+ 921 JLOG(
j_.
trace()) << __func__ <<
" Postgres result msg : " << res.msg();
+ 922 if (res.isNull() || res.ntuples() == 0)
+
+
+ 925 <<
" : No data returned from Postgres : account = "
+
+
+
+
+
-
-
-
-
- 936 char const* resultStr = res.c_str();
- 937 JLOG(
j_.
trace()) << __func__ <<
" : "
- 938 <<
"postgres result = " << resultStr
-
-
-
-
- 943 bool success = reader.
parse(resultStr, resultStr + strlen(resultStr), v);
-
-
- 946 return processAccountTxStoredProcedureResult(args, v,
app_,
j_);
-
-
-
-
- 951 return {{}, {
rpcINTERNAL,
"Failed to deserialize Postgres result"}};
-
-
-
-
-
- 957 #ifdef RIPPLED_REPORTING
- 958 auto baseCmd = boost::format(R
"(SELECT tx('%s');)");
-
-
-
-
-
-
-
-
-
-
- 969 <<
" : Postgres response is null - tx ID = " <<
strHex(
id);
-
-
-
- 973 else if (res.status() != PGRES_TUPLES_OK)
-
-
-
- 977 <<
" : Postgres response should have been "
- 978 "PGRES_TUPLES_OK but instead was "
- 979 << res.status() <<
" - msg = " << res.msg()
- 980 <<
" - tx ID = " <<
strHex(
id);
-
-
-
-
-
- 986 << __func__ <<
" Postgres result msg : " << res.msg();
- 987 if (res.isNull() || res.ntuples() == 0)
-
-
-
- 991 <<
" : No data returned from Postgres : tx ID = " <<
strHex(
id);
-
-
-
-
+ 932 char const* resultStr = res.c_str();
+ 933 JLOG(
j_.
trace()) << __func__ <<
" : "
+ 934 <<
"postgres result = " << resultStr
+
+
+
+
+ 939 bool success = reader.
parse(resultStr, resultStr + strlen(resultStr), v);
+
+
+ 942 return processAccountTxStoredProcedureResult(args, v,
app_,
j_);
+
+
+
+
+ 947 return {{}, {
rpcINTERNAL,
"Failed to deserialize Postgres result"}};
+
+
+
+
+
+ 953 #ifdef RIPPLED_REPORTING
+ 954 auto baseCmd = boost::format(R
"(SELECT tx('%s');)");
+
+
+
+
+
+
+
+
+
+
+ 965 <<
" : Postgres response is null - tx ID = " <<
strHex(
id);
+
+
+
+ 969 else if (res.status() != PGRES_TUPLES_OK)
+
+
+
+ 973 <<
" : Postgres response should have been "
+ 974 "PGRES_TUPLES_OK but instead was "
+ 975 << res.status() <<
" - msg = " << res.msg()
+ 976 <<
" - tx ID = " <<
strHex(
id);
+
+
+
+
+
+ 982 << __func__ <<
" Postgres result msg : " << res.msg();
+ 983 if (res.isNull() || res.ntuples() == 0)
+
+
+
+ 987 <<
" : No data returned from Postgres : tx ID = " <<
strHex(
id);
+
+
+
+
+
+ 993 char const* resultStr = res.c_str();
+
+ 995 <<
"postgres result = " << resultStr;
- 997 char const* resultStr = res.c_str();
-
- 999 <<
"postgres result = " << resultStr;
-
-
-
- 1003 bool success = reader.
parse(resultStr, resultStr + strlen(resultStr), v);
-
-
-
-
-
-
-
-
- 1012 uint32_t ledgerSeq = v[
"ledger_seq"].
asUInt();
-
-
-
-
-
-
- 1019 v[
"min_seq"].asUInt(), v[
"max_seq"].asUInt())};
-
-
-
-
-
-
- 1026 Throw<std::runtime_error>(
- 1027 "Transaction::Locate - Invalid Postgres response");
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1054 return std::make_unique<PostgresDatabaseImp>(app, config, jobQueue);
-
-
-
-
-
- 1060 #ifdef RIPPLED_REPORTING
- 1061 using namespace std::chrono_literals;
- 1062 auto age = PgQuery(
pgPool_)(
"SELECT age()");
- 1063 if (!age || age.isNull())
-
- 1065 reason =
"No ledgers in database";
-
-
-
-
- 1070 reason =
"No recently-published ledger";
-
-
-
-
-
-
-
+
+
+ 999 bool success = reader.
parse(resultStr, resultStr + strlen(resultStr), v);
+
+
+
+
+
+
+
+
+ 1008 uint32_t ledgerSeq = v[
"ledger_seq"].
asUInt();
+
+
+
+
+
+
+ 1015 v[
"min_seq"].asUInt(), v[
"max_seq"].asUInt())};
+
+
+
+
+
+
+ 1022 Throw<std::runtime_error>(
+ 1023 "Transaction::Locate - Invalid Postgres response");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1050 return std::make_unique<PostgresDatabaseImp>(app, config, jobQueue);
+
+
+
+
+
+ 1056 #ifdef RIPPLED_REPORTING
+ 1057 using namespace std::chrono_literals;
+ 1058 auto age = PgQuery(
pgPool_)(
"SELECT age()");
+ 1059 if (!age || age.isNull())
+
+ 1061 reason =
"No ledgers in database";
+
+
+
+
+ 1066 reason =
"No recently-published ledger";
+
+
+
+
+
+
+
static std::vector< LedgerInfo > loadLedgerInfos(std::shared_ptr< PgPool > const &pgPool, std::variant< std::monostate, uint256, uint32_t, std::pair< uint32_t, uint32_t >> const &whichLedger, Application &app)
loadLedgerInfos Loads the ledger info for the specified ledger/s from the database
@@ -1139,14 +1135,14 @@ $(function() {
-Transaction::Locator locateTransaction(uint256 const &id) override
locateTransaction Returns information used to locate a transaction.
+Transaction::Locator locateTransaction(uint256 const &id) override
locateTransaction Returns information used to locate a transaction.
Stream trace() const
Severity stream access functions.
-bool transactionDbHasSpace(Config const &config) override
transactionDbHasSpace Checks if the transaction database has available space.
+bool transactionDbHasSpace(Config const &config) override
transactionDbHasSpace Checks if the transaction database has available space.
@@ -1157,16 +1153,16 @@ $(function() {
-std::chrono::seconds getValidatedLedgerAge() override
getValidatedLedgerAge Returns the age of the last validated ledger.
+std::chrono::seconds getValidatedLedgerAge() override
getValidatedLedgerAge Returns the age of the last validated ledger.
Unserialize a JSON document into a Value.
-std::optional< LedgerInfo > getNewestLedgerInfo() override
getNewestLedgerInfo Returns the info of the newest saved ledger.
+std::optional< LedgerInfo > getNewestLedgerInfo() override
getNewestLedgerInfo Returns the info of the newest saved ledger.
PostgresDatabaseImp(Application &app, Config const &config, JobQueue &jobQueue)
-std::optional< LedgerIndex > getMinLedgerSeq() override
getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table.
+std::optional< LedgerIndex > getMinLedgerSeq() override
getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table.
@@ -1174,8 +1170,8 @@ $(function() {
-std::optional< LedgerHashPair > getHashesByIndex(LedgerIndex ledgerIndex) override
getHashesByIndex Returns the hashes of the ledger and its parent as specified by the ledgerIndex.
-std::pair< AccountTxResult, RPC::Status > getAccountTx(AccountTxArgs const &args) override
getAccountTx Get the last account transactions specified by the AccountTxArgs struct.
+std::optional< LedgerHashPair > getHashesByIndex(LedgerIndex ledgerIndex) override
getHashesByIndex Returns the hashes of the ledger and its parent as specified by the ledgerIndex.
+std::pair< AccountTxResult, RPC::Status > getAccountTx(AccountTxArgs const &args) override
getAccountTx Get the last account transactions specified by the AccountTxArgs struct.
@@ -1186,23 +1182,23 @@ $(function() {
std::optional< AccountTxMarker > marker
-bool dbHasSpace(Config const &config)
+bool dbHasSpace(Config const &config)
-uint256 getHashByIndex(LedgerIndex ledgerIndex) override
getHashByIndex Returns the hash of the ledger with the given sequence.
+uint256 getHashByIndex(LedgerIndex ledgerIndex) override
getHashByIndex Returns the hash of the ledger with the given sequence.
-std::unique_ptr< RelationalDatabase > getPostgresDatabase(Application &app, Config const &config, JobQueue &jobQueue)
+std::unique_ptr< RelationalDatabase > getPostgresDatabase(Application &app, Config const &config, JobQueue &jobQueue)
RelationalDatabase::MetaTxsList TxnsDataBinary
bool isMember(const char *key) const
Return true if the object has a member named key.
A generic endpoint for log messages.
-std::vector< std::shared_ptr< Transaction > > getTxHistory(LedgerIndex startIndex) override
getTxHistory Returns the 20 most recent transactions starting from the given number.
+std::vector< std::shared_ptr< Transaction > > getTxHistory(LedgerIndex startIndex) override
getTxHistory Returns the 20 most recent transactions starting from the given number.
-std::optional< LedgerIndex > getMaxLedgerSeq() override
getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers table.
+std::optional< LedgerIndex > getMaxLedgerSeq() override
getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers table.
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
-std::optional< LedgerInfo > getLedgerInfoByIndex(LedgerIndex ledgerSeq) override
getLedgerInfoByIndex Returns a ledger by its sequence.
-std::vector< uint256 > getTxHashes(LedgerIndex seq) override
getTxHashes Returns a vector of the hashes of transactions belonging to the ledger with the provided ...
+std::optional< LedgerInfo > getLedgerInfoByIndex(LedgerIndex ledgerSeq) override
getLedgerInfoByIndex Returns a ledger by its sequence.
+std::vector< uint256 > getTxHashes(LedgerIndex seq) override
getTxHashes Returns a vector of the hashes of transactions belonging to the ledger with the provided ...
RelationalDatabase::AccountTxResult AccountTxResult
@@ -1210,25 +1206,25 @@ $(function() {
-bool isCaughtUp(std::string &reason) override
isCaughtUp returns whether the database is caught up with the network
+bool isCaughtUp(std::string &reason) override
isCaughtUp returns whether the database is caught up with the network
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual beast::Journal journal(std::string const &name)=0
-std::string getCompleteLedgers() override
getCompleteLedgers Returns a string which contains a list of completed ledgers.
+std::string getCompleteLedgers() override
getCompleteLedgers Returns a string which contains a list of completed ledgers.
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
-std::optional< LedgerInfo > getLedgerInfoByHash(uint256 const &ledgerHash) override
getLedgerInfoByHash Returns the info of the ledger with given hash.
+std::optional< LedgerInfo > getLedgerInfoByHash(uint256 const &ledgerHash) override
getLedgerInfoByHash Returns the info of the ledger with given hash.
std::shared_ptr< PgPool > pgPool_
-void sweep() override
sweep Sweeps the database.
+void sweep() override
sweep Sweeps the database.
std::string strHex(FwdIt begin, FwdIt end)
RelationalDatabase::AccountTxs TxnsData
@@ -1239,7 +1235,7 @@ $(function() {
bool reportingReadOnly() const
std::shared_ptr< Ledger > loadLedgerHelper(LedgerInfo const &info, Application &app, bool acquire)
-bool ledgerDbHasSpace(Config const &config) override
ledgerDbHasSpace Checks if the ledger database has available space.
+bool ledgerDbHasSpace(Config const &config) override
ledgerDbHasSpace Checks if the ledger database has available space.
std::chrono::time_point< NetClock > time_point
@@ -1248,7 +1244,7 @@ $(function() {
std::string asString() const
Returns the unquoted string value.
std::vector< std::pair< std::shared_ptr< STTx const >, std::shared_ptr< STObject const > > > flatFetchTransactions(Application &app, std::vector< uint256 > &nodestoreHashes)
-bool writeLedgerAndTransactions(LedgerInfo const &info, std::vector< AccountTransactionsData > const &accountTxData) override
writeLedgerAndTransactions Writes new ledger and transaction data into the database.
+bool writeLedgerAndTransactions(LedgerInfo const &info, std::vector< AccountTransactionsData > const &accountTxData) override
writeLedgerAndTransactions Writes new ledger and transaction data into the database.