Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: CAFxX on April 15, 2011, 05:34:05 PM



Title: [PULL] add parameter [from] to listtransactions (JSON-RPC)
Post by: CAFxX on April 15, 2011, 05:34:05 PM
I wrote a patch (already on github) that adds the [from=0] parameter to the listtransaction rpc command. Right now this command returns the most recent transactions in the range [0, count). With my patch it returns the most recent transactions in the range [from, from+count). Since from defaults to 0 if it is not supplied, this change should be backward compatible.
The rationale for the change is that in this way a frontend/UI doesn't have to store locally the whole list of transactions, but can query directly the range that needs to be displayed.

Pull request: https://github.com/bitcoin/bitcoin/pull/160


Title: Re: [RPC] add parameter [from] to listtransactions
Post by: CAFxX on April 16, 2011, 02:53:05 PM
bump   :-\


Title: Re: [PULL] add parameter [from] to listtransactions (JSON-RPC)
Post by: xf2_org on April 16, 2011, 04:39:33 PM

1) This breaks the API, which makes it unlikely to be accepted as-is.

2) It is such a small amount of information, I do not see the difficulty in querying up to max-count.



Title: Re: [PULL] add parameter [from] to listtransactions (JSON-RPC)
Post by: CAFxX on April 16, 2011, 04:45:05 PM
1) This breaks the API, which makes it unlikely to be accepted as-is.
No it doesn't. Existing queries will keep on working (as explained in the first post).

Quote
2) It is such a small amount of information, I do not see the difficulty in querying up to max-count.
As it is today if i have thousands of transactions and want to view the oldest one I have to get (and store) all the transactions. Think what might happen if my wallet wasn't stored locally... it would mean getting MBs (potentially over slow connections) every single time!


Title: Re: [PULL] add parameter [from] to listtransactions (JSON-RPC)
Post by: xf2_org on April 16, 2011, 04:57:35 PM
1) This breaks the API, which makes it unlikely to be accepted as-is.
No it doesn't. Existing queries will keep on working (as explained in the first post).

It is not 100% backwards compatible.

Quote
2) It is such a small amount of information, I do not see the difficulty in querying up to max-count.
As it is today if i have thousands of transactions and want to view the oldest one I have to get (and store) all the transactions. Think what might happen if my wallet wasn't stored locally... it would mean getting MBs (potentially over slow connections) every single time!
[/quote]

Even with thousands of transactions, that is not many bytes, certainly not "MBs."



Title: Re: [PULL] add parameter [from] to listtransactions (JSON-RPC)
Post by: CAFxX on April 16, 2011, 05:25:03 PM
1) This breaks the API, which makes it unlikely to be accepted as-is.
No it doesn't. Existing queries will keep on working (as explained in the first post).
It is not 100% backwards compatible.
The only case this could "break compatibility" is if someone had been passing a third numeric parameter to listtransactions. Sorry to say but avoiding breaking API misuse doesn't count as backwards compatibility.

Quote
Quote
Quote
2) It is such a small amount of information, I do not see the difficulty in querying up to max-count.
As it is today if i have thousands of transactions and want to view the oldest one I have to get (and store) all the transactions. Think what might happen if my wallet wasn't stored locally... it would mean getting MBs (potentially over slow connections) every single time!
Even with thousands of transactions, that is not many bytes, certainly not "MBs."
From what I can see in the source code in rpc.cpp each transaction is likely using more than 100 bytes. Let's assume conservatively it's just 100 bytes: then it would be 1MB per 10k transactions.


Title: Re: [PULL] add parameter [from] to listtransactions (JSON-RPC)
Post by: CAFxX on April 16, 2011, 05:35:34 PM
From what I can see in the source code in rpc.cpp each transaction is likely using more than 100 bytes. Let's assume conservatively it's just 100 bytes: then it would be 1MB per 10k transactions.
Better yet: this page (http://bitcointalk.org/index.php?action=printpage;topic=2343.0) shows example listtransactions outputs. They're about 250 bytes long (this figure excludes the comments). This means 1MB roughly every 4000 transactions. This figure is way lower if comments are included in transactions. So, as I said, "MBs".


Title: Re: [PULL] add parameter [from] to listtransactions (JSON-RPC)
Post by: Gavin Andresen on April 17, 2011, 02:09:14 PM
It always bothered me that the MySQL's SELECT... LIMIT statement could skip records if the database was changing between calls, but that doesn't seem to bother anybody else.

This patch is very much like MySQL LIMIT, is needed for the same reason (paging through results efficiently in a GUI), is backwards compatible, and looks good to me.



Title: Re: [PULL] add parameter [from] to listtransactions (JSON-RPC)
Post by: xf2_org on April 18, 2011, 08:05:13 PM
I stand corrected -- no backwards compat issues.