mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-01 03:01:05 +00:00
move-only: Move CBlockFileInfo to kernel namespace
Also, move it to the blockstorage module, because it is only used inside that module. Can be reviewed with the git option --color-moved=dimmed-zebra
This commit is contained in:
parent
fa2bbc9e4c
commit
fa01f38e53
@ -6,12 +6,6 @@
|
||||
#include <chain.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/check.h>
|
||||
#include <util/time.h>
|
||||
|
||||
std::string CBlockFileInfo::ToString() const
|
||||
{
|
||||
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, FormatISO8601Date(nTimeFirst), FormatISO8601Date(nTimeLast));
|
||||
}
|
||||
|
||||
std::string CBlockIndex::ToString() const
|
||||
{
|
||||
|
||||
41
src/chain.h
41
src/chain.h
@ -47,47 +47,6 @@ static constexpr int32_t SEQ_ID_INIT_FROM_DISK = 1;
|
||||
*/
|
||||
static constexpr int64_t MAX_BLOCK_TIME_GAP = 90 * 60;
|
||||
|
||||
class CBlockFileInfo
|
||||
{
|
||||
public:
|
||||
unsigned int nBlocks{}; //!< number of blocks stored in file
|
||||
unsigned int nSize{}; //!< number of used bytes of block file
|
||||
unsigned int nUndoSize{}; //!< number of used bytes in the undo file
|
||||
unsigned int nHeightFirst{}; //!< lowest height of block in file
|
||||
unsigned int nHeightLast{}; //!< highest height of block in file
|
||||
uint64_t nTimeFirst{}; //!< earliest time of block in file
|
||||
uint64_t nTimeLast{}; //!< latest time of block in file
|
||||
|
||||
SERIALIZE_METHODS(CBlockFileInfo, obj)
|
||||
{
|
||||
READWRITE(VARINT(obj.nBlocks));
|
||||
READWRITE(VARINT(obj.nSize));
|
||||
READWRITE(VARINT(obj.nUndoSize));
|
||||
READWRITE(VARINT(obj.nHeightFirst));
|
||||
READWRITE(VARINT(obj.nHeightLast));
|
||||
READWRITE(VARINT(obj.nTimeFirst));
|
||||
READWRITE(VARINT(obj.nTimeLast));
|
||||
}
|
||||
|
||||
CBlockFileInfo() = default;
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
/** update statistics (does not update nSize) */
|
||||
void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn)
|
||||
{
|
||||
if (nBlocks == 0 || nHeightFirst > nHeightIn)
|
||||
nHeightFirst = nHeightIn;
|
||||
if (nBlocks == 0 || nTimeFirst > nTimeIn)
|
||||
nTimeFirst = nTimeIn;
|
||||
nBlocks++;
|
||||
if (nHeightIn > nHeightLast)
|
||||
nHeightLast = nHeightIn;
|
||||
if (nTimeIn > nTimeLast)
|
||||
nTimeLast = nTimeIn;
|
||||
}
|
||||
};
|
||||
|
||||
enum BlockStatus : uint32_t {
|
||||
//! Unused.
|
||||
BLOCK_VALID_UNKNOWN = 0,
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include <util/signalinterrupt.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/syserror.h>
|
||||
#include <util/time.h>
|
||||
#include <util/translation.h>
|
||||
#include <validation.h>
|
||||
|
||||
@ -151,6 +152,11 @@ bool BlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams, s
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string CBlockFileInfo::ToString() const
|
||||
{
|
||||
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, FormatISO8601Date(nTimeFirst), FormatISO8601Date(nTimeLast));
|
||||
}
|
||||
} // namespace kernel
|
||||
|
||||
namespace node {
|
||||
|
||||
@ -47,6 +47,47 @@ class SignalInterrupt;
|
||||
} // namespace util
|
||||
|
||||
namespace kernel {
|
||||
class CBlockFileInfo
|
||||
{
|
||||
public:
|
||||
unsigned int nBlocks{}; //!< number of blocks stored in file
|
||||
unsigned int nSize{}; //!< number of used bytes of block file
|
||||
unsigned int nUndoSize{}; //!< number of used bytes in the undo file
|
||||
unsigned int nHeightFirst{}; //!< lowest height of block in file
|
||||
unsigned int nHeightLast{}; //!< highest height of block in file
|
||||
uint64_t nTimeFirst{}; //!< earliest time of block in file
|
||||
uint64_t nTimeLast{}; //!< latest time of block in file
|
||||
|
||||
SERIALIZE_METHODS(CBlockFileInfo, obj)
|
||||
{
|
||||
READWRITE(VARINT(obj.nBlocks));
|
||||
READWRITE(VARINT(obj.nSize));
|
||||
READWRITE(VARINT(obj.nUndoSize));
|
||||
READWRITE(VARINT(obj.nHeightFirst));
|
||||
READWRITE(VARINT(obj.nHeightLast));
|
||||
READWRITE(VARINT(obj.nTimeFirst));
|
||||
READWRITE(VARINT(obj.nTimeLast));
|
||||
}
|
||||
|
||||
CBlockFileInfo() = default;
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
/** update statistics (does not update nSize) */
|
||||
void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn)
|
||||
{
|
||||
if (nBlocks == 0 || nHeightFirst > nHeightIn)
|
||||
nHeightFirst = nHeightIn;
|
||||
if (nBlocks == 0 || nTimeFirst > nTimeIn)
|
||||
nTimeFirst = nTimeIn;
|
||||
nBlocks++;
|
||||
if (nHeightIn > nHeightLast)
|
||||
nHeightLast = nHeightIn;
|
||||
if (nTimeIn > nTimeLast)
|
||||
nTimeLast = nTimeIn;
|
||||
}
|
||||
};
|
||||
|
||||
/** Access to the block database (blocks/index/) */
|
||||
class BlockTreeDB : public CDBWrapper
|
||||
{
|
||||
@ -65,6 +106,7 @@ public:
|
||||
} // namespace kernel
|
||||
|
||||
namespace node {
|
||||
using kernel::CBlockFileInfo;
|
||||
using kernel::BlockTreeDB;
|
||||
|
||||
/** The pre-allocation chunk size for blk?????.dat files (since 0.8) */
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include <test/util/logging.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
using kernel::CBlockFileInfo;
|
||||
using node::STORAGE_HEADER_BYTES;
|
||||
using node::BlockManager;
|
||||
using node::KernelNotifications;
|
||||
|
||||
@ -12,6 +12,8 @@
|
||||
#include <txdb.h>
|
||||
#include <validation.h>
|
||||
|
||||
using kernel::CBlockFileInfo;
|
||||
|
||||
namespace {
|
||||
|
||||
const BasicTestingSetup* g_setup;
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include <net.h>
|
||||
#include <netbase.h>
|
||||
#include <netgroup.h>
|
||||
#include <node/blockstorage.h>
|
||||
#include <node/utxo_snapshot.h>
|
||||
#include <primitives/block.h>
|
||||
#include <protocol.h>
|
||||
@ -34,6 +35,7 @@
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
|
||||
using kernel::CBlockFileInfo;
|
||||
using node::SnapshotMetadata;
|
||||
|
||||
namespace {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user