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
|
#ifdef RIPPLED_REPORTING
|
||||||
if (app_.config().reporting())
|
if (app_.config().reporting())
|
||||||
return dynamic_cast<RelationalDBInterfacePostgres*>(
|
return static_cast<RelationalDBInterfacePostgres*>(
|
||||||
&app_.getRelationalDBInterface())
|
&app_.getRelationalDBInterface())
|
||||||
->getValidatedLedgerAge();
|
->getValidatedLedgerAge();
|
||||||
#endif
|
#endif
|
||||||
@@ -299,20 +299,9 @@ LedgerMaster::isCaughtUp(std::string& reason)
|
|||||||
|
|
||||||
#ifdef RIPPLED_REPORTING
|
#ifdef RIPPLED_REPORTING
|
||||||
if (app_.config().reporting())
|
if (app_.config().reporting())
|
||||||
{
|
return static_cast<RelationalDBInterfacePostgres*>(
|
||||||
auto age = PgQuery(app_.getPgPool())("SELECT age()");
|
&app_.getRelationalDBInterface())
|
||||||
if (!age || age.isNull())
|
->isCaughtUp(reason);
|
||||||
{
|
|
||||||
reason = "No ledgers in database";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (std::chrono::seconds{age.asInt()} > 3min)
|
|
||||||
{
|
|
||||||
reason = "No recently-published ledger";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (getPublishedLedgerAge() > 3min)
|
if (getPublishedLedgerAge() > 3min)
|
||||||
@@ -1665,7 +1654,7 @@ LedgerMaster::getCompleteLedgers()
|
|||||||
{
|
{
|
||||||
#ifdef RIPPLED_REPORTING
|
#ifdef RIPPLED_REPORTING
|
||||||
if (app_.config().reporting())
|
if (app_.config().reporting())
|
||||||
return dynamic_cast<RelationalDBInterfacePostgres*>(
|
return static_cast<RelationalDBInterfacePostgres*>(
|
||||||
&app_.getRelationalDBInterface())
|
&app_.getRelationalDBInterface())
|
||||||
->getCompleteLedgers();
|
->getCompleteLedgers();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ public:
|
|||||||
bool
|
bool
|
||||||
transactionDbHasSpace(Config const& config) override;
|
transactionDbHasSpace(Config const& config) override;
|
||||||
|
|
||||||
|
bool
|
||||||
|
isCaughtUp(std::string& reason) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Application& app_;
|
Application& app_;
|
||||||
beast::Journal j_;
|
beast::Journal j_;
|
||||||
@@ -272,5 +275,24 @@ getRelationalDBInterfacePostgres(
|
|||||||
return std::make_unique<RelationalDBInterfacePostgresImp>(
|
return std::make_unique<RelationalDBInterfacePostgresImp>(
|
||||||
app, config, jobQueue);
|
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
|
} // namespace ripple
|
||||||
|
|||||||
@@ -104,6 +104,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual Transaction::Locator
|
virtual Transaction::Locator
|
||||||
locateTransaction(uint256 const& id) = 0;
|
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
|
} // namespace ripple
|
||||||
|
|||||||
Reference in New Issue
Block a user