Changeset View
Changeset View
Standalone View
Standalone View
src/bench/wallet_balance.cpp
// Copyright (c) 2012-2019 The Bitcoin Core developers | // Copyright (c) 2012-2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <bench/bench.h> | #include <bench/bench.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <interfaces/chain.h> | #include <interfaces/chain.h> | ||||
#include <node/context.h> | #include <node/context.h> | ||||
#include <optional.h> | #include <optional.h> | ||||
#include <test/util/mining.h> | #include <test/util/mining.h> | ||||
#include <test/util/setup_common.h> | |||||
#include <test/util/wallet.h> | #include <test/util/wallet.h> | ||||
#include <validationinterface.h> | #include <validationinterface.h> | ||||
#include <wallet/wallet.h> | #include <wallet/wallet.h> | ||||
static void WalletBalance(benchmark::State &state, const bool set_dirty, | static void WalletBalance(benchmark::State &state, const bool set_dirty, | ||||
const bool add_watchonly, const bool add_mine) { | const bool add_watchonly, const bool add_mine) { | ||||
const auto &ADDRESS_WATCHONLY = ADDRESS_BCHREG_UNSPENDABLE; | const auto &ADDRESS_WATCHONLY = ADDRESS_BCHREG_UNSPENDABLE; | ||||
Show All 17 Lines | static void WalletBalance(benchmark::State &state, const bool set_dirty, | ||||
const Optional<std::string> address_mine{ | const Optional<std::string> address_mine{ | ||||
add_mine ? Optional<std::string>{getnewaddress(config, wallet)} | add_mine ? Optional<std::string>{getnewaddress(config, wallet)} | ||||
: nullopt}; | : nullopt}; | ||||
if (add_watchonly) { | if (add_watchonly) { | ||||
importaddress(wallet, ADDRESS_WATCHONLY); | importaddress(wallet, ADDRESS_WATCHONLY); | ||||
} | } | ||||
for (int i = 0; i < 100; ++i) { | for (int i = 0; i < 100; ++i) { | ||||
generatetoaddress(config, address_mine.get_value_or(ADDRESS_WATCHONLY)); | generatetoaddress(config, g_testing_setup->m_node, | ||||
generatetoaddress(config, ADDRESS_WATCHONLY); | address_mine.get_value_or(ADDRESS_WATCHONLY)); | ||||
generatetoaddress(config, g_testing_setup->m_node, ADDRESS_WATCHONLY); | |||||
} | } | ||||
SyncWithValidationInterfaceQueue(); | SyncWithValidationInterfaceQueue(); | ||||
// Cache | // Cache | ||||
auto bal = wallet.GetBalance(); | auto bal = wallet.GetBalance(); | ||||
while (state.KeepRunning()) { | while (state.KeepRunning()) { | ||||
if (set_dirty) { | if (set_dirty) { | ||||
Show All 33 Lines |