Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch transaction deserialization error in doLedgerGrpc #4323

Merged
merged 2 commits into from
Dec 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions src/ripple/rpc/handlers/LedgerHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,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());
}
intelliot marked this conversation as resolved.
Show resolved Hide resolved
}
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