Skip to content

Commit 7eb0667

Browse files
committed
Merge pull request #5403
c5b390b Make comments in main an init doxygen compatible (Michael Ford)
2 parents 1333442 + c5b390b commit 7eb0667

File tree

4 files changed

+189
-160
lines changed

4 files changed

+189
-160
lines changed

src/init.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) 2009-2010 Satoshi Nakamoto
22
// Copyright (c) 2009-2014 The Bitcoin developers
3-
// Distributed under the MIT/X11 software license, see the accompanying
3+
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
#if defined(HAVE_CONFIG_H)
@@ -60,7 +60,7 @@ bool fFeeEstimatesInitialized = false;
6060
#define MIN_CORE_FILEDESCRIPTORS 150
6161
#endif
6262

63-
// Used to pass flags to the Bind() function
63+
/** Used to pass flags to the Bind() function */
6464
enum BindFlags {
6565
BF_NONE = 0,
6666
BF_EXPLICIT = (1U << 0),
@@ -175,9 +175,9 @@ void Shutdown()
175175
LogPrintf("%s: done\n", __func__);
176176
}
177177

178-
//
179-
// Signal handlers are very limited in what they are allowed to do, so:
180-
//
178+
/**
179+
* Signal handlers are very limited in what they are allowed to do, so:
180+
*/
181181
void HandleSIGTERM(int)
182182
{
183183
fRequestShutdown = true;

src/init.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) 2009-2010 Satoshi Nakamoto
2-
// Copyright (c) 2009-2013 The Bitcoin developers
3-
// Distributed under the MIT/X11 software license, see the accompanying
2+
// Copyright (c) 2009-2014 The Bitcoin developers
3+
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
#ifndef BITCOIN_INIT_H
@@ -22,7 +22,7 @@ bool ShutdownRequested();
2222
void Shutdown();
2323
bool AppInit2(boost::thread_group& threadGroup);
2424

25-
/* The help message mode determines what help message to show */
25+
/** The help message mode determines what help message to show */
2626
enum HelpMessageMode {
2727
HMM_BITCOIND,
2828
HMM_BITCOIN_QT

src/main.cpp

Lines changed: 82 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) 2009-2010 Satoshi Nakamoto
22
// Copyright (c) 2009-2014 The Bitcoin developers
3-
// Distributed under the MIT/X11 software license, see the accompanying
3+
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
#include "main.h"
@@ -33,9 +33,9 @@ using namespace std;
3333
# error "Bitcoin cannot be compiled without assertions."
3434
#endif
3535

36-
//
37-
// Global state
38-
//
36+
/**
37+
* Global state
38+
*/
3939

4040
CCriticalSection cs_main;
4141

@@ -66,7 +66,7 @@ map<uint256, COrphanTx> mapOrphanTransactions;
6666
map<uint256, set<uint256> > mapOrphanTransactionsByPrev;
6767
void EraseOrphansFor(NodeId peer);
6868

69-
// Constant stuff for coinbase transactions we create:
69+
/** Constant stuff for coinbase transactions we create: */
7070
CScript COINBASE_FLAGS;
7171

7272
const string strMessageMagic = "Bitcoin Signed Message:\n";
@@ -97,44 +97,49 @@ namespace {
9797

9898
CBlockIndex *pindexBestInvalid;
9999

100-
// The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS or better that are at least
101-
// as good as our current tip. Entries may be failed, though.
100+
/**
101+
* The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS or better that are at least
102+
* as good as our current tip. Entries may be failed, though.
103+
*/
102104
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexCandidates;
103-
// Number of nodes with fSyncStarted.
105+
/** Number of nodes with fSyncStarted. */
104106
int nSyncStarted = 0;
105-
// All pairs A->B, where A (or one if its ancestors) misses transactions, but B has transactions.
107+
/** All pairs A->B, where A (or one if its ancestors) misses transactions, but B has transactions. */
106108
multimap<CBlockIndex*, CBlockIndex*> mapBlocksUnlinked;
107109

108110
CCriticalSection cs_LastBlockFile;
109111
std::vector<CBlockFileInfo> vinfoBlockFile;
110112
int nLastBlockFile = 0;
111113

112-
// Every received block is assigned a unique and increasing identifier, so we
113-
// know which one to give priority in case of a fork.
114+
/**
115+
* Every received block is assigned a unique and increasing identifier, so we
116+
* know which one to give priority in case of a fork.
117+
*/
114118
CCriticalSection cs_nBlockSequenceId;
115-
// Blocks loaded from disk are assigned id 0, so start the counter at 1.
119+
/** Blocks loaded from disk are assigned id 0, so start the counter at 1. */
116120
uint32_t nBlockSequenceId = 1;
117121

118-
// Sources of received blocks, to be able to send them reject messages or ban
119-
// them, if processing happens afterwards. Protected by cs_main.
122+
/**
123+
* Sources of received blocks, to be able to send them reject messages or ban
124+
* them, if processing happens afterwards. Protected by cs_main.
125+
*/
120126
map<uint256, NodeId> mapBlockSource;
121127

122-
// Blocks that are in flight, and that are in the queue to be downloaded.
123-
// Protected by cs_main.
128+
/** Blocks that are in flight, and that are in the queue to be downloaded. Protected by cs_main. */
124129
struct QueuedBlock {
125130
uint256 hash;
126-
CBlockIndex *pindex; // Optional.
127-
int64_t nTime; // Time of "getdata" request in microseconds.
131+
CBlockIndex *pindex; //! Optional.
132+
int64_t nTime; //! Time of "getdata" request in microseconds.
128133
};
129134
map<uint256, pair<NodeId, list<QueuedBlock>::iterator> > mapBlocksInFlight;
130135

131-
// Number of preferrable block download peers.
136+
/** Number of preferable block download peers. */
132137
int nPreferredDownload = 0;
133138

134-
// Dirty block index entries.
139+
/** Dirty block index entries. */
135140
set<CBlockIndex*> setDirtyBlockIndex;
136141

137-
// Dirty block file entries.
142+
/** Dirty block file entries. */
138143
set<int> setDirtyFileInfo;
139144
} // anon namespace
140145

@@ -148,19 +153,19 @@ namespace {
148153
namespace {
149154

150155
struct CMainSignals {
151-
// Notifies listeners of updated transaction data (transaction, and optionally the block it is found in.
156+
/** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
152157
boost::signals2::signal<void (const CTransaction &, const CBlock *)> SyncTransaction;
153-
// Notifies listeners of an erased transaction (currently disabled, requires transaction replacement).
158+
/** Notifies listeners of an erased transaction (currently disabled, requires transaction replacement). */
154159
boost::signals2::signal<void (const uint256 &)> EraseTransaction;
155-
// Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible).
160+
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
156161
boost::signals2::signal<void (const uint256 &)> UpdatedTransaction;
157-
// Notifies listeners of a new active block chain.
162+
/** Notifies listeners of a new active block chain. */
158163
boost::signals2::signal<void (const CBlockLocator &)> SetBestChain;
159-
// Notifies listeners about an inventory item being seen on the network.
164+
/** Notifies listeners about an inventory item being seen on the network. */
160165
boost::signals2::signal<void (const uint256 &)> Inventory;
161-
// Tells listeners to broadcast their data.
166+
/** Tells listeners to broadcast their data. */
162167
boost::signals2::signal<void ()> Broadcast;
163-
// Notifies listeners of a block validation result
168+
/** Notifies listeners of a block validation result */
164169
boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked;
165170
} g_signals;
166171

@@ -213,32 +218,34 @@ struct CBlockReject {
213218
uint256 hashBlock;
214219
};
215220

216-
// Maintain validation-specific state about nodes, protected by cs_main, instead
217-
// by CNode's own locks. This simplifies asynchronous operation, where
218-
// processing of incoming data is done after the ProcessMessage call returns,
219-
// and we're no longer holding the node's locks.
221+
/**
222+
* Maintain validation-specific state about nodes, protected by cs_main, instead
223+
* by CNode's own locks. This simplifies asynchronous operation, where
224+
* processing of incoming data is done after the ProcessMessage call returns,
225+
* and we're no longer holding the node's locks.
226+
*/
220227
struct CNodeState {
221-
// Accumulated misbehaviour score for this peer.
228+
//! Accumulated misbehaviour score for this peer.
222229
int nMisbehavior;
223-
// Whether this peer should be disconnected and banned (unless whitelisted).
230+
//! Whether this peer should be disconnected and banned (unless whitelisted).
224231
bool fShouldBan;
225-
// String name of this peer (debugging/logging purposes).
232+
//! String name of this peer (debugging/logging purposes).
226233
std::string name;
227-
// List of asynchronously-determined block rejections to notify this peer about.
234+
//! List of asynchronously-determined block rejections to notify this peer about.
228235
std::vector<CBlockReject> rejects;
229-
// The best known block we know this peer has announced.
236+
//! The best known block we know this peer has announced.
230237
CBlockIndex *pindexBestKnownBlock;
231-
// The hash of the last unknown block this peer has announced.
238+
//! The hash of the last unknown block this peer has announced.
232239
uint256 hashLastUnknownBlock;
233-
// The last full block we both have.
240+
//! The last full block we both have.
234241
CBlockIndex *pindexLastCommonBlock;
235-
// Whether we've started headers synchronization with this peer.
242+
//! Whether we've started headers synchronization with this peer.
236243
bool fSyncStarted;
237-
// Since when we're stalling block download progress (in microseconds), or 0.
244+
//! Since when we're stalling block download progress (in microseconds), or 0.
238245
int64_t nStallingSince;
239246
list<QueuedBlock> vBlocksInFlight;
240247
int nBlocksInFlight;
241-
// Whether we consider this a preferred download peer.
248+
//! Whether we consider this a preferred download peer.
242249
bool fPreferredDownload;
243250

244251
CNodeState() {
@@ -254,7 +261,7 @@ struct CNodeState {
254261
}
255262
};
256263

257-
// Map maintaining per-node state. Requires cs_main.
264+
/** Map maintaining per-node state. Requires cs_main. */
258265
map<NodeId, CNodeState> mapNodeState;
259266

260267
// Requires cs_main.
@@ -708,15 +715,15 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
708715
return true;
709716
}
710717

711-
//
712-
// Check transaction inputs to mitigate two
713-
// potential denial-of-service attacks:
714-
//
715-
// 1. scriptSigs with extra data stuffed into them,
716-
// not consumed by scriptPubKey (or P2SH script)
717-
// 2. P2SH scripts with a crazy number of expensive
718-
// CHECKSIG/CHECKMULTISIG operations
719-
//
718+
/**
719+
* Check transaction inputs to mitigate two
720+
* potential denial-of-service attacks:
721+
*
722+
* 1. scriptSigs with extra data stuffed into them,
723+
* not consumed by scriptPubKey (or P2SH script)
724+
* 2. P2SH scripts with a crazy number of expensive
725+
* CHECKSIG/CHECKMULTISIG operations
726+
*/
720727
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
721728
{
722729
if (tx.IsCoinBase())
@@ -1054,7 +1061,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
10541061
return true;
10551062
}
10561063

1057-
// Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock
1064+
/** Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock */
10581065
bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
10591066
{
10601067
CBlockIndex *pindexSlow = NULL;
@@ -1818,7 +1825,7 @@ void FlushStateToDisk() {
18181825
FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
18191826
}
18201827

1821-
// Update chainActive and related internal data structures.
1828+
/** Update chainActive and related internal data structures. */
18221829
void static UpdateTip(CBlockIndex *pindexNew) {
18231830
chainActive.SetTip(pindexNew);
18241831

@@ -1857,7 +1864,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
18571864
}
18581865
}
18591866

1860-
// Disconnect chainActive's tip.
1867+
/** Disconnect chainActive's tip. */
18611868
bool static DisconnectTip(CValidationState &state) {
18621869
CBlockIndex *pindexDelete = chainActive.Tip();
18631870
assert(pindexDelete);
@@ -1904,8 +1911,10 @@ static int64_t nTimeFlush = 0;
19041911
static int64_t nTimeChainState = 0;
19051912
static int64_t nTimePostConnect = 0;
19061913

1907-
// Connect a new block to chainActive. pblock is either NULL or a pointer to a CBlock
1908-
// corresponding to pindexNew, to bypass loading it again from disk.
1914+
/**
1915+
* Connect a new block to chainActive. pblock is either NULL or a pointer to a CBlock
1916+
* corresponding to pindexNew, to bypass loading it again from disk.
1917+
*/
19091918
bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *pblock) {
19101919
assert(pindexNew->pprev == chainActive.Tip());
19111920
mempool.check(pcoinsTip);
@@ -1965,8 +1974,10 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
19651974
return true;
19661975
}
19671976

1968-
// Return the tip of the chain with the most work in it, that isn't
1969-
// known to be invalid (it's however far from certain to be valid).
1977+
/**
1978+
* Return the tip of the chain with the most work in it, that isn't
1979+
* known to be invalid (it's however far from certain to be valid).
1980+
*/
19701981
static CBlockIndex* FindMostWorkChain() {
19711982
do {
19721983
CBlockIndex *pindexNew = NULL;
@@ -2007,7 +2018,7 @@ static CBlockIndex* FindMostWorkChain() {
20072018
} while(true);
20082019
}
20092020

2010-
// Delete all entries in setBlockIndexCandidates that are worse than the current tip.
2021+
/** Delete all entries in setBlockIndexCandidates that are worse than the current tip. */
20112022
static void PruneBlockIndexCandidates() {
20122023
// Note that we can't delete the current block itself, as we may need to return to it later in case a
20132024
// reorganization to a better block fails.
@@ -2019,8 +2030,10 @@ static void PruneBlockIndexCandidates() {
20192030
assert(!setBlockIndexCandidates.empty());
20202031
}
20212032

2022-
// Try to make some progress towards making pindexMostWork the active block.
2023-
// pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
2033+
/**
2034+
* Try to make some progress towards making pindexMostWork the active block.
2035+
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
2036+
*/
20242037
static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) {
20252038
AssertLockHeld(cs_main);
20262039
bool fInvalidFound = false;
@@ -2085,9 +2098,11 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
20852098
return true;
20862099
}
20872100

2088-
// Make the best chain active, in multiple steps. The result is either failure
2089-
// or an activated best chain. pblock is either NULL or a pointer to a block
2090-
// that is already loaded (to avoid loading it again from disk).
2101+
/**
2102+
* Make the best chain active, in multiple steps. The result is either failure
2103+
* or an activated best chain. pblock is either NULL or a pointer to a block
2104+
* that is already loaded (to avoid loading it again from disk).
2105+
*/
20912106
bool ActivateBestChain(CValidationState &state, CBlock *pblock) {
20922107
CBlockIndex *pindexNewTip = NULL;
20932108
CBlockIndex *pindexMostWork = NULL;
@@ -2236,7 +2251,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block)
22362251
return pindexNew;
22372252
}
22382253

2239-
// Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS).
2254+
/** Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). */
22402255
bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos)
22412256
{
22422257
pindexNew->nTx = block.vtx.size();
@@ -2745,7 +2760,7 @@ uint256 CPartialMerkleTree::CalcHash(int height, unsigned int pos, const std::ve
27452760
} else {
27462761
// calculate left hash
27472762
uint256 left = CalcHash(height-1, pos*2, vTxid), right;
2748-
// calculate right hash if not beyong the end of the array - copy left hash otherwise1
2763+
// calculate right hash if not beyond the end of the array - copy left hash otherwise1
27492764
if (pos*2+1 < CalcTreeWidth(height-1))
27502765
right = CalcHash(height-1, pos*2+1, vTxid);
27512766
else

0 commit comments

Comments
 (0)