Bitcoin ABC 0.30.7
P2P Digital Currency
blockfileinfo.h
Go to the documentation of this file.
1// Copyright (c) 2018-2020 The Bitcoin developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_BLOCKFILEINFO_H
6#define BITCOIN_BLOCKFILEINFO_H
7
8#include <serialize.h>
9
10#include <cstdint>
11#include <string>
12
14public:
16 unsigned int nBlocks;
18 unsigned int nSize;
20 unsigned int nUndoSize;
22 unsigned int nHeightFirst;
24 unsigned int nHeightLast;
26 uint64_t nTimeFirst;
28 uint64_t nTimeLast;
29
31 READWRITE(VARINT(obj.nBlocks));
32 READWRITE(VARINT(obj.nSize));
33 READWRITE(VARINT(obj.nUndoSize));
34 READWRITE(VARINT(obj.nHeightFirst));
35 READWRITE(VARINT(obj.nHeightLast));
36 READWRITE(VARINT(obj.nTimeFirst));
37 READWRITE(VARINT(obj.nTimeLast));
38 }
39
40 void SetNull() {
41 nBlocks = 0;
42 nSize = 0;
43 nUndoSize = 0;
44 nHeightFirst = 0;
45 nHeightLast = 0;
46 nTimeFirst = 0;
47 nTimeLast = 0;
48 }
49
51
52 std::string ToString() const;
53
55 void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn) {
56 if (nBlocks == 0 || nHeightFirst > nHeightIn) {
57 nHeightFirst = nHeightIn;
58 }
59 if (nBlocks == 0 || nTimeFirst > nTimeIn) {
60 nTimeFirst = nTimeIn;
61 }
62 nBlocks++;
63 if (nHeightIn > nHeightLast) {
64 nHeightLast = nHeightIn;
65 }
66 if (nTimeIn > nTimeLast) {
67 nTimeLast = nTimeIn;
68 }
69 }
70};
71
72#endif // BITCOIN_BLOCKFILEINFO_H
uint64_t nTimeFirst
earliest time of block in file
Definition: blockfileinfo.h:26
uint64_t nTimeLast
latest time of block in file
Definition: blockfileinfo.h:28
std::string ToString() const
void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn)
update statistics (does not update nSize)
Definition: blockfileinfo.h:55
unsigned int nHeightFirst
lowest height of block in file
Definition: blockfileinfo.h:22
unsigned int nHeightLast
highest height of block in file
Definition: blockfileinfo.h:24
unsigned int nUndoSize
number of used bytes in the undo file
Definition: blockfileinfo.h:20
unsigned int nBlocks
number of blocks stored in file
Definition: blockfileinfo.h:16
SERIALIZE_METHODS(CBlockFileInfo, obj)
Definition: blockfileinfo.h:30
unsigned int nSize
number of used bytes of block file
Definition: blockfileinfo.h:18
#define VARINT(obj)
Definition: serialize.h:579
#define READWRITE(...)
Definition: serialize.h:166