{"action":"created","issue":{"url":"https://api.github.com/repos/btcsuite/btcd/issues/497","labels_url":"https://api.github.com/repos/btcsuite/btcd/issues/497/labels{/name}","comments_url":"https://api.github.com/repos/btcsuite/btcd/issues/497/comments","events_url":"https://api.github.com/repos/btcsuite/btcd/issues/497/events","html_url":"https://github.com/btcsuite/btcd/pull/497","id":104125134,"number":497,"title":"Add reverse order option to searchrawtransactions rpc","user":{"login":"Dirbaio","id":1247578,"avatar_url":"https://avatars.githubusercontent.com/u/1247578?v=3","gravatar_id":"","url":"https://api.github.com/users/Dirbaio","html_url":"https://github.com/Dirbaio","followers_url":"https://api.github.com/users/Dirbaio/followers","following_url":"https://api.github.com/users/Dirbaio/following{/other_user}","gists_url":"https://api.github.com/users/Dirbaio/gists{/gist_id}","starred_url":"https://api.github.com/users/Dirbaio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dirbaio/subscriptions","organizations_url":"https://api.github.com/users/Dirbaio/orgs","repos_url":"https://api.github.com/users/Dirbaio/repos","events_url":"https://api.github.com/users/Dirbaio/events{/privacy}","received_events_url":"https://api.github.com/users/Dirbaio/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-31T20:09:38Z","updated_at":"2015-09-02T03:16:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/btcsuite/btcd/pulls/497","html_url":"https://github.com/btcsuite/btcd/pull/497","diff_url":"https://github.com/btcsuite/btcd/pull/497.diff","patch_url":"https://github.com/btcsuite/btcd/pull/497.patch"},"body":"***This PR requires #495***\r\n\r\nThis PR adds a new parameter to searchrawtransactions that lists transactions in reverse order. \r\n\r\nThe reason I believe this is useful is that many apps (wallets and block explorers, for example) list newer transactions on the top, and display transactions in pages. Without the `reverse` flag, clients need to fetch all the transactions to show just the most recent ones, because the total tx count is not known. If it was known, clients could request the last transactions using high skip values, which is still not optimal since it involves skipping all the addrindex rows in the database. \r\n\r\nThis solution iterates the addrindex database from the end, so requesting latest transactions just iterates over the last keys in the addrindex. \r\n\r\nMempool txs are appended at the beginning or end of the result depending on the value of the `reverse flag`. Ordering of the mempool txs themselves is not actually reversed: as discussed in #495 the mempool order is random right now. This can be addressed in the future when an actual ordering is established for mempool txs."},"comment":{"url":"https://api.github.com/repos/btcsuite/btcd/issues/comments/136922688","html_url":"https://github.com/btcsuite/btcd/pull/497#issuecomment-136922688","issue_url":"https://api.github.com/repos/btcsuite/btcd/issues/497","id":136922688,"user":{"login":"davecgh","id":2115102,"avatar_url":"https://avatars.githubusercontent.com/u/2115102?v=3","gravatar_id":"","url":"https://api.github.com/users/davecgh","html_url":"https://github.com/davecgh","followers_url":"https://api.github.com/users/davecgh/followers","following_url":"https://api.github.com/users/davecgh/following{/other_user}","gists_url":"https://api.github.com/users/davecgh/gists{/gist_id}","starred_url":"https://api.github.com/users/davecgh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecgh/subscriptions","organizations_url":"https://api.github.com/users/davecgh/orgs","repos_url":"https://api.github.com/users/davecgh/repos","events_url":"https://api.github.com/users/davecgh/events{/privacy}","received_events_url":"https://api.github.com/users/davecgh/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T03:16:00Z","updated_at":"2015-09-02T03:16:00Z","body":"I haven't reviewed this yet, but I did want to point out that the [btcrpcclient](https://github.com/btcsuite/btcrpcclient) will also need a PR ready to go in concurrently with this.  See #487 and btcsuite/btcrpcclient#61 as an example."}}