Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/dash/lint-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ iwyu_tool.py \
"src/init" \
"src/kernel" \
"src/node/chainstate.cpp" \
"src/node/mempool_args.cpp" \
"src/node/minisketchwrapper.cpp" \
"src/policy/feerate.cpp" \
"src/policy/packages.cpp" \
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ BITCOIN_CORE_H = \
masternode/payments.h \
masternode/sync.h \
masternode/utils.h \
mempool_args.h \
memusage.h \
merkleblock.h \
messagesigner.h \
Expand All @@ -342,6 +341,7 @@ BITCOIN_CORE_H = \
node/context.h \
node/eviction.h \
node/interface_ui.h \
node/mempool_args.h \
node/mempool_persist_args.h \
node/miner.h \
node/minisketchwrapper.h \
Expand Down Expand Up @@ -596,7 +596,6 @@ libbitcoin_node_a_SOURCES = \
masternode/payments.cpp \
masternode/sync.cpp \
masternode/utils.cpp \
mempool_args.cpp \
net.cpp \
net_processing.cpp \
netfulfilledman.cpp \
Expand All @@ -610,6 +609,7 @@ libbitcoin_node_a_SOURCES = \
node/eviction.cpp \
node/interface_ui.cpp \
node/interfaces.cpp \
node/mempool_args.cpp \
node/mempool_persist_args.cpp \
node/miner.cpp \
node/minisketchwrapper.cpp \
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.test_fuzz.include
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TEST_FUZZ_H = \
test/fuzz/FuzzedDataProvider.h \
test/fuzz/util.h \
test/util/mining.h \
test/fuzz/mempool_utils.h \
test/fuzz/util/mempool.h \
test/fuzz/util/net.h

libtest_fuzz_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
Expand All @@ -21,5 +21,6 @@ libtest_fuzz_a_SOURCES = \
test/fuzz/fuzz.cpp \
test/util/mining.cpp \
test/fuzz/util.cpp \
test/fuzz/util/mempool.cpp \
test/fuzz/util/net.cpp \
$(TEST_FUZZ_H)
2 changes: 1 addition & 1 deletion src/index/addressindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ bool AddressIndex::DB::RewindBatch(const std::vector<CAddressIndexEntry>& addres
}

AddressIndex::AddressIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory, bool f_wipe) :
BaseIndex(std::move(chain)),
BaseIndex(std::move(chain), "addressindex"),
m_db(std::make_unique<AddressIndex::DB>(n_cache_size, f_memory, f_wipe))
{
}
Expand Down
2 changes: 0 additions & 2 deletions src/index/addressindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class AddressIndex final : public BaseIndex

BaseIndex::DB& GetDB() const override;

const char* GetName() const override { return "addressindex"; }

public:
/// Constructs the index, which becomes available to be queried
explicit AddressIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
Expand Down
7 changes: 5 additions & 2 deletions src/index/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include <validation.h>
#include <warnings.h>

#include <string>
#include <utility>

using node::PruneLockInfo;
using node::ReadBlockFromDisk;
using node::fPruneMode;
Expand Down Expand Up @@ -58,8 +61,8 @@ void BaseIndex::DB::WriteBestBlock(CDBBatch& batch, const CBlockLocator& locator
batch.Write(DB_BEST_BLOCK, locator);
}

BaseIndex::BaseIndex(std::unique_ptr<interfaces::Chain> chain)
: m_chain{std::move(chain)} {}
BaseIndex::BaseIndex(std::unique_ptr<interfaces::Chain> chain, std::string name)
: m_chain{std::move(chain)}, m_name{std::move(name)} {}

BaseIndex::~BaseIndex()
{
Expand Down
6 changes: 4 additions & 2 deletions src/index/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <validationinterface.h>

#include <atomic>
#include <string>

class CBlock;
class CBlockIndex;
Expand Down Expand Up @@ -98,6 +99,7 @@ class BaseIndex : public CValidationInterface
protected:
std::unique_ptr<interfaces::Chain> m_chain;
Chainstate* m_chainstate{nullptr};
const std::string m_name;

void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) override;

Expand All @@ -122,7 +124,7 @@ class BaseIndex : public CValidationInterface
virtual DB& GetDB() const = 0;

/// Get the name of the index for display in logs.
virtual const char* GetName() const = 0;
const std::string& GetName() const LIFETIMEBOUND { return m_name; }

/// Trigger a fatal index error and initiate shutdown.
static void FatalErrorImpl(const std::string& message);
Expand All @@ -137,7 +139,7 @@ class BaseIndex : public CValidationInterface
void SetBestBlockIndex(const CBlockIndex* block);

public:
BaseIndex(std::unique_ptr<interfaces::Chain> chain);
BaseIndex(std::unique_ptr<interfaces::Chain> chain, std::string name);
/// Destructor interrupts sync thread if running and blocks until it exits.
virtual ~BaseIndex();

Expand Down
4 changes: 2 additions & 2 deletions src/index/blockfilterindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ static std::map<BlockFilterType, BlockFilterIndex> g_filter_indexes;

BlockFilterIndex::BlockFilterIndex(std::unique_ptr<interfaces::Chain> chain, BlockFilterType filter_type,
size_t n_cache_size, bool f_memory, bool f_wipe)
: BaseIndex(std::move(chain)), m_filter_type(filter_type)
: BaseIndex(std::move(chain), BlockFilterTypeName(filter_type) + " block filter index")
, m_filter_type(filter_type)
{
const std::string& filter_name = BlockFilterTypeName(filter_type);
if (filter_name.empty()) throw std::invalid_argument("unknown filter_type");

fs::path path = gArgs.GetDataDirNet() / "indexes" / "blockfilter" / fs::u8path(filter_name);
fs::create_directories(path);

m_name = filter_name + " block filter index";
m_db = std::make_unique<BaseIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);

// Check version
Expand Down
3 changes: 0 additions & 3 deletions src/index/blockfilterindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class BlockFilterIndex final : public BaseIndex
static constexpr int CURRENT_VERSION = 2;

BlockFilterType m_filter_type;
std::string m_name;
std::unique_ptr<BaseIndex::DB> m_db;

FlatFilePos m_next_filter_pos;
Expand All @@ -57,8 +56,6 @@ class BlockFilterIndex final : public BaseIndex

BaseIndex::DB& GetDB() const LIFETIMEBOUND override { return *m_db; }

const char* GetName() const LIFETIMEBOUND override { return m_name.c_str(); }

