Skip to content

Commit a895ac7

Browse files
cjcobb23dangell7
authored andcommitted
Catch transaction deserialization error in doLedgerGrpc (XRPLF#4323)
* Allow clio to extract ledgers with transactions that can no longer be deserialized. The problem transactions will be skipped.
1 parent 43a58aa commit a895ac7

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

src/ripple/rpc/handlers/LedgerHandler.cpp

+27-16
Original file line numberDiff line numberDiff line change
@@ -133,27 +133,38 @@ doLedgerGrpc(RPC::GRPCContext<org::xrpl::rpc::v1::GetLedgerRequest>& context)
133133

134134
if (request.transactions())
135135
{
136-
for (auto& i : ledger->txs)
136+
try
137137
{
138-
assert(i.first);
139-
if (request.expand())
138+
for (auto& i : ledger->txs)
140139
{
141-
auto txn =
142-
response.mutable_transactions_list()->add_transactions();
143-
Serializer sTxn = i.first->getSerializer();
144-
txn->set_transaction_blob(sTxn.data(), sTxn.getLength());
145-
if (i.second)
140+
assert(i.first);
141+
if (request.expand())
146142
{
147-
Serializer sMeta = i.second->getSerializer();
148-
txn->set_metadata_blob(sMeta.data(), sMeta.getLength());
143+
auto txn = response.mutable_transactions_list()
144+
->add_transactions();
145+
Serializer sTxn = i.first->getSerializer();
146+
txn->set_transaction_blob(sTxn.data(), sTxn.getLength());
147+
if (i.second)
148+
{
149+
Serializer sMeta = i.second->getSerializer();
150+
txn->set_metadata_blob(sMeta.data(), sMeta.getLength());
151+
}
152+
}
153+
else
154+
{
155+
auto const& hash = i.first->getTransactionID();
156+
response.mutable_hashes_list()->add_hashes(
157+
hash.data(), hash.size());
149158
}
150159
}
151-
else
152-
{
153-
auto const& hash = i.first->getTransactionID();
154-
response.mutable_hashes_list()->add_hashes(
155-
hash.data(), hash.size());
156-
}
160+
}
161+
catch (std::exception const& e)
162+
{
163+
JLOG(context.j.error())
164+
<< __func__ << " - Error deserializing transaction in ledger "
165+
<< ledger->info().seq
166+
<< " . skipping transaction and following transactions. You "
167+
"should look into this further";
157168
}
158169
}
159170

0 commit comments

Comments
 (0)