I'm trying to list out the results of getrawmempool by newest transactions first.
Here's what I've got:
getrawmempool returns the memory pool in order of transaction hash, so I'm using PHP to sort it:
<?php // Get an array of the memory pool transactions $getrawmempool = $bitcoin->getrawmempool(true); // true = verbose // Create a new array of "txid" => "time" (just so I can sort it) foreach (array_keys($getrawmempool) as $txid) { $mempool[$tx] = $getrawmempool[$txid]['time']; } // Sort the new array arsort($mempool); // Print results print_r($mempool); ?> Now, this isn't terribly slow, but sorting 10,000+ array values isn't terribly snappy.
Questions:
- Is there a way of getting the mempool in order of newest first from bitcoin-cli?
- If not, is there a faster/better way of sorting the returned results?
I'd like to play around with all the mempool transactions using PHP. So if I can get the mempool transactions in order along with all the verbose information about each one, that would be handy.