From 3f40bc3293e197f08788673da3b68e6cea9c67bf Mon Sep 17 00:00:00 2001 From: svost Date: Thu, 10 Feb 2022 17:37:06 +0300 Subject: [PATCH] Includes cleanup --- src/bitcoinrpc.h | 11 ++++------- src/checkpoints.cpp | 35 ++++++++++++++++++++++++++++++++++- src/checkpoints.h | 46 ++++++++++------------------------------------ src/db.cpp | 3 +-- src/db.h | 6 +++++- src/kernel.cpp | 2 +- src/kernel.h | 5 +++-- src/kernel_worker.cpp | 3 --- src/kernel_worker.h | 7 ++++++- src/main.cpp | 4 ++-- src/main.h | 3 +-- src/miner.cpp | 1 + src/noui.cpp | 3 +-- src/txdb-leveldb.cpp | 10 +++------- src/txdb-leveldb.h | 10 +++++++++- 15 files changed, 81 insertions(+), 68 deletions(-) diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h index d0a3712..7c5bd87 100644 --- a/src/bitcoinrpc.h +++ b/src/bitcoinrpc.h @@ -6,18 +6,15 @@ #ifndef _BITCOINRPC_H_ #define _BITCOINRPC_H_ 1 -#include -#include -#include - -class CBlockIndex; +#include "checkpoints.h" #include "json/json_spirit_reader_template.h" #include "json/json_spirit_writer_template.h" #include "json/json_spirit_utils.h" -#include "util.h" -#include "checkpoints.h" +#include +#include +#include // HTTP status codes enum HTTPStatusCode diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 396fb24..ab3c7f7 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -5,7 +5,6 @@ #include "checkpoints.h" #include "main.h" #include "txdb-leveldb.h" -#include "uint256.h" #include @@ -383,6 +382,40 @@ const std::string CSyncCheckpoint::strMasterPubKey = "04a51b735f816de4ec3f891d5b std::string CSyncCheckpoint::strMasterPrivKey = ""; // ppcoin: verify signature of sync-checkpoint message +CSyncCheckpoint::CSyncCheckpoint() +{ + SetNull(); +} + +void CSyncCheckpoint::SetNull() +{ + CUnsignedSyncCheckpoint::SetNull(); + vchMsg.clear(); + vchSig.clear(); +} + +bool CSyncCheckpoint::IsNull() const +{ + return (hashCheckpoint == 0); +} + +uint256 CSyncCheckpoint::GetHash() const +{ + return SerializeHash(*this); +} + +bool CSyncCheckpoint::RelayTo(CNode *pnode) const +{ + // returns true if wasn't already sent + if (pnode->hashCheckpointKnown != hashCheckpoint) + { + pnode->hashCheckpointKnown = hashCheckpoint; + pnode->PushMessage("checkpoint", *this); + return true; + } + return false; +} + bool CSyncCheckpoint::CheckSignature() { CPubKey key(ParseHex(CSyncCheckpoint::strMasterPubKey)); diff --git a/src/checkpoints.h b/src/checkpoints.h index a2b9731..701e253 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -4,9 +4,11 @@ #ifndef BITCOIN_CHECKPOINT_H #define BITCOIN_CHECKPOINT_H -#include #include "util.h" -#include "net.h" +#include "sync.h" +#include "uint256.h" + +#include // max 1 hour before latest block static const int64_t CHECKPOINT_MAX_SPAN = nOneHour; @@ -17,9 +19,9 @@ static const int64_t CHECKPOINT_MAX_SPAN = nOneHour; #undef ADVISORY #endif -class uint256; class CBlockIndex; class CSyncCheckpoint; +class CNode; /** Block-chain checkpoints are compiled-in sanity checks. * They are updated every release or three. @@ -111,10 +113,7 @@ public: std::vector vchMsg; std::vector vchSig; - CSyncCheckpoint() - { - SetNull(); - } + CSyncCheckpoint(); IMPLEMENT_SERIALIZE ( @@ -122,35 +121,10 @@ public: READWRITE(vchSig); ) - void SetNull() - { - CUnsignedSyncCheckpoint::SetNull(); - vchMsg.clear(); - vchSig.clear(); - } - - bool IsNull() const - { - return (hashCheckpoint == 0); - } - - uint256 GetHash() const - { - return SerializeHash(*this); - } - - bool RelayTo(CNode* pnode) const - { - // returns true if wasn't already sent - if (pnode->hashCheckpointKnown != hashCheckpoint) - { - pnode->hashCheckpointKnown = hashCheckpoint; - pnode->PushMessage("checkpoint", *this); - return true; - } - return false; - } - + void SetNull(); + bool IsNull() const; + uint256 GetHash() const; + bool RelayTo(CNode* pnode) const; bool CheckSignature(); bool ProcessSyncCheckpoint(CNode* pfrom); }; diff --git a/src/db.cpp b/src/db.cpp index cc1f3e9..946454d 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -4,10 +4,9 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "db.h" -#include "net.h" #include "util.h" #include "main.h" -#include "interface.h" + #include #include diff --git a/src/db.h b/src/db.h index 07bb2b0..2cccbc6 100644 --- a/src/db.h +++ b/src/db.h @@ -5,7 +5,11 @@ #ifndef BITCOIN_DB_H #define BITCOIN_DB_H -#include "main.h" +#include "sync.h" +#include "serialize.h" +#include "script.h" + +#include #include #include diff --git a/src/kernel.cpp b/src/kernel.cpp index a2a0e0e..639547c 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -6,10 +6,10 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "kernel.h" +#include "wallet.h" #include "kernel_worker.h" #include "txdb-leveldb.h" -extern unsigned int nStakeMaxAge; extern unsigned int nStakeTargetSpacing; using namespace std; diff --git a/src/kernel.h b/src/kernel.h index 464e401..e41b9a4 100644 --- a/src/kernel.h +++ b/src/kernel.h @@ -5,7 +5,8 @@ #define PPCOIN_KERNEL_H #include "main.h" -#include "wallet.h" + +extern unsigned int nStakeMaxAge; // ChainDB upgrade time extern unsigned int nModifierUpgradeTime; @@ -56,4 +57,4 @@ inline int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd) return std::min(nIntervalEnd - nIntervalBeginning - nStakeMinAge, (int64_t)nStakeMaxAge); } -#endif // PPCOIN_KERNEL_H \ No newline at end of file +#endif // PPCOIN_KERNEL_H diff --git a/src/kernel_worker.cpp b/src/kernel_worker.cpp index 244769b..1c66963 100644 --- a/src/kernel_worker.cpp +++ b/src/kernel_worker.cpp @@ -1,8 +1,5 @@ -#include -#include #include "uint256.h" -#include "bignum.h" #include "kernel.h" #include "kernel_worker.h" diff --git a/src/kernel_worker.h b/src/kernel_worker.h index 93ee62c..594ab35 100644 --- a/src/kernel_worker.h +++ b/src/kernel_worker.h @@ -1,8 +1,13 @@ #ifndef NOVACOIN_KERNELWORKER_H #define NOVACOIN_KERNELWORKER_H +#include "bignum.h" + +#include #include +class uint256; + class KernelWorker { public: @@ -33,4 +38,4 @@ private: // Scan given kernel for solutions bool ScanKernelBackward(unsigned char *kernel, uint32_t nBits, uint32_t nInputTxTime, int64_t nValueIn, std::pair &SearchInterval, std::pair &solution); -#endif // NOVACOIN_KERNELWORKER_H \ No newline at end of file +#endif // NOVACOIN_KERNELWORKER_H diff --git a/src/main.cpp b/src/main.cpp index 7925ce1..8cf70d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include "main.h" #include "alert.h" #include "checkpoints.h" #include "db.h" @@ -11,11 +12,10 @@ #include "interface.h" #include "checkqueue.h" #include "kernel.h" + #include #include -#include "main.h" - #include using namespace std; diff --git a/src/main.h b/src/main.h index b75dd8d..b3bff19 100644 --- a/src/main.h +++ b/src/main.h @@ -5,14 +5,13 @@ #ifndef BITCOIN_MAIN_H #define BITCOIN_MAIN_H -#include - #include "timestamps.h" #include "sync.h" #include "net.h" #include "script.h" #include "scrypt.h" +#include #include #include #include diff --git a/src/miner.cpp b/src/miner.cpp index 4818e4c..d4a2cab 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -8,6 +8,7 @@ #include "miner.h" #include "kernel.h" #include "kernel_worker.h" +#include "wallet.h" ////////////////////////////////////////////////////////////////////////////// diff --git a/src/noui.cpp b/src/noui.cpp index 91fb8d0..8643715 100644 --- a/src/noui.cpp +++ b/src/noui.cpp @@ -2,9 +2,8 @@ // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include "interface.h" -#include "init.h" -#include "bitcoinrpc.h" #include diff --git a/src/txdb-leveldb.cpp b/src/txdb-leveldb.cpp index a6282e8..5ccf07d 100644 --- a/src/txdb-leveldb.cpp +++ b/src/txdb-leveldb.cpp @@ -3,7 +3,9 @@ // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. -#include +#include "txdb-leveldb.h" +#include "kernel.h" +#include "checkpoints.h" #include #include @@ -14,12 +16,6 @@ #include #include -#include "kernel.h" -#include "checkpoints.h" -#include "txdb-leveldb.h" -#include "util.h" -#include "main.h" - using namespace std; leveldb::DB *txdb; // global pointer for LevelDB object instance diff --git a/src/txdb-leveldb.h b/src/txdb-leveldb.h index 07c7088..8f0c995 100644 --- a/src/txdb-leveldb.h +++ b/src/txdb-leveldb.h @@ -6,7 +6,7 @@ #ifndef BITCOIN_LEVELDB_H #define BITCOIN_LEVELDB_H -#include "main.h" +#include "serialize.h" #include #include @@ -15,6 +15,14 @@ #include #include +class CBigNum; +class CDiskBlockIndex; +class COutPoint; +class CTxIndex; +class CTransaction; +class uint256; +class CDiskTxPos; + // Class that provides access to a LevelDB. Note that this class is frequently // instantiated on the stack and then destroyed again, so instantiation has to // be very cheap. Unfortunately that means, a CTxDB instance is actually just a -- 1.7.1