XRPLF / rippled

Decentralized cryptocurrency blockchain daemon implementing the XRP Ledger protocol in C++
https://xrpl.org
ISC License
4.52k stars 1.46k forks source link

subLedger response: include txn_count #3349

Closed intelliot closed 1 year ago

intelliot commented 4 years ago

Summary

When a client subscribes to the ledger stream, the response includes all of the same fields as a ledgerClosed message but with two exceptions:

This feature request is for the txn_count field to be added to the subLedger response.

Motivation

It seems OK to omit the type field because it differentiates the immediately response to the subscribe request from the subsequent ledger stream messages. However, it is strange that the txn_count field is omitted.

Solution

The code for the subLedger response: https://github.com/ripple/rippled/blob/3d952f4b2e295059d6ee0982f20b52b1c3e4064e/src/ripple/app/misc/NetworkOPs.cpp#L3056-L3080

The code for the subsequent ledger stream messages: https://github.com/ripple/rippled/blob/3d952f4b2e295059d6ee0982f20b52b1c3e4064e/src/ripple/app/misc/NetworkOPs.cpp#L2676-L2711

By stepping through the code, you can see that the fields are identical aside from the two exceptions noted above.

Paths Not Taken

We could leave status quo, and just clarify the difference in the documentation. I'll open a PR for the docs to do exactly this. But assuming that adding txn_count is not expensive, it may be worth adding. It would simplify the docs by allowing us to say that the fields in the subscribe response are identical to the fields in the ledger stream messages.

intelliot commented 1 year ago

Docs were updated here https://github.com/XRPLF/xrpl-dev-portal/pull/824

In 3 years, no one has expressed a desire for txn_count in the subLedger response, so this is being closed. Feel free to re-open or create a new issue if this is something you're interested in.