XRPLF / rippled

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

Allow account_tx return specific TransactionType result #3075

Closed yxxyun closed 1 year ago

yxxyun commented 5 years ago

similar to Data api

MarkusTeufelberger commented 5 years ago

Could you give a bit more context? Which information from which Data API call should be available in which rippled API call?

yxxyun commented 5 years ago

https://xrpl.org/data-api.html#get-account-transaction-history

Restrict results to a specified transaction type.

mDuo13 commented 5 years ago

I could see this being pretty handy.

A good way for this to work from an API perspective would be if there was an optional field type in the account_tx request, whose value could be any valid TransactionType string; if provided, the results would be filtered to only those transactions that matched the given type. Which is basically how the Data API does it already.

The problem is, the account_tx method is already one of the most computationally expensive commands and this could make it do quite a bit more work. That's one thing for admin commands, where it's your own server anyway, but the additional strain on public servers may be too much for it to be worth it. In particular, the challenge comes with certain accounts that have very long transaction histories. For example, if an account has sent over 1 million orders (not unheard of) then filtering for the AccountSet transactions that were sent during account setup may involve digging into very old ledger data (if your server even has it available) on a transaction-by-transaction basis.

This kind of thing is much easier to do if you can use an SQL-based database, especially if the transaction type is an indexed field. Basically, this type of query is what the Data API is good at and rippled's node store is bad at. There's also been some work done by @mtrippled to build a server that sits in front of rippled and serves account_tx queries from a full SQL database, so that might be a good place to add a feature like this.

intelliot commented 1 year ago

As mDuo13 explained, this is unlikely to make sense for rippled, but it could be good for Clio. Transferred here: https://github.com/XRPLF/clio/issues/685