mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 14:05:51 +00:00
Add NetworkOPs::isValidate functions to check if a ledger is fully validated.
This commit is contained in:
@@ -93,6 +93,14 @@ public:
|
||||
|
||||
Ledger::pointer closeLedger(bool recoverHeldTransactions);
|
||||
|
||||
uint256 getHashBySeq(uint32 index)
|
||||
{
|
||||
uint256 hash = mLedgerHistory.getLedgerHash(index);
|
||||
if (hash.isNonZero())
|
||||
return hash;
|
||||
return Ledger::getHashByIndex(index);
|
||||
}
|
||||
|
||||
Ledger::pointer getLedgerBySeq(uint32 index)
|
||||
{
|
||||
if (mCurrentLedger && (mCurrentLedger->getLedgerSeq() == index))
|
||||
|
||||
@@ -119,6 +119,19 @@ bool NetworkOPs::haveLedger(uint32 seq)
|
||||
return mLedgerMaster->haveLedger(seq);
|
||||
}
|
||||
|
||||
bool NetworkOPs::isValidated(uint32 seq, const uint256& hash)
|
||||
{
|
||||
if (!isValidated(seq))
|
||||
return false;
|
||||
|
||||
return mLedgerMaster->getHashBySeq(seq) == hash;
|
||||
}
|
||||
|
||||
bool NetworkOPs::isValidated(uint32 seq)
|
||||
{ // use when ledger was retrieved by seq
|
||||
return haveLedger(seq) && (seq <= mLedgerMaster->getValidatedLedger()->getLedgerSeq());
|
||||
}
|
||||
|
||||
bool NetworkOPs::addWantedHash(const uint256& h)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(mWantedHashLock);
|
||||
|
||||
@@ -156,6 +156,9 @@ public:
|
||||
// Do we have this inclusive range of ledgers in our database
|
||||
bool haveLedgerRange(uint32 from, uint32 to);
|
||||
bool haveLedger(uint32 seq);
|
||||
bool isValidated(uint32 seq);
|
||||
bool isValidated(uint32 seq, const uint256& hash);
|
||||
bool isValidated(Ledger::ref l) { return isValidated(l->getLedgerSeq(), l->getHash()); }
|
||||
|
||||
SerializedValidation::ref getLastValidation() { return mLastValidation; }
|
||||
void setLastValidation(SerializedValidation::ref v) { mLastValidation = v; }
|
||||
|
||||
@@ -1447,10 +1447,10 @@ Json::Value RPCHandler::doTx(Json::Value jvRequest)
|
||||
{
|
||||
TransactionMetaSet::pointer set;
|
||||
if (lgr->getTransactionMeta(txid, set))
|
||||
{
|
||||
ret["meta"] = set->getJson(0);
|
||||
ret["validated"] =
|
||||
theApp->getOPs().haveLedger(lgr->getLedgerSeq()) &&
|
||||
(lgr->getLedgerSeq() <= theApp->getLedgerMaster().getValidatedLedger()->getLedgerSeq());
|
||||
ret["validated"] = theApp->getOPs().isValidated(lgr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user