Changeset View
Changeset View
Standalone View
Standalone View
src/chain.h
Show All 24 Lines | |||||
/** | /** | ||||
* Timestamp window used as a grace period by code that compares external | * Timestamp window used as a grace period by code that compares external | ||||
* timestamps (such as timestamps passed to RPCs, or wallet key creation times) | * timestamps (such as timestamps passed to RPCs, or wallet key creation times) | ||||
* to block timestamps. This should be set at least as high as | * to block timestamps. This should be set at least as high as | ||||
* MAX_FUTURE_BLOCK_TIME. | * MAX_FUTURE_BLOCK_TIME. | ||||
*/ | */ | ||||
static const int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME; | static const int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME; | ||||
class CBlockFileInfo { | |||||
public: | |||||
//!< number of blocks stored in file | |||||
unsigned int nBlocks; | |||||
//!< number of used bytes of block file | |||||
unsigned int nSize; | |||||
//!< number of used bytes in the undo file | |||||
unsigned int nUndoSize; | |||||
//!< lowest height of block in file | |||||
unsigned int nHeightFirst; | |||||
//!< highest height of block in file | |||||
unsigned int nHeightLast; | |||||
//!< earliest time of block in file | |||||
uint64_t nTimeFirst; | |||||
//!< latest time of block in file | |||||
uint64_t nTimeLast; | |||||
ADD_SERIALIZE_METHODS; | |||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(VARINT(nBlocks)); | |||||
READWRITE(VARINT(nSize)); | |||||
READWRITE(VARINT(nUndoSize)); | |||||
READWRITE(VARINT(nHeightFirst)); | |||||
READWRITE(VARINT(nHeightLast)); | |||||
READWRITE(VARINT(nTimeFirst)); | |||||
READWRITE(VARINT(nTimeLast)); | |||||
} | |||||
void SetNull() { | |||||
nBlocks = 0; | |||||
nSize = 0; | |||||
nUndoSize = 0; | |||||
nHeightFirst = 0; | |||||
nHeightLast = 0; | |||||
nTimeFirst = 0; | |||||
nTimeLast = 0; | |||||
} | |||||
CBlockFileInfo() { SetNull(); } | |||||
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; | |||||
} | |||||
} | |||||
}; | |||||
struct CDiskBlockPos { | struct CDiskBlockPos { | ||||
int nFile; | int nFile; | ||||
unsigned int nPos; | unsigned int nPos; | ||||
ADD_SERIALIZE_METHODS; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
▲ Show 20 Lines • Show All 549 Lines • Show Last 20 Lines |