When the mempool fills the verbose `getrawmempool` RPC call gets really slow.  It can take minutes for >100k transactions in the mempool.

The culprit is the univalue library.  Objects are implemented as a big list, but the library checks for duplicate keys.  So inserting n key-value pairs into an object takes O(n^2).

Possible fixes:

- Improve univalue library by using linked hash maps.
- change the RPC output format of getrawmempool to use a list of objects, instead of an object of objects.  But this breaks existing code.
- hack the library to be able to skip the duplicate check.

}.ToString());
    int timeout = 0;
    if (!request.params[0].isNull())
        timeout = request.params[0].get_int();
    CUpdatedBlock block;
    {
        WAIT_LOCK(cs_blockchange, lock);
        block = latestblock;
        if(timeout)
            cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&block]{return latestblock.height != block.height || latestblock.hash != block.hash || !IsRPCRunning(); });
        else
            cond_blockchange.wait(lock, [&block]{return latestblock.height != block.height || latestblock.hash != block.hash || !IsRPCRunning(); });
        block = latestblock;
    }
    UniValue ret(UniValue::VOBJ);
    ret.pushKV("hash", block.hash.GetHex());
    ret.pushKV("height", block.height);
    return ret;
}
static UniValue waitforblock(const JSONRPCRequest& request)
{
    if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
        throw std::runtime_error(
            RPCHelpMan{"waitforblock",
                "\nWaits for a specific new block and returns useful info about it.\n"
                "\nReturns the current block on timeout or exit.\n",
                {
                    {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Block hash to wait for."},
                    {"timeout", RPCArg::Type::NUM,  "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."},
                },