Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REST] Add memory pool API #6013

Merged
merged 1 commit into from
Aug 15, 2015
Merged

[REST] Add memory pool API #6013

merged 1 commit into from
Aug 15, 2015

Conversation

paveljanik
Copy link
Contributor

As requested in #5844, memory pool API added.

Get TX mempool info:

$ curl localhost:8332/rest/mempool/info.json 2>/dev/null | json_pp
{
   "bytes" : 877,
   "size" : 2
}
$

Get TX mempool contents:

$ curl localhost:8332/rest/mempool/contents.json 2>/dev/null | json_pp
{
   "d84fb825b54442d737f9026ac52c4208f48eae8e1aaf9c942acede7ee8457f35" : {
      "currentpriority" : 8060141.48717949,
      "time" : 1429038596,
      "fee" : 0.0001,
      "height" : 352141,
      "depends" : [],
      "startingpriority" : 8060141.48717949,
      "size" : 225
   },
...
$ 

@laanwj
Copy link
Member

laanwj commented Apr 15, 2015

Concept ACK

@laanwj laanwj added the REST label Apr 15, 2015
@jgarzik
Copy link
Contributor

jgarzik commented Apr 15, 2015

ACK

@jonasschnelli
Copy link
Contributor

Concept ACK.
Misses RPC test.

@paveljanik
Copy link
Contributor Author

Yup, I plan to add them in the evening or tomorrow.

Array rpcParams;
rpcParams.push_back(true);

Value mempoolObject = getrawmempool(rpcParams, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should just loop through RPC commands. I know that i did the same when i added the /chaininfos REST command. This will tie the REST interface to the current RPC implementation. But duplicating code is also something we should avoid.
I don't have a solution here i just wanted to bring up this concern.

@paveljanik
Copy link
Contributor Author

nit addressed, squashed, ready.

@jonasschnelli
Copy link
Contributor

Tested ACK.

@paveljanik
Copy link
Contributor Author

Other reviews, please?

@jgarzik
Copy link
Contributor

jgarzik commented Jun 11, 2015

tested ACK

@jonasschnelli
Copy link
Contributor

Needs rebase.

@paveljanik
Copy link
Contributor Author

Rebased (changed the header style in README to match the other entries).

@paveljanik
Copy link
Contributor Author

Needs to be adapted to UniValue. Tomorrow.

@paveljanik paveljanik force-pushed the rest_mempool branch 2 times, most recently from 0188efb to da94f0d Compare June 16, 2015 05:14
@paveljanik
Copy link
Contributor Author

Travis CI build fails only in one environment because of the comparison tool.
Ready for merge.

@jonasschnelli
Copy link
Contributor

I like this PR.

But, am i alone with the feeling that calling a RPC method (getrawmempool, getmempoolinfo) will end up in REST/RPC dependency and smells after a unideal design? Duplicating code would also be kinda stupid. Maybe factoring out some code to a independent helper class/file?

But however reACK.

@paveljanik
Copy link
Contributor Author

@jonasschnelli Something like CTxMemPool::toJSON factored out from get*mempool*? Or do you prefer interface similar to TxToJSON (defined in rpc, used in rest)?

I do not have a problem to refactor once agreed, but in the next PR please.

@sipa
Copy link
Member

sipa commented Jun 16, 2015

No JSON conversion code inside core classes, please. That's something that belongs in the RPC glue layer.

@jonasschnelli
Copy link
Contributor

For sure we don't want json code within core classes. But i think calling a RPC function within REST should be avoided. Maybe something like blockToJSON or similar. Just factor out the json encoding and for now – place it within the rpcblockchain.cpp.

@paveljanik
Copy link
Contributor Author

@jonasschnelli Please review. Thanks.

@jonasschnelli
Copy link
Contributor

design wise this looks much better.
utACK. Will give it a real testshot soon.

@jonasschnelli
Copy link
Contributor

Tested ACK.

Two nits:
a) missing support for HEX/BIN (would make it consistence).
aa) could be serialized vector of transactions for mempool/content and two serialized int64_t for mempool/info
b) your diff looks somehow strange (look at UniValue getrawmempool(const UniValue& params, bool fHelp) remove L150-185, re-add at L169-232). Maybe shuffle some lines to avoid this?

@paveljanik
Copy link
Contributor Author

@jonasschnelli Thanks for review.

  • hex/bin: Does this make sense at all here? I do not think so. I modelled info it similar to getchaininfo.
  • does git diff --diff-algorithm=minimal help you?

@jonasschnelli
Copy link
Contributor

hex/bin: Does this make sense at all here? I do not think so. I modelled info it similar to getchaininfo.

If someone actively polls the mempool over REST, he could probably save CPU time and bandwidth if there would be a BIN/HEX support. But as said: low prio.

does git diff --diff-algorithm=minimal help you?

Thanks. Yes: https://github.com/bitcoin/bitcoin/pull/6013/files?1 (the 1 at the end helps)

@paveljanik
Copy link
Contributor Author

Hmm, 1 at the end seems to not have any effect here (compared with two curl calls and diff on the output).

@paveljanik
Copy link
Contributor Author

Rebased.
Added "usage" to the documentation.

@jgarzik
Copy link
Contributor

jgarzik commented Jul 23, 2015

re-ACK

@jonasschnelli
Copy link
Contributor

Needs rebase.
Anything holding this back?

@paveljanik
Copy link
Contributor Author

Rebased (to accomodate #6504 changes).
Ready for merge IMO.

@btcdrak
Copy link
Contributor

btcdrak commented Aug 7, 2015

ACK

####Memory pool
`GET /rest/mempool/info.json`

Returns various informations about the TX mempool.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: informations->information

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the SQUASHME commit.

@TheBlueMatt
Copy link
Contributor

utACK

@paveljanik
Copy link
Contributor Author

@laanwj Can you please have a look. Thank you.

@jgarzik
Copy link
Contributor

jgarzik commented Aug 13, 2015

I can merge, after this latest commit is squashed.

@paveljanik
Copy link
Contributor Author

Squashed.

const std::map<std::string, std::string>& mapHeaders,
bool fRun)
{
vector<string> params;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could (in the future) start adding std:: in front of such code, as that means we can more easily get rid of using namespace std; :).

@jonasschnelli
Copy link
Contributor

Re ACK

@jonasschnelli
Copy link
Contributor

@Diapolo: i think it's unfair to start nitpicking at this stage of the PR.

Let's get this PR merged.

Anyone can open a cleanup PR over @trivial.

@Diapolo
Copy link

Diapolo commented Aug 14, 2015

ACK and merge is fine with me, I just comment when I've got time or start reading a pull, nothing more ;).

@dcousens
Copy link
Contributor

utACK

@jgarzik jgarzik merged commit 70180b2 into bitcoin:master Aug 15, 2015
jgarzik pushed a commit that referenced this pull request Aug 15, 2015
@paveljanik paveljanik mentioned this pull request Aug 17, 2015
zkbot added a commit to zcash/zcash that referenced this pull request Mar 23, 2017
Bitcoin 0.12 mempool memory usage PRs

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6410
- bitcoin/bitcoin#6453
- bitcoin/bitcoin#6013 (excludes changes to docs we deleted)

Part of #2074.
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants