mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge #21404: refactor: Remove MakeUnique<T>()
1a6323bdbedoc: update developer notes for removal of MakeUnique (fanquake)3ba2840e7escripted-diff: remove MakeUnique<T>() (fanquake) Pull request description: Since requiring C++17, this is just pointless abstraction. I think we should just "tear the band-aid off" and remove it. Similar to the changes happening in #21366. Also, having a comment saying this is deprecated doesn't prevent it's usage in new code. i.e : https://github.com/bitcoin/bitcoin/pull/20946#discussion_r561949731. The repository is fairly quiet at the moment, so any potential complaints about having to rebase should be minimal. Might as well get this over and done with. ACKs for top commit: jnewbery: utACK1a6323bdbepracticalswift: cr ACK1a6323bdbe: patch looks correct ajtowns: ACK1a6323bdbe-- code review only glozow: ACK1a6323bdbelooks correct Tree-SHA512: 4a14b9611b60b9b3026b54d6f5a2dce4c5d9b63a7b93d7de1307512df736503ed84bac66e7b93372c76e3117f49bf9f29cd473d3a47cb41fb2775bc10234736f
This commit is contained in:
commit
e0bc27a14c
48 changed files with 110 additions and 161 deletions
|
|
@ -595,11 +595,6 @@ Common misconceptions are clarified in those sections:
|
||||||
|
|
||||||
- *Rationale*: This avoids memory and resource leaks, and ensures exception safety.
|
- *Rationale*: This avoids memory and resource leaks, and ensures exception safety.
|
||||||
|
|
||||||
- Use `MakeUnique()` to construct objects owned by `unique_ptr`s.
|
|
||||||
|
|
||||||
- *Rationale*: `MakeUnique` is concise and ensures exception safety in complex expressions.
|
|
||||||
`MakeUnique` is a temporary project local implementation of `std::make_unique` (C++14).
|
|
||||||
|
|
||||||
C++ data structures
|
C++ data structures
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,6 @@ BITCOIN_CORE_H = \
|
||||||
util/golombrice.h \
|
util/golombrice.h \
|
||||||
util/hasher.h \
|
util/hasher.h \
|
||||||
util/macros.h \
|
util/macros.h \
|
||||||
util/memory.h \
|
|
||||||
util/message.h \
|
util/message.h \
|
||||||
util/moneystr.h \
|
util/moneystr.h \
|
||||||
util/rbf.h \
|
util/rbf.h \
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<st
|
||||||
tx.nLockTime = nextLockTime++; // so all transactions get different hashes
|
tx.nLockTime = nextLockTime++; // so all transactions get different hashes
|
||||||
tx.vout.resize(1);
|
tx.vout.resize(1);
|
||||||
tx.vout[0].nValue = nValue;
|
tx.vout[0].nValue = nValue;
|
||||||
wtxs.push_back(MakeUnique<CWalletTx>(&wallet, MakeTransactionRef(std::move(tx))));
|
wtxs.push_back(std::make_unique<CWalletTx>(&wallet, MakeTransactionRef(std::move(tx))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple benchmark for wallet coin selection. Note that it maybe be necessary
|
// Simple benchmark for wallet coin selection. Note that it maybe be necessary
|
||||||
|
|
@ -73,7 +73,7 @@ static void add_coin(const CAmount& nValue, int nInput, std::vector<OutputGroup>
|
||||||
CMutableTransaction tx;
|
CMutableTransaction tx;
|
||||||
tx.vout.resize(nInput + 1);
|
tx.vout.resize(nInput + 1);
|
||||||
tx.vout[nInput].nValue = nValue;
|
tx.vout[nInput].nValue = nValue;
|
||||||
std::unique_ptr<CWalletTx> wtx = MakeUnique<CWalletTx>(&testWallet, MakeTransactionRef(std::move(tx)));
|
std::unique_ptr<CWalletTx> wtx = std::make_unique<CWalletTx>(&testWallet, MakeTransactionRef(std::move(tx)));
|
||||||
set.emplace_back();
|
set.emplace_back();
|
||||||
set.back().Insert(COutput(wtx.get(), nInput, 0, true, true, true).GetInputCoin(), 0, true, 0, 0, false);
|
set.back().Insert(COutput(wtx.get(), nInput, 0, true, true, true).GetInputCoin(), 0, true, 0, 0, false);
|
||||||
wtxn.emplace_back(std::move(wtx));
|
wtxn.emplace_back(std::move(wtx));
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
@ -44,13 +43,13 @@ const CBaseChainParams& BaseParams()
|
||||||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
|
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
|
||||||
{
|
{
|
||||||
if (chain == CBaseChainParams::MAIN) {
|
if (chain == CBaseChainParams::MAIN) {
|
||||||
return MakeUnique<CBaseChainParams>("", 8332, 8334);
|
return std::make_unique<CBaseChainParams>("", 8332, 8334);
|
||||||
} else if (chain == CBaseChainParams::TESTNET) {
|
} else if (chain == CBaseChainParams::TESTNET) {
|
||||||
return MakeUnique<CBaseChainParams>("testnet3", 18332, 18334);
|
return std::make_unique<CBaseChainParams>("testnet3", 18332, 18334);
|
||||||
} else if (chain == CBaseChainParams::SIGNET) {
|
} else if (chain == CBaseChainParams::SIGNET) {
|
||||||
return MakeUnique<CBaseChainParams>("signet", 38332, 38334);
|
return std::make_unique<CBaseChainParams>("signet", 38332, 38334);
|
||||||
} else if (chain == CBaseChainParams::REGTEST) {
|
} else if (chain == CBaseChainParams::REGTEST) {
|
||||||
return MakeUnique<CBaseChainParams>("regtest", 18443, 18445);
|
return std::make_unique<CBaseChainParams>("regtest", 18443, 18445);
|
||||||
}
|
}
|
||||||
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ bool StartHTTPRPC(const util::Ref& context)
|
||||||
}
|
}
|
||||||
struct event_base* eventBase = EventBase();
|
struct event_base* eventBase = EventBase();
|
||||||
assert(eventBase);
|
assert(eventBase);
|
||||||
httpRPCTimerInterface = MakeUnique<HTTPRPCTimerInterface>(eventBase);
|
httpRPCTimerInterface = std::make_unique<HTTPRPCTimerInterface>(eventBase);
|
||||||
RPCSetTimerInterface(httpRPCTimerInterface.get());
|
RPCSetTimerInterface(httpRPCTimerInterface.get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,8 @@ BlockFilterIndex::BlockFilterIndex(BlockFilterType filter_type,
|
||||||
fs::create_directories(path);
|
fs::create_directories(path);
|
||||||
|
|
||||||
m_name = filter_name + " block filter index";
|
m_name = filter_name + " block filter index";
|
||||||
m_db = MakeUnique<BaseIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);
|
m_db = std::make_unique<BaseIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);
|
||||||
m_filter_fileseq = MakeUnique<FlatFileSeq>(std::move(path), "fltr", FLTR_FILE_CHUNK_SIZE);
|
m_filter_fileseq = std::make_unique<FlatFileSeq>(std::move(path), "fltr", FLTR_FILE_CHUNK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BlockFilterIndex::Init()
|
bool BlockFilterIndex::Init()
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ bool TxIndex::DB::MigrateData(CBlockTreeDB& block_tree_db, const CBlockLocator&
|
||||||
}
|
}
|
||||||
|
|
||||||
TxIndex::TxIndex(size_t n_cache_size, bool f_memory, bool f_wipe)
|
TxIndex::TxIndex(size_t n_cache_size, bool f_memory, bool f_wipe)
|
||||||
: m_db(MakeUnique<TxIndex::DB>(n_cache_size, f_memory, f_wipe))
|
: m_db(std::make_unique<TxIndex::DB>(n_cache_size, f_memory, f_wipe))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
TxIndex::~TxIndex() {}
|
TxIndex::~TxIndex() {}
|
||||||
|
|
|
||||||
|
|
@ -1350,7 +1350,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!node.scheduler);
|
assert(!node.scheduler);
|
||||||
node.scheduler = MakeUnique<CScheduler>();
|
node.scheduler = std::make_unique<CScheduler>();
|
||||||
|
|
||||||
// Start the lightweight task scheduler thread
|
// Start the lightweight task scheduler thread
|
||||||
node.scheduler->m_service_thread = std::thread([&] { TraceThread("scheduler", [&] { node.scheduler->serviceQueue(); }); });
|
node.scheduler->m_service_thread = std::thread([&] { TraceThread("scheduler", [&] { node.scheduler->serviceQueue(); }); });
|
||||||
|
|
@ -1402,9 +1402,9 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
||||||
const bool ignores_incoming_txs{args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)};
|
const bool ignores_incoming_txs{args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)};
|
||||||
|
|
||||||
assert(!node.banman);
|
assert(!node.banman);
|
||||||
node.banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
|
node.banman = std::make_unique<BanMan>(GetDataDir() / "banlist.dat", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
|
||||||
assert(!node.connman);
|
assert(!node.connman);
|
||||||
node.connman = MakeUnique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()), args.GetBoolArg("-networkactive", true));
|
node.connman = std::make_unique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()), args.GetBoolArg("-networkactive", true));
|
||||||
|
|
||||||
assert(!node.fee_estimator);
|
assert(!node.fee_estimator);
|
||||||
// Don't initialize fee estimation with old data if we don't relay transactions,
|
// Don't initialize fee estimation with old data if we don't relay transactions,
|
||||||
|
|
@ -1800,7 +1800,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
||||||
|
|
||||||
// ********************************************************* Step 8: start indexers
|
// ********************************************************* Step 8: start indexers
|
||||||
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
|
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
|
||||||
g_txindex = MakeUnique<TxIndex>(nTxIndexCache, false, fReindex);
|
g_txindex = std::make_unique<TxIndex>(nTxIndexCache, false, fReindex);
|
||||||
g_txindex->Start();
|
g_txindex->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include <interfaces/handler.h>
|
#include <interfaces/handler.h>
|
||||||
|
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <boost/signals2/connection.hpp>
|
#include <boost/signals2/connection.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
@ -35,12 +34,12 @@ public:
|
||||||
|
|
||||||
std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection)
|
std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection)
|
||||||
{
|
{
|
||||||
return MakeUnique<HandlerImpl>(std::move(connection));
|
return std::make_unique<HandlerImpl>(std::move(connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Handler> MakeHandler(std::function<void()> cleanup)
|
std::unique_ptr<Handler> MakeHandler(std::function<void()> cleanup)
|
||||||
{
|
{
|
||||||
return MakeUnique<CleanupHandler>(std::move(cleanup));
|
return std::make_unique<CleanupHandler>(std::move(cleanup));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace interfaces
|
} // namespace interfaces
|
||||||
|
|
|
||||||
12
src/net.cpp
12
src/net.cpp
|
|
@ -2466,11 +2466,11 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
|
||||||
|
|
||||||
if (semOutbound == nullptr) {
|
if (semOutbound == nullptr) {
|
||||||
// initialize semaphore
|
// initialize semaphore
|
||||||
semOutbound = MakeUnique<CSemaphore>(std::min(m_max_outbound, nMaxConnections));
|
semOutbound = std::make_unique<CSemaphore>(std::min(m_max_outbound, nMaxConnections));
|
||||||
}
|
}
|
||||||
if (semAddnode == nullptr) {
|
if (semAddnode == nullptr) {
|
||||||
// initialize semaphore
|
// initialize semaphore
|
||||||
semAddnode = MakeUnique<CSemaphore>(nMaxAddnode);
|
semAddnode = std::make_unique<CSemaphore>(nMaxAddnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -2906,11 +2906,11 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const
|
||||||
hSocket = hSocketIn;
|
hSocket = hSocketIn;
|
||||||
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
|
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
|
||||||
if (conn_type_in != ConnectionType::BLOCK_RELAY) {
|
if (conn_type_in != ConnectionType::BLOCK_RELAY) {
|
||||||
m_tx_relay = MakeUnique<TxRelay>();
|
m_tx_relay = std::make_unique<TxRelay>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RelayAddrsWithConn()) {
|
if (RelayAddrsWithConn()) {
|
||||||
m_addr_known = MakeUnique<CRollingBloomFilter>(5000, 0.001);
|
m_addr_known = std::make_unique<CRollingBloomFilter>(5000, 0.001);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const std::string &msg : getAllNetMessageTypes())
|
for (const std::string &msg : getAllNetMessageTypes())
|
||||||
|
|
@ -2923,8 +2923,8 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const
|
||||||
LogPrint(BCLog::NET, "Added connection peer=%d\n", id);
|
LogPrint(BCLog::NET, "Added connection peer=%d\n", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_deserializer = MakeUnique<V1TransportDeserializer>(V1TransportDeserializer(Params(), GetId(), SER_NETWORK, INIT_PROTO_VERSION));
|
m_deserializer = std::make_unique<V1TransportDeserializer>(V1TransportDeserializer(Params(), GetId(), SER_NETWORK, INIT_PROTO_VERSION));
|
||||||
m_serializer = MakeUnique<V1TransportSerializer>(V1TransportSerializer());
|
m_serializer = std::make_unique<V1TransportSerializer>(V1TransportSerializer());
|
||||||
}
|
}
|
||||||
|
|
||||||
CNode::~CNode()
|
CNode::~CNode()
|
||||||
|
|
|
||||||
|
|
@ -634,7 +634,7 @@ public:
|
||||||
}
|
}
|
||||||
std::unique_ptr<Handler> handleNotifications(std::shared_ptr<Notifications> notifications) override
|
std::unique_ptr<Handler> handleNotifications(std::shared_ptr<Notifications> notifications) override
|
||||||
{
|
{
|
||||||
return MakeUnique<NotificationsHandlerImpl>(std::move(notifications));
|
return std::make_unique<NotificationsHandlerImpl>(std::move(notifications));
|
||||||
}
|
}
|
||||||
void waitForNotificationsIfTipChanged(const uint256& old_tip) override
|
void waitForNotificationsIfTipChanged(const uint256& old_tip) override
|
||||||
{
|
{
|
||||||
|
|
@ -647,7 +647,7 @@ public:
|
||||||
}
|
}
|
||||||
std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) override
|
std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) override
|
||||||
{
|
{
|
||||||
return MakeUnique<RpcHandlerImpl>(command);
|
return std::make_unique<RpcHandlerImpl>(command);
|
||||||
}
|
}
|
||||||
bool rpcEnableDeprecated(const std::string& method) override { return IsDeprecatedRPCEnabled(method); }
|
bool rpcEnableDeprecated(const std::string& method) override { return IsDeprecatedRPCEnabled(method); }
|
||||||
void rpcRunLater(const std::string& name, std::function<void()> fn, int64_t seconds) override
|
void rpcRunLater(const std::string& name, std::function<void()> fn, int64_t seconds) override
|
||||||
|
|
@ -690,6 +690,6 @@ public:
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
|
||||||
namespace interfaces {
|
namespace interfaces {
|
||||||
std::unique_ptr<Node> MakeNode(NodeContext* context) { return MakeUnique<node::NodeImpl>(context); }
|
std::unique_ptr<Node> MakeNode(NodeContext* context) { return std::make_unique<node::NodeImpl>(context); }
|
||||||
std::unique_ptr<Chain> MakeChain(NodeContext& context) { return MakeUnique<node::ChainImpl>(context); }
|
std::unique_ptr<Chain> MakeChain(NodeContext& context) { return std::make_unique<node::ChainImpl>(context); }
|
||||||
} // namespace interfaces
|
} // namespace interfaces
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare transaction for getting txFee earlier
|
// prepare transaction for getting txFee earlier
|
||||||
m_current_transaction = MakeUnique<WalletModelTransaction>(recipients);
|
m_current_transaction = std::make_unique<WalletModelTransaction>(recipients);
|
||||||
WalletModel::SendCoinsReturn prepareStatus;
|
WalletModel::SendCoinsReturn prepareStatus;
|
||||||
|
|
||||||
updateCoinControlState(*m_coin_control);
|
updateCoinControlState(*m_coin_control);
|
||||||
|
|
|
||||||
|
|
@ -853,7 +853,7 @@ std::unique_ptr<PubkeyProvider> ParsePubkeyInner(uint32_t key_exp_index, const S
|
||||||
CPubKey pubkey(data);
|
CPubKey pubkey(data);
|
||||||
if (pubkey.IsFullyValid()) {
|
if (pubkey.IsFullyValid()) {
|
||||||
if (permit_uncompressed || pubkey.IsCompressed()) {
|
if (permit_uncompressed || pubkey.IsCompressed()) {
|
||||||
return MakeUnique<ConstPubkeyProvider>(key_exp_index, pubkey);
|
return std::make_unique<ConstPubkeyProvider>(key_exp_index, pubkey);
|
||||||
} else {
|
} else {
|
||||||
error = "Uncompressed keys are not allowed";
|
error = "Uncompressed keys are not allowed";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -867,7 +867,7 @@ std::unique_ptr<PubkeyProvider> ParsePubkeyInner(uint32_t key_exp_index, const S
|
||||||
if (permit_uncompressed || key.IsCompressed()) {
|
if (permit_uncompressed || key.IsCompressed()) {
|
||||||
CPubKey pubkey = key.GetPubKey();
|
CPubKey pubkey = key.GetPubKey();
|
||||||
out.keys.emplace(pubkey.GetID(), key);
|
out.keys.emplace(pubkey.GetID(), key);
|
||||||
return MakeUnique<ConstPubkeyProvider>(key_exp_index, pubkey);
|
return std::make_unique<ConstPubkeyProvider>(key_exp_index, pubkey);
|
||||||
} else {
|
} else {
|
||||||
error = "Uncompressed keys are not allowed";
|
error = "Uncompressed keys are not allowed";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -894,7 +894,7 @@ std::unique_ptr<PubkeyProvider> ParsePubkeyInner(uint32_t key_exp_index, const S
|
||||||
extpubkey = extkey.Neuter();
|
extpubkey = extkey.Neuter();
|
||||||
out.keys.emplace(extpubkey.pubkey.GetID(), extkey.key);
|
out.keys.emplace(extpubkey.pubkey.GetID(), extkey.key);
|
||||||
}
|
}
|
||||||
return MakeUnique<BIP32PubkeyProvider>(key_exp_index, extpubkey, std::move(path), type);
|
return std::make_unique<BIP32PubkeyProvider>(key_exp_index, extpubkey, std::move(path), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse a public key including origin information (if enabled). */
|
/** Parse a public key including origin information (if enabled). */
|
||||||
|
|
@ -931,7 +931,7 @@ std::unique_ptr<PubkeyProvider> ParsePubkey(uint32_t key_exp_index, const Span<c
|
||||||
if (!ParseKeyPath(slash_split, info.path, error)) return nullptr;
|
if (!ParseKeyPath(slash_split, info.path, error)) return nullptr;
|
||||||
auto provider = ParsePubkeyInner(key_exp_index, origin_split[1], permit_uncompressed, out, error);
|
auto provider = ParsePubkeyInner(key_exp_index, origin_split[1], permit_uncompressed, out, error);
|
||||||
if (!provider) return nullptr;
|
if (!provider) return nullptr;
|
||||||
return MakeUnique<OriginPubkeyProvider>(key_exp_index, std::move(info), std::move(provider));
|
return std::make_unique<OriginPubkeyProvider>(key_exp_index, std::move(info), std::move(provider));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse a script in a particular context. */
|
/** Parse a script in a particular context. */
|
||||||
|
|
@ -944,17 +944,17 @@ std::unique_ptr<DescriptorImpl> ParseScript(uint32_t key_exp_index, Span<const c
|
||||||
if (Func("pk", expr)) {
|
if (Func("pk", expr)) {
|
||||||
auto pubkey = ParsePubkey(key_exp_index, expr, ctx != ParseScriptContext::P2WSH, out, error);
|
auto pubkey = ParsePubkey(key_exp_index, expr, ctx != ParseScriptContext::P2WSH, out, error);
|
||||||
if (!pubkey) return nullptr;
|
if (!pubkey) return nullptr;
|
||||||
return MakeUnique<PKDescriptor>(std::move(pubkey));
|
return std::make_unique<PKDescriptor>(std::move(pubkey));
|
||||||
}
|
}
|
||||||
if (Func("pkh", expr)) {
|
if (Func("pkh", expr)) {
|
||||||
auto pubkey = ParsePubkey(key_exp_index, expr, ctx != ParseScriptContext::P2WSH, out, error);
|
auto pubkey = ParsePubkey(key_exp_index, expr, ctx != ParseScriptContext::P2WSH, out, error);
|
||||||
if (!pubkey) return nullptr;
|
if (!pubkey) return nullptr;
|
||||||
return MakeUnique<PKHDescriptor>(std::move(pubkey));
|
return std::make_unique<PKHDescriptor>(std::move(pubkey));
|
||||||
}
|
}
|
||||||
if (ctx == ParseScriptContext::TOP && Func("combo", expr)) {
|
if (ctx == ParseScriptContext::TOP && Func("combo", expr)) {
|
||||||
auto pubkey = ParsePubkey(key_exp_index, expr, true, out, error);
|
auto pubkey = ParsePubkey(key_exp_index, expr, true, out, error);
|
||||||
if (!pubkey) return nullptr;
|
if (!pubkey) return nullptr;
|
||||||
return MakeUnique<ComboDescriptor>(std::move(pubkey));
|
return std::make_unique<ComboDescriptor>(std::move(pubkey));
|
||||||
} else if (ctx != ParseScriptContext::TOP && Func("combo", expr)) {
|
} else if (ctx != ParseScriptContext::TOP && Func("combo", expr)) {
|
||||||
error = "Cannot have combo in non-top level";
|
error = "Cannot have combo in non-top level";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -1002,12 +1002,12 @@ std::unique_ptr<DescriptorImpl> ParseScript(uint32_t key_exp_index, Span<const c
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return MakeUnique<MultisigDescriptor>(thres, std::move(providers), sorted_multi);
|
return std::make_unique<MultisigDescriptor>(thres, std::move(providers), sorted_multi);
|
||||||
}
|
}
|
||||||
if (ctx != ParseScriptContext::P2WSH && Func("wpkh", expr)) {
|
if (ctx != ParseScriptContext::P2WSH && Func("wpkh", expr)) {
|
||||||
auto pubkey = ParsePubkey(key_exp_index, expr, false, out, error);
|
auto pubkey = ParsePubkey(key_exp_index, expr, false, out, error);
|
||||||
if (!pubkey) return nullptr;
|
if (!pubkey) return nullptr;
|
||||||
return MakeUnique<WPKHDescriptor>(std::move(pubkey));
|
return std::make_unique<WPKHDescriptor>(std::move(pubkey));
|
||||||
} else if (ctx == ParseScriptContext::P2WSH && Func("wpkh", expr)) {
|
} else if (ctx == ParseScriptContext::P2WSH && Func("wpkh", expr)) {
|
||||||
error = "Cannot have wpkh within wsh";
|
error = "Cannot have wpkh within wsh";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -1015,7 +1015,7 @@ std::unique_ptr<DescriptorImpl> ParseScript(uint32_t key_exp_index, Span<const c
|
||||||
if (ctx == ParseScriptContext::TOP && Func("sh", expr)) {
|
if (ctx == ParseScriptContext::TOP && Func("sh", expr)) {
|
||||||
auto desc = ParseScript(key_exp_index, expr, ParseScriptContext::P2SH, out, error);
|
auto desc = ParseScript(key_exp_index, expr, ParseScriptContext::P2SH, out, error);
|
||||||
if (!desc || expr.size()) return nullptr;
|
if (!desc || expr.size()) return nullptr;
|
||||||
return MakeUnique<SHDescriptor>(std::move(desc));
|
return std::make_unique<SHDescriptor>(std::move(desc));
|
||||||
} else if (ctx != ParseScriptContext::TOP && Func("sh", expr)) {
|
} else if (ctx != ParseScriptContext::TOP && Func("sh", expr)) {
|
||||||
error = "Cannot have sh in non-top level";
|
error = "Cannot have sh in non-top level";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -1023,7 +1023,7 @@ std::unique_ptr<DescriptorImpl> ParseScript(uint32_t key_exp_index, Span<const c
|
||||||
if (ctx != ParseScriptContext::P2WSH && Func("wsh", expr)) {
|
if (ctx != ParseScriptContext::P2WSH && Func("wsh", expr)) {
|
||||||
auto desc = ParseScript(key_exp_index, expr, ParseScriptContext::P2WSH, out, error);
|
auto desc = ParseScript(key_exp_index, expr, ParseScriptContext::P2WSH, out, error);
|
||||||
if (!desc || expr.size()) return nullptr;
|
if (!desc || expr.size()) return nullptr;
|
||||||
return MakeUnique<WSHDescriptor>(std::move(desc));
|
return std::make_unique<WSHDescriptor>(std::move(desc));
|
||||||
} else if (ctx == ParseScriptContext::P2WSH && Func("wsh", expr)) {
|
} else if (ctx == ParseScriptContext::P2WSH && Func("wsh", expr)) {
|
||||||
error = "Cannot have wsh within wsh";
|
error = "Cannot have wsh within wsh";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -1034,7 +1034,7 @@ std::unique_ptr<DescriptorImpl> ParseScript(uint32_t key_exp_index, Span<const c
|
||||||
error = "Address is not valid";
|
error = "Address is not valid";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return MakeUnique<AddressDescriptor>(std::move(dest));
|
return std::make_unique<AddressDescriptor>(std::move(dest));
|
||||||
}
|
}
|
||||||
if (ctx == ParseScriptContext::TOP && Func("raw", expr)) {
|
if (ctx == ParseScriptContext::TOP && Func("raw", expr)) {
|
||||||
std::string str(expr.begin(), expr.end());
|
std::string str(expr.begin(), expr.end());
|
||||||
|
|
@ -1043,7 +1043,7 @@ std::unique_ptr<DescriptorImpl> ParseScript(uint32_t key_exp_index, Span<const c
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto bytes = ParseHex(str);
|
auto bytes = ParseHex(str);
|
||||||
return MakeUnique<RawDescriptor>(CScript(bytes.begin(), bytes.end()));
|
return std::make_unique<RawDescriptor>(CScript(bytes.begin(), bytes.end()));
|
||||||
}
|
}
|
||||||
if (ctx == ParseScriptContext::P2SH) {
|
if (ctx == ParseScriptContext::P2SH) {
|
||||||
error = "A function is needed within P2SH";
|
error = "A function is needed within P2SH";
|
||||||
|
|
@ -1058,10 +1058,10 @@ std::unique_ptr<DescriptorImpl> ParseScript(uint32_t key_exp_index, Span<const c
|
||||||
|
|
||||||
std::unique_ptr<PubkeyProvider> InferPubkey(const CPubKey& pubkey, ParseScriptContext, const SigningProvider& provider)
|
std::unique_ptr<PubkeyProvider> InferPubkey(const CPubKey& pubkey, ParseScriptContext, const SigningProvider& provider)
|
||||||
{
|
{
|
||||||
std::unique_ptr<PubkeyProvider> key_provider = MakeUnique<ConstPubkeyProvider>(0, pubkey);
|
std::unique_ptr<PubkeyProvider> key_provider = std::make_unique<ConstPubkeyProvider>(0, pubkey);
|
||||||
KeyOriginInfo info;
|
KeyOriginInfo info;
|
||||||
if (provider.GetKeyOrigin(pubkey.GetID(), info)) {
|
if (provider.GetKeyOrigin(pubkey.GetID(), info)) {
|
||||||
return MakeUnique<OriginPubkeyProvider>(0, std::move(info), std::move(key_provider));
|
return std::make_unique<OriginPubkeyProvider>(0, std::move(info), std::move(key_provider));
|
||||||
}
|
}
|
||||||
return key_provider;
|
return key_provider;
|
||||||
}
|
}
|
||||||
|
|
@ -1074,7 +1074,7 @@ std::unique_ptr<DescriptorImpl> InferScript(const CScript& script, ParseScriptCo
|
||||||
if (txntype == TxoutType::PUBKEY) {
|
if (txntype == TxoutType::PUBKEY) {
|
||||||
CPubKey pubkey(data[0].begin(), data[0].end());
|
CPubKey pubkey(data[0].begin(), data[0].end());
|
||||||
if (pubkey.IsValid()) {
|
if (pubkey.IsValid()) {
|
||||||
return MakeUnique<PKDescriptor>(InferPubkey(pubkey, ctx, provider));
|
return std::make_unique<PKDescriptor>(InferPubkey(pubkey, ctx, provider));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (txntype == TxoutType::PUBKEYHASH) {
|
if (txntype == TxoutType::PUBKEYHASH) {
|
||||||
|
|
@ -1082,7 +1082,7 @@ std::unique_ptr<DescriptorImpl> InferScript(const CScript& script, ParseScriptCo
|
||||||
CKeyID keyid(hash);
|
CKeyID keyid(hash);
|
||||||
CPubKey pubkey;
|
CPubKey pubkey;
|
||||||
if (provider.GetPubKey(keyid, pubkey)) {
|
if (provider.GetPubKey(keyid, pubkey)) {
|
||||||
return MakeUnique<PKHDescriptor>(InferPubkey(pubkey, ctx, provider));
|
return std::make_unique<PKHDescriptor>(InferPubkey(pubkey, ctx, provider));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (txntype == TxoutType::WITNESS_V0_KEYHASH && ctx != ParseScriptContext::P2WSH) {
|
if (txntype == TxoutType::WITNESS_V0_KEYHASH && ctx != ParseScriptContext::P2WSH) {
|
||||||
|
|
@ -1090,7 +1090,7 @@ std::unique_ptr<DescriptorImpl> InferScript(const CScript& script, ParseScriptCo
|
||||||
CKeyID keyid(hash);
|
CKeyID keyid(hash);
|
||||||
CPubKey pubkey;
|
CPubKey pubkey;
|
||||||
if (provider.GetPubKey(keyid, pubkey)) {
|
if (provider.GetPubKey(keyid, pubkey)) {
|
||||||
return MakeUnique<WPKHDescriptor>(InferPubkey(pubkey, ctx, provider));
|
return std::make_unique<WPKHDescriptor>(InferPubkey(pubkey, ctx, provider));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (txntype == TxoutType::MULTISIG) {
|
if (txntype == TxoutType::MULTISIG) {
|
||||||
|
|
@ -1099,7 +1099,7 @@ std::unique_ptr<DescriptorImpl> InferScript(const CScript& script, ParseScriptCo
|
||||||
CPubKey pubkey(data[i].begin(), data[i].end());
|
CPubKey pubkey(data[i].begin(), data[i].end());
|
||||||
providers.push_back(InferPubkey(pubkey, ctx, provider));
|
providers.push_back(InferPubkey(pubkey, ctx, provider));
|
||||||
}
|
}
|
||||||
return MakeUnique<MultisigDescriptor>((int)data[0][0], std::move(providers));
|
return std::make_unique<MultisigDescriptor>((int)data[0][0], std::move(providers));
|
||||||
}
|
}
|
||||||
if (txntype == TxoutType::SCRIPTHASH && ctx == ParseScriptContext::TOP) {
|
if (txntype == TxoutType::SCRIPTHASH && ctx == ParseScriptContext::TOP) {
|
||||||
uint160 hash(data[0]);
|
uint160 hash(data[0]);
|
||||||
|
|
@ -1107,7 +1107,7 @@ std::unique_ptr<DescriptorImpl> InferScript(const CScript& script, ParseScriptCo
|
||||||
CScript subscript;
|
CScript subscript;
|
||||||
if (provider.GetCScript(scriptid, subscript)) {
|
if (provider.GetCScript(scriptid, subscript)) {
|
||||||
auto sub = InferScript(subscript, ParseScriptContext::P2SH, provider);
|
auto sub = InferScript(subscript, ParseScriptContext::P2SH, provider);
|
||||||
if (sub) return MakeUnique<SHDescriptor>(std::move(sub));
|
if (sub) return std::make_unique<SHDescriptor>(std::move(sub));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (txntype == TxoutType::WITNESS_V0_SCRIPTHASH && ctx != ParseScriptContext::P2WSH) {
|
if (txntype == TxoutType::WITNESS_V0_SCRIPTHASH && ctx != ParseScriptContext::P2WSH) {
|
||||||
|
|
@ -1116,18 +1116,18 @@ std::unique_ptr<DescriptorImpl> InferScript(const CScript& script, ParseScriptCo
|
||||||
CScript subscript;
|
CScript subscript;
|
||||||
if (provider.GetCScript(scriptid, subscript)) {
|
if (provider.GetCScript(scriptid, subscript)) {
|
||||||
auto sub = InferScript(subscript, ParseScriptContext::P2WSH, provider);
|
auto sub = InferScript(subscript, ParseScriptContext::P2WSH, provider);
|
||||||
if (sub) return MakeUnique<WSHDescriptor>(std::move(sub));
|
if (sub) return std::make_unique<WSHDescriptor>(std::move(sub));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CTxDestination dest;
|
CTxDestination dest;
|
||||||
if (ExtractDestination(script, dest)) {
|
if (ExtractDestination(script, dest)) {
|
||||||
if (GetScriptForDestination(dest) == script) {
|
if (GetScriptForDestination(dest) == script) {
|
||||||
return MakeUnique<AddressDescriptor>(std::move(dest));
|
return std::make_unique<AddressDescriptor>(std::move(dest));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MakeUnique<RawDescriptor>(script);
|
return std::make_unique<RawDescriptor>(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
// 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 <util/memory.h>
|
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
|
@ -163,7 +162,7 @@ private:
|
||||||
BOOST_AUTO_TEST_CASE(lockedpool_tests_mock)
|
BOOST_AUTO_TEST_CASE(lockedpool_tests_mock)
|
||||||
{
|
{
|
||||||
// Test over three virtual arenas, of which one will succeed being locked
|
// Test over three virtual arenas, of which one will succeed being locked
|
||||||
std::unique_ptr<LockedPageAllocator> x = MakeUnique<TestLockedPageAllocator>(3, 1);
|
std::unique_ptr<LockedPageAllocator> x = std::make_unique<TestLockedPageAllocator>(3, 1);
|
||||||
LockedPool pool(std::move(x));
|
LockedPool pool(std::move(x));
|
||||||
BOOST_CHECK(pool.stats().total == 0);
|
BOOST_CHECK(pool.stats().total == 0);
|
||||||
BOOST_CHECK(pool.stats().locked == 0);
|
BOOST_CHECK(pool.stats().locked == 0);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
#include <checkqueue.h>
|
#include <checkqueue.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
|
||||||
|
|
@ -146,7 +145,7 @@ typedef CCheckQueue<FrozenCleanupCheck> FrozenCleanup_Queue;
|
||||||
*/
|
*/
|
||||||
static void Correct_Queue_range(std::vector<size_t> range)
|
static void Correct_Queue_range(std::vector<size_t> range)
|
||||||
{
|
{
|
||||||
auto small_queue = MakeUnique<Correct_Queue>(QUEUE_BATCH_SIZE);
|
auto small_queue = std::make_unique<Correct_Queue>(QUEUE_BATCH_SIZE);
|
||||||
small_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
small_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
||||||
// Make vChecks here to save on malloc (this test can be slow...)
|
// Make vChecks here to save on malloc (this test can be slow...)
|
||||||
std::vector<FakeCheckCheckCompletion> vChecks;
|
std::vector<FakeCheckCheckCompletion> vChecks;
|
||||||
|
|
@ -206,7 +205,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_Random)
|
||||||
/** Test that failing checks are caught */
|
/** Test that failing checks are caught */
|
||||||
BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure)
|
BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure)
|
||||||
{
|
{
|
||||||
auto fail_queue = MakeUnique<Failing_Queue>(QUEUE_BATCH_SIZE);
|
auto fail_queue = std::make_unique<Failing_Queue>(QUEUE_BATCH_SIZE);
|
||||||
fail_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
fail_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
||||||
|
|
||||||
for (size_t i = 0; i < 1001; ++i) {
|
for (size_t i = 0; i < 1001; ++i) {
|
||||||
|
|
@ -234,7 +233,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure)
|
||||||
// future blocks, ie, the bad state is cleared.
|
// future blocks, ie, the bad state is cleared.
|
||||||
BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure)
|
BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure)
|
||||||
{
|
{
|
||||||
auto fail_queue = MakeUnique<Failing_Queue>(QUEUE_BATCH_SIZE);
|
auto fail_queue = std::make_unique<Failing_Queue>(QUEUE_BATCH_SIZE);
|
||||||
fail_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
fail_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
||||||
|
|
||||||
for (auto times = 0; times < 10; ++times) {
|
for (auto times = 0; times < 10; ++times) {
|
||||||
|
|
@ -258,7 +257,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure)
|
||||||
// more than once as well
|
// more than once as well
|
||||||
BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck)
|
BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck)
|
||||||
{
|
{
|
||||||
auto queue = MakeUnique<Unique_Queue>(QUEUE_BATCH_SIZE);
|
auto queue = std::make_unique<Unique_Queue>(QUEUE_BATCH_SIZE);
|
||||||
queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
||||||
|
|
||||||
size_t COUNT = 100000;
|
size_t COUNT = 100000;
|
||||||
|
|
@ -293,7 +292,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck)
|
||||||
// time could leave the data hanging across a sequence of blocks.
|
// time could leave the data hanging across a sequence of blocks.
|
||||||
BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory)
|
BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory)
|
||||||
{
|
{
|
||||||
auto queue = MakeUnique<Memory_Queue>(QUEUE_BATCH_SIZE);
|
auto queue = std::make_unique<Memory_Queue>(QUEUE_BATCH_SIZE);
|
||||||
queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
||||||
for (size_t i = 0; i < 1000; ++i) {
|
for (size_t i = 0; i < 1000; ++i) {
|
||||||
size_t total = i;
|
size_t total = i;
|
||||||
|
|
@ -320,7 +319,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory)
|
||||||
// have been destructed
|
// have been destructed
|
||||||
BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup)
|
BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup)
|
||||||
{
|
{
|
||||||
auto queue = MakeUnique<FrozenCleanup_Queue>(QUEUE_BATCH_SIZE);
|
auto queue = std::make_unique<FrozenCleanup_Queue>(QUEUE_BATCH_SIZE);
|
||||||
bool fails = false;
|
bool fails = false;
|
||||||
queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
|
||||||
std::thread t0([&]() {
|
std::thread t0([&]() {
|
||||||
|
|
@ -360,7 +359,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup)
|
||||||
/** Test that CCheckQueueControl is threadsafe */
|
/** Test that CCheckQueueControl is threadsafe */
|
||||||
BOOST_AUTO_TEST_CASE(test_CheckQueueControl_Locks)
|
BOOST_AUTO_TEST_CASE(test_CheckQueueControl_Locks)
|
||||||
{
|
{
|
||||||
auto queue = MakeUnique<Standard_Queue>(QUEUE_BATCH_SIZE);
|
auto queue = std::make_unique<Standard_Queue>(QUEUE_BATCH_SIZE);
|
||||||
{
|
{
|
||||||
std::vector<std::thread> tg;
|
std::vector<std::thread> tg;
|
||||||
std::atomic<int> nThreads {0};
|
std::atomic<int> nThreads {0};
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
#include <dbwrapper.h>
|
#include <dbwrapper.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
@ -207,7 +206,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
|
||||||
create_directories(ph);
|
create_directories(ph);
|
||||||
|
|
||||||
// Set up a non-obfuscated wrapper to write some initial data.
|
// Set up a non-obfuscated wrapper to write some initial data.
|
||||||
std::unique_ptr<CDBWrapper> dbw = MakeUnique<CDBWrapper>(ph, (1 << 10), false, false, false);
|
std::unique_ptr<CDBWrapper> dbw = std::make_unique<CDBWrapper>(ph, (1 << 10), false, false, false);
|
||||||
char key = 'k';
|
char key = 'k';
|
||||||
uint256 in = InsecureRand256();
|
uint256 in = InsecureRand256();
|
||||||
uint256 res;
|
uint256 res;
|
||||||
|
|
@ -248,7 +247,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex)
|
||||||
create_directories(ph);
|
create_directories(ph);
|
||||||
|
|
||||||
// Set up a non-obfuscated wrapper to write some initial data.
|
// Set up a non-obfuscated wrapper to write some initial data.
|
||||||
std::unique_ptr<CDBWrapper> dbw = MakeUnique<CDBWrapper>(ph, (1 << 10), false, false, false);
|
std::unique_ptr<CDBWrapper> dbw = std::make_unique<CDBWrapper>(ph, (1 << 10), false, false, false);
|
||||||
char key = 'k';
|
char key = 'k';
|
||||||
uint256 in = InsecureRand256();
|
uint256 in = InsecureRand256();
|
||||||
uint256 res;
|
uint256 res;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
#include <script/standard.h>
|
#include <script/standard.h>
|
||||||
#include <serialize.h>
|
#include <serialize.h>
|
||||||
#include <txorphanage.h>
|
#include <txorphanage.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
|
@ -68,7 +67,7 @@ BOOST_FIXTURE_TEST_SUITE(denialofservice_tests, TestingSetup)
|
||||||
BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
auto connman = MakeUnique<CConnman>(0x1337, 0x1337);
|
auto connman = std::make_unique<CConnman>(0x1337, 0x1337);
|
||||||
auto peerLogic = PeerManager::make(chainparams, *connman, nullptr, *m_node.scheduler,
|
auto peerLogic = PeerManager::make(chainparams, *connman, nullptr, *m_node.scheduler,
|
||||||
*m_node.chainman, *m_node.mempool, false);
|
*m_node.chainman, *m_node.mempool, false);
|
||||||
|
|
||||||
|
|
@ -138,7 +137,7 @@ static void AddRandomOutboundPeer(std::vector<CNode *> &vNodes, PeerManager &pee
|
||||||
BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
auto connman = MakeUnique<CConnmanTest>(0x1337, 0x1337);
|
auto connman = std::make_unique<CConnmanTest>(0x1337, 0x1337);
|
||||||
auto peerLogic = PeerManager::make(chainparams, *connman, nullptr, *m_node.scheduler,
|
auto peerLogic = PeerManager::make(chainparams, *connman, nullptr, *m_node.scheduler,
|
||||||
*m_node.chainman, *m_node.mempool, false);
|
*m_node.chainman, *m_node.mempool, false);
|
||||||
|
|
||||||
|
|
@ -211,8 +210,8 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||||
BOOST_AUTO_TEST_CASE(peer_discouragement)
|
BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
auto banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||||
auto connman = MakeUnique<CConnman>(0x1337, 0x1337);
|
auto connman = std::make_unique<CConnman>(0x1337, 0x1337);
|
||||||
auto peerLogic = PeerManager::make(chainparams, *connman, banman.get(), *m_node.scheduler,
|
auto peerLogic = PeerManager::make(chainparams, *connman, banman.get(), *m_node.scheduler,
|
||||||
*m_node.chainman, *m_node.mempool, false);
|
*m_node.chainman, *m_node.mempool, false);
|
||||||
|
|
||||||
|
|
@ -258,8 +257,8 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||||
BOOST_AUTO_TEST_CASE(DoS_bantime)
|
BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
auto banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||||
auto connman = MakeUnique<CConnman>(0x1337, 0x1337);
|
auto connman = std::make_unique<CConnman>(0x1337, 0x1337);
|
||||||
auto peerLogic = PeerManager::make(chainparams, *connman, banman.get(), *m_node.scheduler,
|
auto peerLogic = PeerManager::make(chainparams, *connman, banman.get(), *m_node.scheduler,
|
||||||
*m_node.chainman, *m_node.mempool, false);
|
*m_node.chainman, *m_node.mempool, false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include <pubkey.h>
|
#include <pubkey.h>
|
||||||
#include <script/descriptor.h>
|
#include <script/descriptor.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
void initialize_descriptor_parse()
|
void initialize_descriptor_parse()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include <script/interpreter.h>
|
#include <script/interpreter.h>
|
||||||
#include <test/fuzz/FuzzedDataProvider.h>
|
#include <test/fuzz/FuzzedDataProvider.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
#include <script/standard.h>
|
#include <script/standard.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
#include <rpc/client.h>
|
#include <rpc/client.h>
|
||||||
#include <rpc/util.h>
|
#include <rpc/util.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <test/util/validation.h>
|
#include <test/util/validation.h>
|
||||||
#include <txorphanage.h>
|
#include <txorphanage.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <test/util/validation.h>
|
#include <test/util/validation.h>
|
||||||
#include <txorphanage.h>
|
#include <txorphanage.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
#include <pubkey.h>
|
#include <pubkey.h>
|
||||||
#include <script/script.h>
|
#include <script/script.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
#include <pubkey.h>
|
#include <pubkey.h>
|
||||||
#include <script/interpreter.h>
|
#include <script/interpreter.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include <script/interpreter.h>
|
#include <script/interpreter.h>
|
||||||
#include <test/fuzz/FuzzedDataProvider.h>
|
#include <test/fuzz/FuzzedDataProvider.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
@ -15,7 +14,7 @@
|
||||||
|
|
||||||
void initialize_signature_checker()
|
void initialize_signature_checker()
|
||||||
{
|
{
|
||||||
static const auto verify_handle = MakeUnique<ECCVerifyHandle>();
|
static const auto verify_handle = std::make_unique<ECCVerifyHandle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
#include <span.h>
|
#include <span.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
|
@ -188,7 +187,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||||
CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK);
|
CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK);
|
||||||
std::string pszDest;
|
std::string pszDest;
|
||||||
|
|
||||||
std::unique_ptr<CNode> pnode1 = MakeUnique<CNode>(
|
std::unique_ptr<CNode> pnode1 = std::make_unique<CNode>(
|
||||||
id++, NODE_NETWORK, hSocket, addr,
|
id++, NODE_NETWORK, hSocket, addr,
|
||||||
/* nKeyedNetGroupIn = */ 0,
|
/* nKeyedNetGroupIn = */ 0,
|
||||||
/* nLocalHostNonceIn = */ 0,
|
/* nLocalHostNonceIn = */ 0,
|
||||||
|
|
@ -203,7 +202,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||||
BOOST_CHECK(pnode1->m_inbound_onion == false);
|
BOOST_CHECK(pnode1->m_inbound_onion == false);
|
||||||
BOOST_CHECK_EQUAL(pnode1->ConnectedThroughNetwork(), Network::NET_IPV4);
|
BOOST_CHECK_EQUAL(pnode1->ConnectedThroughNetwork(), Network::NET_IPV4);
|
||||||
|
|
||||||
std::unique_ptr<CNode> pnode2 = MakeUnique<CNode>(
|
std::unique_ptr<CNode> pnode2 = std::make_unique<CNode>(
|
||||||
id++, NODE_NETWORK, hSocket, addr,
|
id++, NODE_NETWORK, hSocket, addr,
|
||||||
/* nKeyedNetGroupIn = */ 1,
|
/* nKeyedNetGroupIn = */ 1,
|
||||||
/* nLocalHostNonceIn = */ 1,
|
/* nLocalHostNonceIn = */ 1,
|
||||||
|
|
@ -218,7 +217,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||||
BOOST_CHECK(pnode2->m_inbound_onion == false);
|
BOOST_CHECK(pnode2->m_inbound_onion == false);
|
||||||
BOOST_CHECK_EQUAL(pnode2->ConnectedThroughNetwork(), Network::NET_IPV4);
|
BOOST_CHECK_EQUAL(pnode2->ConnectedThroughNetwork(), Network::NET_IPV4);
|
||||||
|
|
||||||
std::unique_ptr<CNode> pnode3 = MakeUnique<CNode>(
|
std::unique_ptr<CNode> pnode3 = std::make_unique<CNode>(
|
||||||
id++, NODE_NETWORK, hSocket, addr,
|
id++, NODE_NETWORK, hSocket, addr,
|
||||||
/* nKeyedNetGroupIn = */ 0,
|
/* nKeyedNetGroupIn = */ 0,
|
||||||
/* nLocalHostNonceIn = */ 0,
|
/* nLocalHostNonceIn = */ 0,
|
||||||
|
|
@ -233,7 +232,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||||
BOOST_CHECK(pnode3->m_inbound_onion == false);
|
BOOST_CHECK(pnode3->m_inbound_onion == false);
|
||||||
BOOST_CHECK_EQUAL(pnode3->ConnectedThroughNetwork(), Network::NET_IPV4);
|
BOOST_CHECK_EQUAL(pnode3->ConnectedThroughNetwork(), Network::NET_IPV4);
|
||||||
|
|
||||||
std::unique_ptr<CNode> pnode4 = MakeUnique<CNode>(
|
std::unique_ptr<CNode> pnode4 = std::make_unique<CNode>(
|
||||||
id++, NODE_NETWORK, hSocket, addr,
|
id++, NODE_NETWORK, hSocket, addr,
|
||||||
/* nKeyedNetGroupIn = */ 1,
|
/* nKeyedNetGroupIn = */ 1,
|
||||||
/* nLocalHostNonceIn = */ 1,
|
/* nLocalHostNonceIn = */ 1,
|
||||||
|
|
@ -711,7 +710,7 @@ BOOST_AUTO_TEST_CASE(ipv4_peer_with_ipv6_addrMe_test)
|
||||||
in_addr ipv4AddrPeer;
|
in_addr ipv4AddrPeer;
|
||||||
ipv4AddrPeer.s_addr = 0xa0b0c001;
|
ipv4AddrPeer.s_addr = 0xa0b0c001;
|
||||||
CAddress addr = CAddress(CService(ipv4AddrPeer, 7777), NODE_NETWORK);
|
CAddress addr = CAddress(CService(ipv4AddrPeer, 7777), NODE_NETWORK);
|
||||||
std::unique_ptr<CNode> pnode = MakeUnique<CNode>(0, NODE_NETWORK, INVALID_SOCKET, addr, /* nKeyedNetGroupIn */ 0, /* nLocalHostNonceIn */ 0, CAddress{}, /* pszDest */ std::string{}, ConnectionType::OUTBOUND_FULL_RELAY, /* inbound_onion */ false);
|
std::unique_ptr<CNode> pnode = std::make_unique<CNode>(0, NODE_NETWORK, INVALID_SOCKET, addr, /* nKeyedNetGroupIn */ 0, /* nLocalHostNonceIn */ 0, CAddress{}, /* pszDest */ std::string{}, ConnectionType::OUTBOUND_FULL_RELAY, /* inbound_onion */ false);
|
||||||
pnode->fSuccessfullyConnected.store(true);
|
pnode->fSuccessfullyConnected.store(true);
|
||||||
|
|
||||||
// the peer claims to be reaching us via IPv6
|
// the peer claims to be reaching us via IPv6
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <noui.h>
|
#include <noui.h>
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include <script/sigcache.h>
|
#include <script/sigcache.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <txdb.h>
|
#include <txdb.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
|
@ -131,7 +130,7 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
|
||||||
{
|
{
|
||||||
// We have to run a scheduler thread to prevent ActivateBestChain
|
// We have to run a scheduler thread to prevent ActivateBestChain
|
||||||
// from blocking due to queue overrun.
|
// from blocking due to queue overrun.
|
||||||
m_node.scheduler = MakeUnique<CScheduler>();
|
m_node.scheduler = std::make_unique<CScheduler>();
|
||||||
m_node.scheduler->m_service_thread = std::thread([&] { TraceThread("scheduler", [&] { m_node.scheduler->serviceQueue(); }); });
|
m_node.scheduler->m_service_thread = std::thread([&] { TraceThread("scheduler", [&] { m_node.scheduler->serviceQueue(); }); });
|
||||||
GetMainSignals().RegisterBackgroundSignalScheduler(*m_node.scheduler);
|
GetMainSignals().RegisterBackgroundSignalScheduler(*m_node.scheduler);
|
||||||
|
|
||||||
|
|
@ -188,8 +187,8 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
||||||
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString()));
|
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_node.banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
m_node.banman = std::make_unique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||||
m_node.connman = MakeUnique<CConnman>(0x1337, 0x1337); // Deterministic randomness for tests.
|
m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337); // Deterministic randomness for tests.
|
||||||
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, m_node.banman.get(),
|
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, m_node.banman.get(),
|
||||||
*m_node.scheduler, *m_node.chainman, *m_node.mempool,
|
*m_node.scheduler, *m_node.chainman, *m_node.mempool,
|
||||||
false);
|
false);
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(util_datadir)
|
||||||
BOOST_AUTO_TEST_CASE(util_check)
|
BOOST_AUTO_TEST_CASE(util_check)
|
||||||
{
|
{
|
||||||
// Check that Assert can forward
|
// Check that Assert can forward
|
||||||
const std::unique_ptr<int> p_two = Assert(MakeUnique<int>(2));
|
const std::unique_ptr<int> p_two = Assert(std::make_unique<int>(2));
|
||||||
// Check that Assert works on lvalues and rvalues
|
// Check that Assert works on lvalues and rvalues
|
||||||
const int two = *Assert(p_two);
|
const int two = *Assert(p_two);
|
||||||
Assert(two == 2);
|
Assert(two == 2);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
#include <random.h>
|
#include <random.h>
|
||||||
#include <shutdown.h>
|
#include <shutdown.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
#include <util/vector.h>
|
#include <util/vector.h>
|
||||||
|
|
@ -41,7 +40,7 @@ struct CoinEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
CCoinsViewDB::CCoinsViewDB(fs::path ldb_path, size_t nCacheSize, bool fMemory, bool fWipe) :
|
CCoinsViewDB::CCoinsViewDB(fs::path ldb_path, size_t nCacheSize, bool fMemory, bool fWipe) :
|
||||||
m_db(MakeUnique<CDBWrapper>(ldb_path, nCacheSize, fMemory, fWipe, true)),
|
m_db(std::make_unique<CDBWrapper>(ldb_path, nCacheSize, fMemory, fWipe, true)),
|
||||||
m_ldb_path(ldb_path),
|
m_ldb_path(ldb_path),
|
||||||
m_is_memory(fMemory) { }
|
m_is_memory(fMemory) { }
|
||||||
|
|
||||||
|
|
@ -53,7 +52,7 @@ void CCoinsViewDB::ResizeCache(size_t new_cache_size)
|
||||||
// Have to do a reset first to get the original `m_db` state to release its
|
// Have to do a reset first to get the original `m_db` state to release its
|
||||||
// filesystem lock.
|
// filesystem lock.
|
||||||
m_db.reset();
|
m_db.reset();
|
||||||
m_db = MakeUnique<CDBWrapper>(
|
m_db = std::make_unique<CDBWrapper>(
|
||||||
m_ldb_path, new_cache_size, m_is_memory, /*fWipe*/ false, /*obfuscate*/ true);
|
m_ldb_path, new_cache_size, m_is_memory, /*fWipe*/ false, /*obfuscate*/ true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
#include <primitives/transaction.h>
|
#include <primitives/transaction.h>
|
||||||
#include <random.h>
|
#include <random.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <boost/multi_index_container.hpp>
|
#include <boost/multi_index_container.hpp>
|
||||||
#include <boost/multi_index/ordered_index.hpp>
|
#include <boost/multi_index/ordered_index.hpp>
|
||||||
|
|
@ -711,7 +710,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
TxRequestTracker::TxRequestTracker(bool deterministic) :
|
TxRequestTracker::TxRequestTracker(bool deterministic) :
|
||||||
m_impl{MakeUnique<TxRequestTracker::Impl>(deterministic)} {}
|
m_impl{std::make_unique<TxRequestTracker::Impl>(deterministic)} {}
|
||||||
|
|
||||||
TxRequestTracker::~TxRequestTracker() = default;
|
TxRequestTracker::~TxRequestTracker() = default;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
||||||
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
|
||||||
// Distributed under the MIT software license, see the accompanying
|
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
||||||
|
|
||||||
#ifndef BITCOIN_UTIL_MEMORY_H
|
|
||||||
#define BITCOIN_UTIL_MEMORY_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
//! Substitute for C++14 std::make_unique.
|
|
||||||
//! DEPRECATED use std::make_unique in new code.
|
|
||||||
template <typename T, typename... Args>
|
|
||||||
std::unique_ptr<T> MakeUnique(Args&&... args)
|
|
||||||
{
|
|
||||||
return std::make_unique<T>(std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -100,7 +100,7 @@ bool LockDirectory(const fs::path& directory, const std::string lockfile_name, b
|
||||||
// Create empty lock file if it doesn't exist.
|
// Create empty lock file if it doesn't exist.
|
||||||
FILE* file = fsbridge::fopen(pathLockFile, "a");
|
FILE* file = fsbridge::fopen(pathLockFile, "a");
|
||||||
if (file) fclose(file);
|
if (file) fclose(file);
|
||||||
auto lock = MakeUnique<fsbridge::FileLock>(pathLockFile);
|
auto lock = std::make_unique<fsbridge::FileLock>(pathLockFile);
|
||||||
if (!lock->TryLock()) {
|
if (!lock->TryLock()) {
|
||||||
return error("Error while attempting to lock directory %s: %s", directory.string(), lock->GetReason());
|
return error("Error while attempting to lock directory %s: %s", directory.string(), lock->GetReason());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
#include <optional.h>
|
#include <optional.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <util/settings.h>
|
#include <util/settings.h>
|
||||||
#include <util/threadnames.h>
|
#include <util/threadnames.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
|
|
||||||
|
|
@ -1287,7 +1287,7 @@ CoinsViews::CoinsViews(
|
||||||
|
|
||||||
void CoinsViews::InitCache()
|
void CoinsViews::InitCache()
|
||||||
{
|
{
|
||||||
m_cacheview = MakeUnique<CCoinsViewCache>(&m_catcherview);
|
m_cacheview = std::make_unique<CCoinsViewCache>(&m_catcherview);
|
||||||
}
|
}
|
||||||
|
|
||||||
CChainState::CChainState(CTxMemPool& mempool, BlockManager& blockman, uint256 from_snapshot_blockhash)
|
CChainState::CChainState(CTxMemPool& mempool, BlockManager& blockman, uint256 from_snapshot_blockhash)
|
||||||
|
|
@ -1305,7 +1305,7 @@ void CChainState::InitCoinsDB(
|
||||||
leveldb_name += "_" + m_from_snapshot_blockhash.ToString();
|
leveldb_name += "_" + m_from_snapshot_blockhash.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_coins_views = MakeUnique<CoinsViews>(
|
m_coins_views = std::make_unique<CoinsViews>(
|
||||||
leveldb_name, cache_size_bytes, in_memory, should_wipe);
|
leveldb_name, cache_size_bytes, in_memory, should_wipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5279,7 +5279,7 @@ bool ChainstateManager::ActivateSnapshot(
|
||||||
static_cast<size_t>(current_coinsdb_cache_size * IBD_CACHE_PERC));
|
static_cast<size_t>(current_coinsdb_cache_size * IBD_CACHE_PERC));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto snapshot_chainstate = WITH_LOCK(::cs_main, return MakeUnique<CChainState>(
|
auto snapshot_chainstate = WITH_LOCK(::cs_main, return std::make_unique<CChainState>(
|
||||||
this->ActiveChainstate().m_mempool, m_blockman, base_blockhash));
|
this->ActiveChainstate().m_mempool, m_blockman, base_blockhash));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ void BerkeleyDatabase::Open()
|
||||||
|
|
||||||
if (m_db == nullptr) {
|
if (m_db == nullptr) {
|
||||||
int ret;
|
int ret;
|
||||||
std::unique_ptr<Db> pdb_temp = MakeUnique<Db>(env->dbenv.get(), 0);
|
std::unique_ptr<Db> pdb_temp = std::make_unique<Db>(env->dbenv.get(), 0);
|
||||||
|
|
||||||
bool fMockDb = env->IsMock();
|
bool fMockDb = env->IsMock();
|
||||||
if (fMockDb) {
|
if (fMockDb) {
|
||||||
|
|
@ -462,7 +462,7 @@ bool BerkeleyDatabase::Rewrite(const char* pszSkip)
|
||||||
std::string strFileRes = strFile + ".rewrite";
|
std::string strFileRes = strFile + ".rewrite";
|
||||||
{ // surround usage of db with extra {}
|
{ // surround usage of db with extra {}
|
||||||
BerkeleyBatch db(*this, true);
|
BerkeleyBatch db(*this, true);
|
||||||
std::unique_ptr<Db> pdbCopy = MakeUnique<Db>(env->dbenv.get(), 0);
|
std::unique_ptr<Db> pdbCopy = std::make_unique<Db>(env->dbenv.get(), 0);
|
||||||
|
|
||||||
int ret = pdbCopy->open(nullptr, // Txn pointer
|
int ret = pdbCopy->open(nullptr, // Txn pointer
|
||||||
strFileRes.c_str(), // Filename
|
strFileRes.c_str(), // Filename
|
||||||
|
|
@ -819,7 +819,7 @@ void BerkeleyDatabase::RemoveRef()
|
||||||
|
|
||||||
std::unique_ptr<DatabaseBatch> BerkeleyDatabase::MakeBatch(bool flush_on_close)
|
std::unique_ptr<DatabaseBatch> BerkeleyDatabase::MakeBatch(bool flush_on_close)
|
||||||
{
|
{
|
||||||
return MakeUnique<BerkeleyBatch>(*this, false, flush_on_close);
|
return std::make_unique<BerkeleyBatch>(*this, false, flush_on_close);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<BerkeleyDatabase> MakeBerkeleyDatabase(const fs::path& path, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error)
|
std::unique_ptr<BerkeleyDatabase> MakeBerkeleyDatabase(const fs::path& path, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error)
|
||||||
|
|
@ -835,7 +835,7 @@ std::unique_ptr<BerkeleyDatabase> MakeBerkeleyDatabase(const fs::path& path, con
|
||||||
status = DatabaseStatus::FAILED_ALREADY_LOADED;
|
status = DatabaseStatus::FAILED_ALREADY_LOADED;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
db = MakeUnique<BerkeleyDatabase>(std::move(env), std::move(data_filename));
|
db = std::make_unique<BerkeleyDatabase>(std::move(env), std::move(data_filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.verify && !db->Verify(error)) {
|
if (options.verify && !db->Verify(error)) {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
#include <optional.h>
|
#include <optional.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <support/allocators/secure.h>
|
#include <support/allocators/secure.h>
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -193,7 +192,7 @@ public:
|
||||||
void ReloadDbEnv() override {}
|
void ReloadDbEnv() override {}
|
||||||
std::string Filename() override { return "dummy"; }
|
std::string Filename() override { return "dummy"; }
|
||||||
std::string Format() override { return "dummy"; }
|
std::string Format() override { return "dummy"; }
|
||||||
std::unique_ptr<DatabaseBatch> MakeBatch(bool flush_on_close = true) override { return MakeUnique<DummyBatch>(); }
|
std::unique_ptr<DatabaseBatch> MakeBatch(bool flush_on_close = true) override { return std::make_unique<DummyBatch>(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DatabaseFormat {
|
enum class DatabaseFormat {
|
||||||
|
|
|
||||||
|
|
@ -588,10 +588,10 @@ public:
|
||||||
} // namespace wallet
|
} // namespace wallet
|
||||||
|
|
||||||
namespace interfaces {
|
namespace interfaces {
|
||||||
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet) { return wallet ? MakeUnique<wallet::WalletImpl>(wallet) : nullptr; }
|
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet) { return wallet ? std::make_unique<wallet::WalletImpl>(wallet) : nullptr; }
|
||||||
|
|
||||||
std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, ArgsManager& args)
|
std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, ArgsManager& args)
|
||||||
{
|
{
|
||||||
return MakeUnique<wallet::WalletClientImpl>(chain, args);
|
return std::make_unique<wallet::WalletClientImpl>(chain, args);
|
||||||
}
|
}
|
||||||
} // namespace interfaces
|
} // namespace interfaces
|
||||||
|
|
|
||||||
|
|
@ -982,14 +982,14 @@ static UniValue ProcessImportLegacy(ImportData& import_data, std::map<CKeyID, CP
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid redeem script \"" + strRedeemScript + "\": must be hex string");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid redeem script \"" + strRedeemScript + "\": must be hex string");
|
||||||
}
|
}
|
||||||
auto parsed_redeemscript = ParseHex(strRedeemScript);
|
auto parsed_redeemscript = ParseHex(strRedeemScript);
|
||||||
import_data.redeemscript = MakeUnique<CScript>(parsed_redeemscript.begin(), parsed_redeemscript.end());
|
import_data.redeemscript = std::make_unique<CScript>(parsed_redeemscript.begin(), parsed_redeemscript.end());
|
||||||
}
|
}
|
||||||
if (witness_script_hex.size()) {
|
if (witness_script_hex.size()) {
|
||||||
if (!IsHex(witness_script_hex)) {
|
if (!IsHex(witness_script_hex)) {
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid witness script \"" + witness_script_hex + "\": must be hex string");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid witness script \"" + witness_script_hex + "\": must be hex string");
|
||||||
}
|
}
|
||||||
auto parsed_witnessscript = ParseHex(witness_script_hex);
|
auto parsed_witnessscript = ParseHex(witness_script_hex);
|
||||||
import_data.witnessscript = MakeUnique<CScript>(parsed_witnessscript.begin(), parsed_witnessscript.end());
|
import_data.witnessscript = std::make_unique<CScript>(parsed_witnessscript.begin(), parsed_witnessscript.end());
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < pubKeys.size(); ++i) {
|
for (size_t i = 0; i < pubKeys.size(); ++i) {
|
||||||
const auto& str = pubKeys[i].get_str();
|
const auto& str = pubKeys[i].get_str();
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::v
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Db> pdbCopy = MakeUnique<Db>(env->dbenv.get(), 0);
|
std::unique_ptr<Db> pdbCopy = std::make_unique<Db>(env->dbenv.get(), 0);
|
||||||
int ret = pdbCopy->open(nullptr, // Txn pointer
|
int ret = pdbCopy->open(nullptr, // Txn pointer
|
||||||
filename.c_str(), // Filename
|
filename.c_str(), // Filename
|
||||||
"main", // Logical db name
|
"main", // Logical db name
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,7 @@ void LegacyScriptPubKeyMan::UpgradeKeyMetadata()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<WalletBatch> batch = MakeUnique<WalletBatch>(m_storage.GetDatabase());
|
std::unique_ptr<WalletBatch> batch = std::make_unique<WalletBatch>(m_storage.GetDatabase());
|
||||||
for (auto& meta_pair : mapKeyMetadata) {
|
for (auto& meta_pair : mapKeyMetadata) {
|
||||||
CKeyMetadata& meta = meta_pair.second;
|
CKeyMetadata& meta = meta_pair.second;
|
||||||
if (!meta.hd_seed_id.IsNull() && !meta.has_key_origin && meta.hdKeypath != "s") { // If the hdKeypath is "s", that's the seed and it doesn't have a key origin
|
if (!meta.hd_seed_id.IsNull() && !meta.has_key_origin && meta.hdKeypath != "s") { // If the hdKeypath is "s", that's the seed and it doesn't have a key origin
|
||||||
|
|
@ -551,7 +551,7 @@ int64_t LegacyScriptPubKeyMan::GetTimeFirstKey() const
|
||||||
|
|
||||||
std::unique_ptr<SigningProvider> LegacyScriptPubKeyMan::GetSolvingProvider(const CScript& script) const
|
std::unique_ptr<SigningProvider> LegacyScriptPubKeyMan::GetSolvingProvider(const CScript& script) const
|
||||||
{
|
{
|
||||||
return MakeUnique<LegacySigningProvider>(*this);
|
return std::make_unique<LegacySigningProvider>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyScriptPubKeyMan::CanProvide(const CScript& script, SignatureData& sigdata)
|
bool LegacyScriptPubKeyMan::CanProvide(const CScript& script, SignatureData& sigdata)
|
||||||
|
|
@ -651,14 +651,14 @@ std::unique_ptr<CKeyMetadata> LegacyScriptPubKeyMan::GetMetadata(const CTxDestin
|
||||||
if (!key_id.IsNull()) {
|
if (!key_id.IsNull()) {
|
||||||
auto it = mapKeyMetadata.find(key_id);
|
auto it = mapKeyMetadata.find(key_id);
|
||||||
if (it != mapKeyMetadata.end()) {
|
if (it != mapKeyMetadata.end()) {
|
||||||
return MakeUnique<CKeyMetadata>(it->second);
|
return std::make_unique<CKeyMetadata>(it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CScript scriptPubKey = GetScriptForDestination(dest);
|
CScript scriptPubKey = GetScriptForDestination(dest);
|
||||||
auto it = m_script_metadata.find(CScriptID(scriptPubKey));
|
auto it = m_script_metadata.find(CScriptID(scriptPubKey));
|
||||||
if (it != m_script_metadata.end()) {
|
if (it != m_script_metadata.end()) {
|
||||||
return MakeUnique<CKeyMetadata>(it->second);
|
return std::make_unique<CKeyMetadata>(it->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -2026,7 +2026,7 @@ std::unique_ptr<FlatSigningProvider> DescriptorScriptPubKeyMan::GetSigningProvid
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_desc_man);
|
AssertLockHeld(cs_desc_man);
|
||||||
// Get the scripts, keys, and key origins for this script
|
// Get the scripts, keys, and key origins for this script
|
||||||
std::unique_ptr<FlatSigningProvider> out_keys = MakeUnique<FlatSigningProvider>();
|
std::unique_ptr<FlatSigningProvider> out_keys = std::make_unique<FlatSigningProvider>();
|
||||||
std::vector<CScript> scripts_temp;
|
std::vector<CScript> scripts_temp;
|
||||||
if (!m_wallet_descriptor.descriptor->ExpandFromCache(index, m_wallet_descriptor.cache, scripts_temp, *out_keys)) return nullptr;
|
if (!m_wallet_descriptor.descriptor->ExpandFromCache(index, m_wallet_descriptor.cache, scripts_temp, *out_keys)) return nullptr;
|
||||||
|
|
||||||
|
|
@ -2051,7 +2051,7 @@ bool DescriptorScriptPubKeyMan::CanProvide(const CScript& script, SignatureData&
|
||||||
|
|
||||||
bool DescriptorScriptPubKeyMan::SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, std::string>& input_errors) const
|
bool DescriptorScriptPubKeyMan::SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, std::string>& input_errors) const
|
||||||
{
|
{
|
||||||
std::unique_ptr<FlatSigningProvider> keys = MakeUnique<FlatSigningProvider>();
|
std::unique_ptr<FlatSigningProvider> keys = std::make_unique<FlatSigningProvider>();
|
||||||
for (const auto& coin_pair : coins) {
|
for (const auto& coin_pair : coins) {
|
||||||
std::unique_ptr<FlatSigningProvider> coin_keys = GetSigningProvider(coin_pair.second.out.scriptPubKey, true);
|
std::unique_ptr<FlatSigningProvider> coin_keys = GetSigningProvider(coin_pair.second.out.scriptPubKey, true);
|
||||||
if (!coin_keys) {
|
if (!coin_keys) {
|
||||||
|
|
@ -2115,13 +2115,13 @@ TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction&
|
||||||
SignatureData sigdata;
|
SignatureData sigdata;
|
||||||
input.FillSignatureData(sigdata);
|
input.FillSignatureData(sigdata);
|
||||||
|
|
||||||
std::unique_ptr<FlatSigningProvider> keys = MakeUnique<FlatSigningProvider>();
|
std::unique_ptr<FlatSigningProvider> keys = std::make_unique<FlatSigningProvider>();
|
||||||
std::unique_ptr<FlatSigningProvider> script_keys = GetSigningProvider(script, sign);
|
std::unique_ptr<FlatSigningProvider> script_keys = GetSigningProvider(script, sign);
|
||||||
if (script_keys) {
|
if (script_keys) {
|
||||||
*keys = Merge(*keys, *script_keys);
|
*keys = Merge(*keys, *script_keys);
|
||||||
} else {
|
} else {
|
||||||
// Maybe there are pubkeys listed that we can sign for
|
// Maybe there are pubkeys listed that we can sign for
|
||||||
script_keys = MakeUnique<FlatSigningProvider>();
|
script_keys = std::make_unique<FlatSigningProvider>();
|
||||||
for (const auto& pk_pair : input.hd_keypaths) {
|
for (const auto& pk_pair : input.hd_keypaths) {
|
||||||
const CPubKey& pubkey = pk_pair.first;
|
const CPubKey& pubkey = pk_pair.first;
|
||||||
std::unique_ptr<FlatSigningProvider> pk_keys = GetSigningProvider(pubkey);
|
std::unique_ptr<FlatSigningProvider> pk_keys = GetSigningProvider(pubkey);
|
||||||
|
|
@ -2162,7 +2162,7 @@ std::unique_ptr<CKeyMetadata> DescriptorScriptPubKeyMan::GetMetadata(const CTxDe
|
||||||
CKeyID key_id = GetKeyForDestination(*provider, dest);
|
CKeyID key_id = GetKeyForDestination(*provider, dest);
|
||||||
if (provider->GetKeyOrigin(key_id, orig)) {
|
if (provider->GetKeyOrigin(key_id, orig)) {
|
||||||
LOCK(cs_desc_man);
|
LOCK(cs_desc_man);
|
||||||
std::unique_ptr<CKeyMetadata> meta = MakeUnique<CKeyMetadata>();
|
std::unique_ptr<CKeyMetadata> meta = std::make_unique<CKeyMetadata>();
|
||||||
meta->key_origin = orig;
|
meta->key_origin = orig;
|
||||||
meta->has_key_origin = true;
|
meta->has_key_origin = true;
|
||||||
meta->nCreateTime = m_wallet_descriptor.creation_time;
|
meta->nCreateTime = m_wallet_descriptor.creation_time;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
#include <crypto/common.h>
|
#include <crypto/common.h>
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <util/memory.h>
|
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
|
|
@ -330,7 +329,7 @@ void SQLiteDatabase::Close()
|
||||||
std::unique_ptr<DatabaseBatch> SQLiteDatabase::MakeBatch(bool flush_on_close)
|
std::unique_ptr<DatabaseBatch> SQLiteDatabase::MakeBatch(bool flush_on_close)
|
||||||
{
|
{
|
||||||
// We ignore flush_on_close because we don't do manual flushing for SQLite
|
// We ignore flush_on_close because we don't do manual flushing for SQLite
|
||||||
return MakeUnique<SQLiteBatch>(*this);
|
return std::make_unique<SQLiteBatch>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLiteBatch::SQLiteBatch(SQLiteDatabase& database)
|
SQLiteBatch::SQLiteBatch(SQLiteDatabase& database)
|
||||||
|
|
@ -571,7 +570,7 @@ std::unique_ptr<SQLiteDatabase> MakeSQLiteDatabase(const fs::path& path, const D
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
fs::path data_file = SQLiteDataFile(path);
|
fs::path data_file = SQLiteDataFile(path);
|
||||||
auto db = MakeUnique<SQLiteDatabase>(data_file.parent_path(), data_file);
|
auto db = std::make_unique<SQLiteDatabase>(data_file.parent_path(), data_file);
|
||||||
if (options.verify && !db->Verify(error)) {
|
if (options.verify && !db->Verify(error)) {
|
||||||
status = DatabaseStatus::FAILED_VERIFY;
|
status = DatabaseStatus::FAILED_VERIFY;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
|
||||||
// Make sure that can use BnB when there are preset inputs
|
// Make sure that can use BnB when there are preset inputs
|
||||||
empty_wallet();
|
empty_wallet();
|
||||||
{
|
{
|
||||||
std::unique_ptr<CWallet> wallet = MakeUnique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
|
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
|
||||||
bool firstRun;
|
bool firstRun;
|
||||||
wallet->LoadWallet(firstRun);
|
wallet->LoadWallet(firstRun);
|
||||||
wallet->SetupLegacyScriptPubKeyMan();
|
wallet->SetupLegacyScriptPubKeyMan();
|
||||||
|
|
|
||||||
|
|
@ -485,7 +485,7 @@ public:
|
||||||
ListCoinsTestingSetup()
|
ListCoinsTestingSetup()
|
||||||
{
|
{
|
||||||
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
|
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
|
||||||
wallet = MakeUnique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
|
wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
|
||||||
{
|
{
|
||||||
LOCK2(wallet->cs_wallet, ::cs_main);
|
LOCK2(wallet->cs_wallet, ::cs_main);
|
||||||
wallet->SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
|
wallet->SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
|
||||||
|
|
|
||||||
|
|
@ -1086,15 +1086,15 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
|
||||||
/** Return object for accessing dummy database with no read/write capabilities. */
|
/** Return object for accessing dummy database with no read/write capabilities. */
|
||||||
std::unique_ptr<WalletDatabase> CreateDummyWalletDatabase()
|
std::unique_ptr<WalletDatabase> CreateDummyWalletDatabase()
|
||||||
{
|
{
|
||||||
return MakeUnique<DummyDatabase>();
|
return std::make_unique<DummyDatabase>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return object for accessing temporary in-memory database. */
|
/** Return object for accessing temporary in-memory database. */
|
||||||
std::unique_ptr<WalletDatabase> CreateMockWalletDatabase()
|
std::unique_ptr<WalletDatabase> CreateMockWalletDatabase()
|
||||||
{
|
{
|
||||||
#ifdef USE_BDB
|
#ifdef USE_BDB
|
||||||
return MakeUnique<BerkeleyDatabase>(std::make_shared<BerkeleyEnvironment>(), "");
|
return std::make_unique<BerkeleyDatabase>(std::make_shared<BerkeleyEnvironment>(), "");
|
||||||
#elif USE_SQLITE
|
#elif USE_SQLITE
|
||||||
return MakeUnique<SQLiteDatabase>("", "", true);
|
return std::make_unique<SQLiteDatabase>("", "", true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
#ifndef BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
|
#ifndef BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
|
||||||
#define BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
|
#define BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
|
||||||
|
|
||||||
#include <util/memory.h>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -27,7 +26,7 @@ public:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static std::unique_ptr<CZMQAbstractNotifier> Create()
|
static std::unique_ptr<CZMQAbstractNotifier> Create()
|
||||||
{
|
{
|
||||||
return MakeUnique<T>();
|
return std::make_unique<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetType() const { return type; }
|
std::string GetType() const { return type; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue