mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
style: Use 4 spaces for indendation, not 5
Also, other whitespace fixes in the touched file. Can be trivially reviewed with "--ignore-all-space --word-diff-regex=. -U0".
This commit is contained in:
parent
fada66fc2c
commit
faf2614f60
1 changed files with 67 additions and 53 deletions
42
src/chain.h
42
src/chain.h
|
@ -59,7 +59,8 @@ public:
|
||||||
READWRITE(VARINT(obj.nTimeLast));
|
READWRITE(VARINT(obj.nTimeLast));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetNull() {
|
void SetNull()
|
||||||
|
{
|
||||||
nBlocks = 0;
|
nBlocks = 0;
|
||||||
nSize = 0;
|
nSize = 0;
|
||||||
nUndoSize = 0;
|
nUndoSize = 0;
|
||||||
|
@ -69,14 +70,16 @@ public:
|
||||||
nTimeLast = 0;
|
nTimeLast = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBlockFileInfo() {
|
CBlockFileInfo()
|
||||||
|
{
|
||||||
SetNull();
|
SetNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
|
|
||||||
/** update statistics (does not update nSize) */
|
/** update statistics (does not update nSize) */
|
||||||
void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn) {
|
void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn)
|
||||||
|
{
|
||||||
if (nBlocks == 0 || nHeightFirst > nHeightIn)
|
if (nBlocks == 0 || nHeightFirst > nHeightIn)
|
||||||
nHeightFirst = nHeightIn;
|
nHeightFirst = nHeightIn;
|
||||||
if (nBlocks == 0 || nTimeFirst > nTimeIn)
|
if (nBlocks == 0 || nTimeFirst > nTimeIn)
|
||||||
|
@ -220,7 +223,8 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatFilePos GetBlockPos() const {
|
FlatFilePos GetBlockPos() const
|
||||||
|
{
|
||||||
FlatFilePos ret;
|
FlatFilePos ret;
|
||||||
if (nStatus & BLOCK_HAVE_DATA) {
|
if (nStatus & BLOCK_HAVE_DATA) {
|
||||||
ret.nFile = nFile;
|
ret.nFile = nFile;
|
||||||
|
@ -229,7 +233,8 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatFilePos GetUndoPos() const {
|
FlatFilePos GetUndoPos() const
|
||||||
|
{
|
||||||
FlatFilePos ret;
|
FlatFilePos ret;
|
||||||
if (nStatus & BLOCK_HAVE_UNDO) {
|
if (nStatus & BLOCK_HAVE_UNDO) {
|
||||||
ret.nFile = nFile;
|
ret.nFile = nFile;
|
||||||
|
@ -353,11 +358,13 @@ class CDiskBlockIndex : public CBlockIndex
|
||||||
public:
|
public:
|
||||||
uint256 hashPrev;
|
uint256 hashPrev;
|
||||||
|
|
||||||
CDiskBlockIndex() {
|
CDiskBlockIndex()
|
||||||
|
{
|
||||||
hashPrev = uint256();
|
hashPrev = uint256();
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit CDiskBlockIndex(const CBlockIndex* pindex) : CBlockIndex(*pindex) {
|
explicit CDiskBlockIndex(const CBlockIndex* pindex) : CBlockIndex(*pindex)
|
||||||
|
{
|
||||||
hashPrev = (pprev ? pprev->GetBlockHash() : uint256());
|
hashPrev = (pprev ? pprev->GetBlockHash() : uint256());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +414,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** An in-memory indexed chain of blocks. */
|
/** An in-memory indexed chain of blocks. */
|
||||||
class CChain {
|
class CChain
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
std::vector<CBlockIndex*> vChain;
|
std::vector<CBlockIndex*> vChain;
|
||||||
|
|
||||||
|
@ -417,29 +425,34 @@ public:
|
||||||
CChain& operator=(const CChain&) = delete;
|
CChain& operator=(const CChain&) = delete;
|
||||||
|
|
||||||
/** Returns the index entry for the genesis block of this chain, or nullptr if none. */
|
/** Returns the index entry for the genesis block of this chain, or nullptr if none. */
|
||||||
CBlockIndex *Genesis() const {
|
CBlockIndex* Genesis() const
|
||||||
|
{
|
||||||
return vChain.size() > 0 ? vChain[0] : nullptr;
|
return vChain.size() > 0 ? vChain[0] : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the index entry for the tip of this chain, or nullptr if none. */
|
/** Returns the index entry for the tip of this chain, or nullptr if none. */
|
||||||
CBlockIndex *Tip() const {
|
CBlockIndex* Tip() const
|
||||||
|
{
|
||||||
return vChain.size() > 0 ? vChain[vChain.size() - 1] : nullptr;
|
return vChain.size() > 0 ? vChain[vChain.size() - 1] : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the index entry at a particular height in this chain, or nullptr if no such height exists. */
|
/** Returns the index entry at a particular height in this chain, or nullptr if no such height exists. */
|
||||||
CBlockIndex *operator[](int nHeight) const {
|
CBlockIndex* operator[](int nHeight) const
|
||||||
|
{
|
||||||
if (nHeight < 0 || nHeight >= (int)vChain.size())
|
if (nHeight < 0 || nHeight >= (int)vChain.size())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return vChain[nHeight];
|
return vChain[nHeight];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Efficiently check whether a block is present in this chain. */
|
/** Efficiently check whether a block is present in this chain. */
|
||||||
bool Contains(const CBlockIndex *pindex) const {
|
bool Contains(const CBlockIndex* pindex) const
|
||||||
|
{
|
||||||
return (*this)[pindex->nHeight] == pindex;
|
return (*this)[pindex->nHeight] == pindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip. */
|
/** Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip. */
|
||||||
CBlockIndex *Next(const CBlockIndex *pindex) const {
|
CBlockIndex* Next(const CBlockIndex* pindex) const
|
||||||
|
{
|
||||||
if (Contains(pindex))
|
if (Contains(pindex))
|
||||||
return (*this)[pindex->nHeight + 1];
|
return (*this)[pindex->nHeight + 1];
|
||||||
else
|
else
|
||||||
|
@ -447,7 +460,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the maximal height in the chain. Is equal to chain.Tip() ? chain.Tip()->nHeight : -1. */
|
/** Return the maximal height in the chain. Is equal to chain.Tip() ? chain.Tip()->nHeight : -1. */
|
||||||
int Height() const {
|
int Height() const
|
||||||
|
{
|
||||||
return vChain.size() - 1;
|
return vChain.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue