Skip to content

Commit

Permalink
tidy: modernize-use-equals-default
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Jul 8, 2024
1 parent bd5d168 commit 3333bae
Show file tree
Hide file tree
Showing 53 changed files with 72 additions and 76 deletions.
1 change: 1 addition & 0 deletions src/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ misc-unused-using-decls,
misc-no-recursion,
modernize-use-default-member-init,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-noexcept,
modernize-use-nullptr,
performance-*,
Expand Down
2 changes: 1 addition & 1 deletion src/arith_uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class base_uint
/** 256-bit unsigned big integer. */
class arith_uint256 : public base_uint<256> {
public:
arith_uint256() {}
arith_uint256() = default;
arith_uint256(const base_uint<256>& b) : base_uint<256>(b) {}
arith_uint256(uint64_t b) : base_uint<256>(b) {}

Expand Down
4 changes: 2 additions & 2 deletions src/blockencodings.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class BlockTransactions {
uint256 blockhash;
std::vector<CTransactionRef> txn;

BlockTransactions() {}
BlockTransactions() = default;
explicit BlockTransactions(const BlockTransactionsRequest& req) :
blockhash(req.blockhash), txn(req.indexes.size()) {}

Expand Down Expand Up @@ -109,7 +109,7 @@ class CBlockHeaderAndShortTxIDs {
/**
* Dummy for deserialization
*/
CBlockHeaderAndShortTxIDs() {}
CBlockHeaderAndShortTxIDs() = default;

/**
* @param[in] nonce This should be randomly generated, and is used for the siphash secret key
Expand Down
2 changes: 1 addition & 1 deletion src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CBlockFileInfo
READWRITE(VARINT(obj.nTimeLast));
}

CBlockFileInfo() {}
CBlockFileInfo() = default;

std::string ToString() const;

Expand Down
4 changes: 2 additions & 2 deletions src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class CCoinsViewCursor
{
public:
CCoinsViewCursor(const uint256 &hashBlockIn): hashBlock(hashBlockIn) {}
virtual ~CCoinsViewCursor() {}
virtual ~CCoinsViewCursor() = default;

virtual bool GetKey(COutPoint &key) const = 0;
virtual bool GetValue(Coin &coin) const = 0;
Expand Down Expand Up @@ -198,7 +198,7 @@ class CCoinsView
virtual std::unique_ptr<CCoinsViewCursor> Cursor() const;

//! As we use CCoinsViews polymorphically, have a virtual destructor
virtual ~CCoinsView() {}
virtual ~CCoinsView() = default;

//! Estimate database size (0 if not implemented)
virtual size_t EstimateSize() const { return 0; }
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/muhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class MuHash3072

public:
/* The empty set. */
MuHash3072() noexcept {};
MuHash3072() noexcept = default;

/* A singleton with variable sized data in it. */
explicit MuHash3072(Span<const unsigned char> in) noexcept;
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/sha3.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SHA3_256
public:
static constexpr size_t OUTPUT_SIZE = 32;

SHA3_256() {}
SHA3_256() = default;
SHA3_256& Write(Span<const unsigned char> data);
SHA3_256& Finalize(Span<unsigned char> output);
SHA3_256& Reset();
Expand Down
2 changes: 1 addition & 1 deletion src/flatfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct FlatFilePos

SERIALIZE_METHODS(FlatFilePos, obj) { READWRITE(VARINT_MODE(obj.nFile, VarIntMode::NONNEGATIVE_SIGNED), VARINT(obj.nPos)); }

FlatFilePos() {}
FlatFilePos() = default;

FlatFilePos(int nFileIn, unsigned int nPosIn) :
nFile(nFileIn),
Expand Down
2 changes: 1 addition & 1 deletion src/headerssync.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct CompressedHeader {

class HeadersSyncState {
public:
~HeadersSyncState() {}
~HeadersSyncState() = default;

enum class State {
/** PRESYNC means the peer has not yet demonstrated their chain has
Expand Down
2 changes: 1 addition & 1 deletion src/httpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class HTTPClosure
{
public:
virtual void operator()() = 0;
virtual ~HTTPClosure() {}
virtual ~HTTPClosure() = default;
};

/** Event class. This can be used either as a cross-thread trigger or as a timer.
Expand Down
2 changes: 1 addition & 1 deletion src/index/disktxpos.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct CDiskTxPos : public FlatFilePos
CDiskTxPos(const FlatFilePos &blockIn, unsigned int nTxOffsetIn) : FlatFilePos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) {
}

CDiskTxPos() {}
CDiskTxPos() = default;
};

#endif // BITCOIN_INDEX_DISKTXPOS_H
6 changes: 3 additions & 3 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct BlockInfo {
class Chain
{
public:
virtual ~Chain() {}
virtual ~Chain() = default;

//! Get current chain height, not including genesis block (returns 0 if
//! chain only contains genesis block, nullopt if chain does not contain
Expand Down Expand Up @@ -309,7 +309,7 @@ class Chain
class Notifications
{
public:
virtual ~Notifications() {}
virtual ~Notifications() = default;
virtual void transactionAddedToMempool(const CTransactionRef& tx) {}
virtual void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) {}
virtual void blockConnected(ChainstateRole role, const BlockInfo& block) {}
Expand Down Expand Up @@ -371,7 +371,7 @@ class Chain
class ChainClient
{
public:
virtual ~ChainClient() {}
virtual ~ChainClient() = default;

//! Register rpcs.
virtual void registerRpcs() = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/echo.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace interfaces {
class Echo
{
public:
virtual ~Echo() {}
virtual ~Echo() = default;

//! Echo provided string.
virtual std::string echo(const std::string& echo) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace interfaces {
class Handler
{
public:
virtual ~Handler() {}
virtual ~Handler() = default;

//! Disconnect the handler.
virtual void disconnect() = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/mining.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace interfaces {
class Mining
{
public:
virtual ~Mining() {}
virtual ~Mining() = default;

//! If this chain is exclusively used for testing
virtual bool isTestChain() = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct BlockAndHeaderTipInfo
class ExternalSigner
{
public:
virtual ~ExternalSigner() {};
virtual ~ExternalSigner() = default;

//! Get signer display name
virtual std::string getName() = 0;
Expand All @@ -69,7 +69,7 @@ class ExternalSigner
class Node
{
public:
virtual ~Node() {}
virtual ~Node() = default;

//! Init logging.
virtual void initLogging() = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ using WalletValueMap = std::map<std::string, std::string>;
class Wallet
{
public:
virtual ~Wallet() {}
virtual ~Wallet() = default;

//! Encrypt wallet.
virtual bool encryptWallet(const SecureString& wallet_passphrase) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class CChainParams
static std::unique_ptr<const CChainParams> TestNet();

protected:
CChainParams() {}
CChainParams() = default;

Consensus::Params consensus;
MessageStartChars pchMessageStart;
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/notifications_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool IsInterrupted(const T& result)
class Notifications
{
public:
virtual ~Notifications(){};
virtual ~Notifications() = default;

[[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) { return {}; }
virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {}
Expand Down
2 changes: 1 addition & 1 deletion src/merkleblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class CMerkleBlock
// Create from a CBlock, matching the txids in the set
CMerkleBlock(const CBlock& block, const std::set<Txid>& txids) : CMerkleBlock{block, nullptr, &txids} {}

CMerkleBlock() {}
CMerkleBlock() = default;

SERIALIZE_METHODS(CMerkleBlock, obj) { READWRITE(obj.header, obj.txn); }

Expand Down
2 changes: 1 addition & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class CNetMessage
/** The Transport converts one connection's sent messages to wire bytes, and received bytes back. */
class Transport {
public:
virtual ~Transport() {}
virtual ~Transport() = default;

struct Info
{
Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
static std::unique_ptr<PeerManager> make(CConnman& connman, AddrMan& addrman,
BanMan* banman, ChainstateManager& chainman,
CTxMemPool& pool, node::Warnings& warnings, Options opts);
virtual ~PeerManager() { }
virtual ~PeerManager() = default;

/**
* Attempt to manually fetch block from a given peer. We must already have the header.
Expand Down
2 changes: 1 addition & 1 deletion src/net_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CBanEntry
int64_t nCreateTime{0};
int64_t nBanUntil{0};

CBanEntry() {}
CBanEntry() = default;

explicit CBanEntry(int64_t nCreateTimeIn)
: nCreateTime{nCreateTimeIn} {}
Expand Down
2 changes: 1 addition & 1 deletion src/policy/fees.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class CBlockPolicyEstimator : public CValidationInterface
{
unsigned int blockHeight{0};
unsigned int bucketIndex{0};
TxStatsInfo() {}
TxStatsInfo() = default;
};

// map of txids to information about that transaction
Expand Down
2 changes: 1 addition & 1 deletion src/prevector.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class prevector {
fill(item_ptr(0), first, last);
}

prevector() {}
prevector() = default;

explicit prevector(size_type n) {
resize(n);
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ struct CBlockLocator

std::vector<uint256> vHave;

CBlockLocator() {}
CBlockLocator() = default;

explicit CBlockLocator(std::vector<uint256>&& have) : vHave(std::move(have)) {}

Expand Down
6 changes: 3 additions & 3 deletions src/psbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ struct PSBTInput
void FillSignatureData(SignatureData& sigdata) const;
void FromSignatureData(const SignatureData& sigdata);
void Merge(const PSBTInput& input);
PSBTInput() {}
PSBTInput() = default;

template <typename Stream>
inline void Serialize(Stream& s) const {
Expand Down Expand Up @@ -726,7 +726,7 @@ struct PSBTOutput
void FillSignatureData(SignatureData& sigdata) const;
void FromSignatureData(const SignatureData& sigdata);
void Merge(const PSBTOutput& output);
PSBTOutput() {}
PSBTOutput() = default;

template <typename Stream>
inline void Serialize(Stream& s) const {
Expand Down Expand Up @@ -967,7 +967,7 @@ struct PartiallySignedTransaction
[[nodiscard]] bool Merge(const PartiallySignedTransaction& psbt);
bool AddInput(const CTxIn& txin, PSBTInput& psbtin);
bool AddOutput(const CTxOut& txout, const PSBTOutput& psbtout);
PartiallySignedTransaction() {}
PartiallySignedTransaction() = default;
explicit PartiallySignedTransaction(const CMutableTransaction& tx);
/**
* Finds the UTXO for a given input index
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactiondesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TransactionDesc: public QObject
static QString toHTML(interfaces::Node& node, interfaces::Wallet& wallet, TransactionRecord* rec, BitcoinUnit unit);

private:
TransactionDesc() {}
TransactionDesc() = default;

static QString FormatTxStatus(const interfaces::WalletTxStatus& status, bool inMempool);
};
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool RPCIsInWarmup(std::string *outStatus);
class RPCTimerBase
{
public:
virtual ~RPCTimerBase() {}
virtual ~RPCTimerBase() = default;
};

/**
Expand All @@ -57,7 +57,7 @@ class RPCTimerBase
class RPCTimerInterface
{
public:
virtual ~RPCTimerInterface() {}
virtual ~RPCTimerInterface() = default;
/** Implementation name */
virtual const char *Name() = 0;
/** Factory function for timers.
Expand Down
2 changes: 1 addition & 1 deletion src/script/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class BaseSignatureChecker
return false;
}

virtual ~BaseSignatureChecker() {}
virtual ~BaseSignatureChecker() = default;
};

/** Enum to specify what *TransactionSignatureChecker's behavior should be
Expand Down
2 changes: 1 addition & 1 deletion src/script/miniscript.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ struct InputStack {
//! Data elements.
std::vector<std::vector<unsigned char>> stack;
//! Construct an empty stack (valid).
InputStack() {}
InputStack() = default;
//! Construct a valid single-element stack (with an element up to 75 bytes).
InputStack(std::vector<unsigned char> in) : size(in.size() + 1), stack(Vector(std::move(in))) {}
//! Change availability
Expand Down
4 changes: 2 additions & 2 deletions src/script/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ class CScript : public CScriptBase
return *this;
}
public:
CScript() { }
CScript() = default;
CScript(const_iterator pbegin, const_iterator pend) : CScriptBase(pbegin, pend) { }
CScript(std::vector<unsigned char>::const_iterator pbegin, std::vector<unsigned char>::const_iterator pend) : CScriptBase(pbegin, pend) { }
CScript(const unsigned char* pbegin, const unsigned char* pend) : CScriptBase(pbegin, pend) { }
Expand Down Expand Up @@ -569,7 +569,7 @@ struct CScriptWitness
std::vector<std::vector<unsigned char> > stack;

// Some compilers complain without a default constructor
CScriptWitness() { }
CScriptWitness() = default;

bool IsNull() const { return stack.empty(); }

Expand Down
4 changes: 2 additions & 2 deletions src/script/sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct CMutableTransaction;
/** Interface for signature creators. */
class BaseSignatureCreator {
public:
virtual ~BaseSignatureCreator() {}
virtual ~BaseSignatureCreator() = default;
virtual const BaseSignatureChecker& Checker() const =0;

/** Create a singular (non-script) signature. */
Expand Down Expand Up @@ -89,7 +89,7 @@ struct SignatureData {
std::map<std::vector<uint8_t>, std::vector<uint8_t>> ripemd160_preimages; ///< Mapping from a RIPEMD160 hash to its preimage provided to solve a Script
std::map<std::vector<uint8_t>, std::vector<uint8_t>> hash160_preimages; ///< Mapping from a HASH160 hash to its preimage provided to solve a Script

SignatureData() {}
SignatureData() = default;
explicit SignatureData(const CScript& script) : scriptSig(script) {}
void MergeSignatureData(SignatureData sigdata);
};
Expand Down
2 changes: 1 addition & 1 deletion src/script/signingprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ std::optional<std::vector<std::tuple<int, std::vector<unsigned char>, int>>> Inf
class SigningProvider
{
public:
virtual ~SigningProvider() {}
virtual ~SigningProvider() = default;
virtual bool GetCScript(const CScriptID &scriptid, CScript& script) const { return false; }
virtual bool HaveCScript(const CScriptID &scriptid) const { return false; }
virtual bool GetPubKey(const CKeyID &address, CPubKey& pubkey) const { return false; }
Expand Down
Loading

0 comments on commit 3333bae

Please sign in to comment.