public:
/** Constructs the index, which becomes available to be queried. */
explicit BlockFilterIndex(std::unique_ptr<interfaces::Chain> chain, BlockFilterType filter_type,
Expand Down
9 changes: 5 additions & 4 deletions src/index/coinstatsindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <coins.h>
#include <crypto/muhash.h>
#include <index/coinstatsindex.h>
#include <kernel/coinstats.h>
#include <node/blockstorage.h>
#include <serialize.h>
#include <txdb.h>
Expand Down Expand Up @@ -105,7 +106,7 @@ struct DBHashKey {
std::unique_ptr<CoinStatsIndex> g_coin_stats_index;

CoinStatsIndex::CoinStatsIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory, bool f_wipe)
: BaseIndex(std::move(chain))
: BaseIndex(std::move(chain), "coinstatsindex")
{
fs::path path{gArgs.GetDataDirNet() / "indexes" / "coinstats"};
fs::create_directories(path);
Expand Down Expand Up @@ -315,13 +316,13 @@ static bool LookUpOne(const CDBWrapper& db, const interfaces::BlockKey& block, D
return db.Read(DBHashKey(block.hash), result);
}

std::optional<CCoinsStats> CoinStatsIndex::LookUpStats(const CBlockIndex* block_index) const
std::optional<CCoinsStats> CoinStatsIndex::LookUpStats(const CBlockIndex& block_index) const
{
CCoinsStats stats{Assert(block_index)->nHeight, block_index->GetBlockHash()};
CCoinsStats stats{block_index.nHeight, block_index.GetBlockHash()};
stats.index_used = true;

DBVal entry;
if (!LookUpOne(*m_db, {block_index->GetBlockHash(), block_index->nHeight}, entry)) {
if (!LookUpOne(*m_db, {block_index.GetBlockHash(), block_index.nHeight}, entry)) {
return std::nullopt;
}

Expand Down
14 changes: 7 additions & 7 deletions src/index/coinstatsindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
#ifndef BITCOIN_INDEX_COINSTATSINDEX_H
#define BITCOIN_INDEX_COINSTATSINDEX_H

#include <chain.h>
#include <crypto/muhash.h>
#include <flatfile.h>
#include <index/base.h>
#include <kernel/coinstats.h>

class CBlockIndex;
class CDBBatch;
namespace kernel {
struct CCoinsStats;
}

static constexpr bool DEFAULT_COINSTATSINDEX{false};

Expand All @@ -19,7 +22,6 @@ static constexpr bool DEFAULT_COINSTATSINDEX{false};
class CoinStatsIndex final : public BaseIndex
{
private:
std::string m_name;
std::unique_ptr<BaseIndex::DB> m_db;

MuHash3072 m_muhash;
Expand Down Expand Up @@ -51,14 +53,12 @@ class CoinStatsIndex final : public BaseIndex

BaseIndex::DB& GetDB() const override { return *m_db; }

const char* GetName() const override { return "coinstatsindex"; }

public:
// Constructs the index, which becomes available to be queried.
explicit CoinStatsIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory = false, bool f_wipe = false);

// Look up stats for a specific block using CBlockIndex
std::optional<kernel::CCoinsStats> LookUpStats(const CBlockIndex* block_index) const;
std::optional<kernel::CCoinsStats> LookUpStats(const CBlockIndex& block_index) const;
};

/// The global UTXO set hash object.
Expand Down
2 changes: 1 addition & 1 deletion src/index/spentindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bool SpentIndex::DB::EraseSpentIndex(const std::vector<CSpentIndexKey>& keys)
}

SpentIndex::SpentIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory, bool f_wipe) :
BaseIndex(std::move(chain)),
BaseIndex(std::move(chain), "spentindex"),
m_db(std::make_unique<SpentIndex::DB>(n_cache_size, f_memory, f_wipe))
{
}
Expand Down
1 change: 0 additions & 1 deletion src/index/spentindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class SpentIndex final : public BaseIndex
bool CustomRewind(const interfaces::BlockKey& current_tip, const interfaces::BlockKey& new_tip) override;

BaseIndex::DB& GetDB() const override;
const char* GetName() const override { return "spentindex"; }

/// SpentIndex cannot work with pruned nodes as it requires UTXO data
bool AllowPrune() const override { return false; }
Expand Down
2 changes: 1 addition & 1 deletion src/index/timestampindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool TimestampIndex::DB::EraseTimestampIndex(const CTimestampIndexKey& key)
}

TimestampIndex::TimestampIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory, bool f_wipe) :
BaseIndex(std::move(chain)),
BaseIndex(std::move(chain), "timestampindex"),
m_db(std::make_unique<TimestampIndex::DB>(n_cache_size, f_memory, f_wipe))
{
}
Expand Down
1 change: 0 additions & 1 deletion src/index/timestampindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class TimestampIndex final : public BaseIndex
bool CustomRewind(const interfaces::BlockKey& current_tip, const interfaces::BlockKey& new_tip) override;

BaseIndex::DB& GetDB() const override;
const char* GetName() const override { return "timestampindex"; }

/// TimestampIndex works with pruned nodes since it only stores block metadata
bool AllowPrune() const override { return true; }
Expand Down
2 changes: 1 addition & 1 deletion src/index/txindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool TxIndex::DB::WriteTxs(const std::vector<std::pair<uint256, CDiskTxPos>>& v_
}

TxIndex::TxIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory, bool f_wipe)
: BaseIndex(std::move(chain)), m_db(std::make_unique<TxIndex::DB>(n_cache_size, f_memory, f_wipe))
: BaseIndex(std::move(chain), "txindex"), m_db(std::make_unique<TxIndex::DB>(n_cache_size, f_memory, f_wipe))
{}

TxIndex::~TxIndex() = default;
Expand Down
2 changes: 0 additions & 2 deletions src/index/txindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class TxIndex final : public BaseIndex

BaseIndex::DB& GetDB() const override;

const char* GetName() const override { return "txindex"; }

public:
/// Constructs the index, which becomes available to be queried.
explicit TxIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
Expand Down
Loading
Loading