Skip to content

Commit

Permalink
Log why tx isn't validated.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrippled committed Feb 27, 2024
1 parent e718378 commit 9a3f348
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/ripple/rpc/handlers/Tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

namespace ripple {

/*
static bool
isValidated(LedgerMaster& ledgerMaster, std::uint32_t seq, uint256 const& hash)
{
Expand All @@ -50,6 +51,7 @@ isValidated(LedgerMaster& ledgerMaster, std::uint32_t seq, uint256 const& hash)
return ledgerMaster.getHashBySeq(seq) == hash;
}
*/

struct TxResult
{
Expand Down Expand Up @@ -262,6 +264,10 @@ doTxHelp(RPC::Context& context, TxArgs args)
result.txn = txn;
if (txn->getLedger() == 0)
{
if (result.validated == false)
{
JLOG(context.j.debug()) << "tx validated false " << *args.hash;
}
return {result, rpcSUCCESS};
}

Expand All @@ -281,8 +287,33 @@ doTxHelp(RPC::Context& context, TxArgs args)
{
result.meta = meta;
}
result.validated = isValidated(
context.ledgerMaster, ledger->info().seq, ledger->info().hash);
{
// result.validated = isValidated(
// context.ledgerMaster, ledger->info().seq, ledger->info().hash);
if (!context.ledgerMaster.haveLedger(ledger->info().seq))
{
JLOG(context.j.debug()) << "tx validated false " << *args.hash
<< " don't have seq " << ledger->info().seq;
result.validated = false;
}

if (ledger->info().seq > context.ledgerMaster.getValidatedLedger()->info().seq)
{
JLOG(context.j.debug()) << "tx validated false " << *args.hash
<< " seq > validated seq: " << ledger->info().seq
<< " > " << context.ledgerMaster.getValidatedLedger()->info().seq;
result.validated = false;
}

result.validated = context.ledgerMaster.getHashBySeq(ledger->info().seq) == ledger->info().hash;
if (result.validated == false)
{
JLOG(context.j.debug()) << "tx validated false " << *args.hash
<< " wrong hash for seq " << ledger->info().seq << ": "
<< context.ledgerMaster.getHashBySeq(ledger->info().seq)
<< " != " << ledger->info().hash;
}
}
if (result.validated)
result.closeTime =
context.ledgerMaster.getCloseTimeBySeq(txn->getLedger());
Expand All @@ -296,6 +327,11 @@ doTxHelp(RPC::Context& context, TxArgs args)
result.ctid =
RPC::encodeCTID(lgrSeq, (uint16_t)txnIdx, (uint16_t)netID);
}
else
{
JLOG(context.j.debug()) << "tx validated false " << *args.hash
<< " ledger or meta not there " << ledger << ',' << meta;
}

return {result, rpcSUCCESS};
}
Expand Down

0 comments on commit 9a3f348

Please sign in to comment.