Skip to content

Commit

Permalink
Catch transaction deserialization error in doLedgerGrpc (XRPLF#4323)
Browse files Browse the repository at this point in the history
* Allow clio to extract ledgers with transactions that can no longer be
  deserialized. The problem transactions will be skipped.
  • Loading branch information
cjcobb23 authored and RichardAH committed Dec 23, 2022
1 parent 3c1f84f commit 167a7b3
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions src/ripple/rpc/handlers/LedgerHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,38 @@ doLedgerGrpc(RPC::GRPCContext<org::xrpl::rpc::v1::GetLedgerRequest>& context)

if (request.transactions())
{
for (auto& i : ledger->txs)
try
{
assert(i.first);
if (request.expand())
for (auto& i : ledger->txs)
{
auto txn =
response.mutable_transactions_list()->add_transactions();
Serializer sTxn = i.first->getSerializer();
txn->set_transaction_blob(sTxn.data(), sTxn.getLength());
if (i.second)
assert(i.first);
if (request.expand())
{
Serializer sMeta = i.second->getSerializer();
txn->set_metadata_blob(sMeta.data(), sMeta.getLength());
auto txn = response.mutable_transactions_list()
->add_transactions();
Serializer sTxn = i.first->getSerializer();
txn->set_transaction_blob(sTxn.data(), sTxn.getLength());
if (i.second)
{
Serializer sMeta = i.second->getSerializer();
txn->set_metadata_blob(sMeta.data(), sMeta.getLength());
}
}
else
{
auto const& hash = i.first->getTransactionID();
response.mutable_hashes_list()->add_hashes(
hash.data(), hash.size());
}
}
else
{
auto const& hash = i.first->getTransactionID();
response.mutable_hashes_list()->add_hashes(
hash.data(), hash.size());
}
}
catch (std::exception const& e)
{
JLOG(context.j.error())
<< __func__ << " - Error deserializing transaction in ledger "
<< ledger->info().seq
<< " . skipping transaction and following transactions. You "
"should look into this further";
}
}

Expand Down

0 comments on commit 167a7b3

Please sign in to comment.