Changeset View
Changeset View
Standalone View
Standalone View
src/bench/rpc_mempool.cpp
- This file was added.
// Copyright (c) 2011-2019 The Bitcoin Core developers | |||||
// Distributed under the MIT software license, see the accompanying | |||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | |||||
#include <bench/bench.h> | |||||
#include <policy/policy.h> | |||||
#include <rpc/blockchain.h> | |||||
#include <txmempool.h> | |||||
#include <univalue.h> | |||||
#include <list> | |||||
#include <vector> | |||||
static void AddTx(const CTransactionRef &tx, const Amount &fee, | |||||
CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs) { | |||||
LockPoints lp; | |||||
pool.addUnchecked(tx->GetId(), | |||||
deadalnix: There is something missing here. This API is redundant, the txid is already retrievable from… | |||||
CTxMemPoolEntry(tx, fee, /* time */ 0, /*priority*/ 10.0, | |||||
/* height */ 1, tx->GetValueOut(), | |||||
/* spendsCoinbase */ false, | |||||
/* sigOpCost */ 4, lp)); | |||||
} | |||||
static void RpcMempool(benchmark::State &state) { | |||||
CTxMemPool pool; | |||||
LOCK2(cs_main, pool.cs); | |||||
for (int i = 0; i < 1000; ++i) { | |||||
CMutableTransaction tx = CMutableTransaction(); | |||||
tx.vin.resize(1); | |||||
tx.vin[0].scriptSig = CScript() << OP_1; | |||||
tx.vout.resize(1); | |||||
tx.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL; | |||||
tx.vout[0].nValue = i * CENT; | |||||
deadalnixUnsubmitted Not Done Inline ActionsThis isn't what the original PR is doing. deadalnix: This isn't what the original PR is doing. | |||||
const CTransactionRef tx_r{MakeTransactionRef(tx)}; | |||||
AddTx(tx_r, /* fee */ i * CENT, pool); | |||||
deadalnixUnsubmitted Not Done Inline Actionsdito deadalnix: dito | |||||
} | |||||
while (state.KeepRunning()) { | |||||
(void)MempoolToJSON(pool, /*verbose*/ true); | |||||
} | |||||
} | |||||
BENCHMARK(RpcMempool, 40); |
There is something missing here. This API is redundant, the txid is already retrievable from the tx in the CTxMemPoolEntry. This is not required int he original PR, so there is some dependency missing.