mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix reporting mode build issue
* Add isCaughtUp() as a member function of RelationalDBInterfacePostgres
This commit is contained in:
@@ -273,7 +273,7 @@ LedgerMaster::getValidatedLedgerAge()
|
||||
|
||||
#ifdef RIPPLED_REPORTING
|
||||
if (app_.config().reporting())
|
||||
return dynamic_cast<RelationalDBInterfacePostgres*>(
|
||||
return static_cast<RelationalDBInterfacePostgres*>(
|
||||
&app_.getRelationalDBInterface())
|
||||
->getValidatedLedgerAge();
|
||||
#endif
|
||||
@@ -299,20 +299,9 @@ LedgerMaster::isCaughtUp(std::string& reason)
|
||||
|
||||
#ifdef RIPPLED_REPORTING
|
||||
if (app_.config().reporting())
|
||||
{
|
||||
auto age = PgQuery(app_.getPgPool())("SELECT age()");
|
||||
if (!age || age.isNull())
|
||||
{
|
||||
reason = "No ledgers in database";
|
||||
return false;
|
||||
}
|
||||
if (std::chrono::seconds{age.asInt()} > 3min)
|
||||
{
|
||||
reason = "No recently-published ledger";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return static_cast<RelationalDBInterfacePostgres*>(
|
||||
&app_.getRelationalDBInterface())
|
||||
->isCaughtUp(reason);
|
||||
#endif
|
||||
|
||||
if (getPublishedLedgerAge() > 3min)
|
||||
@@ -1665,7 +1654,7 @@ LedgerMaster::getCompleteLedgers()
|
||||
{
|
||||
#ifdef RIPPLED_REPORTING
|
||||
if (app_.config().reporting())
|
||||
return dynamic_cast<RelationalDBInterfacePostgres*>(
|
||||
return static_cast<RelationalDBInterfacePostgres*>(
|
||||
&app_.getRelationalDBInterface())
|
||||
->getCompleteLedgers();
|
||||
#endif
|
||||
|
||||
@@ -128,6 +128,9 @@ public:
|
||||
bool
|
||||
transactionDbHasSpace(Config const& config) override;
|
||||
|
||||
bool
|
||||
isCaughtUp(std::string& reason) override;
|
||||
|
||||
private:
|
||||
Application& app_;
|
||||
beast::Journal j_;
|
||||
@@ -272,5 +275,24 @@ getRelationalDBInterfacePostgres(
|
||||
return std::make_unique<RelationalDBInterfacePostgresImp>(
|
||||
app, config, jobQueue);
|
||||
}
|
||||
bool
|
||||
RelationalDBInterfacePostgresImp::isCaughtUp(std::string& reason)
|
||||
{
|
||||
#ifdef RIPPLED_REPORTING
|
||||
using namespace std::chrono_literals;
|
||||
auto age = PgQuery(pgPool_)("SELECT age()");
|
||||
if (!age || age.isNull())
|
||||
{
|
||||
reason = "No ledgers in database";
|
||||
return false;
|
||||
}
|
||||
if (std::chrono::seconds{age.asInt()} > 3min)
|
||||
{
|
||||
reason = "No recently-published ledger";
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
|
||||
@@ -104,6 +104,18 @@ public:
|
||||
*/
|
||||
virtual Transaction::Locator
|
||||
locateTransaction(uint256 const& id) = 0;
|
||||
|
||||
/**
|
||||
* @brief isCaughtUp returns whether the database is caught up with the
|
||||
* network
|
||||
* @param[out] reason if the database is not caught up, reason contains a
|
||||
* helpful message describing why
|
||||
* @return false if the most recently written
|
||||
* ledger has a close time over 3 minutes ago, or if there are
|
||||
* no ledgers in the database. true otherwise
|
||||
*/
|
||||
virtual bool
|
||||
isCaughtUp(std::string& reason) = 0;
|
||||
};
|
||||
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user