1 Please be consistent with the existing coding style.
\r
5 bool Function(char* psz, int n)
\r
7 // Comment summarising what this section of code does
\r
8 for (int i = 0; i < n; i++)
\r
10 // When something fails, return early
\r
16 // Success return is usually at the end
\r
20 - ANSI/Allman block style
\r
21 - 4 space indenting, no tabs
\r
22 - No extra spaces inside parenthesis; please don't do ( this )
\r
23 - No space after function names, one space after if, for and while
\r
25 Variable names begin with the type in lowercase, like nSomeVariable.
\r
26 Please don't put the first word of the variable name in lowercase like
\r
30 n integer number: short, unsigned short, int, unsigned int,
\r
31 int64, uint64, sometimes char if used as a number
\r
35 p pointer or array, one p for each level of indirection
\r
36 psz pointer to null terminated string
\r
38 v vector or similar list objects
\r
43 -------------------------
\r
44 Locking/mutex usage notes
\r
46 The code is multi-threaded, and uses mutexes and the
\r
47 CRITICAL_BLOCK/TRY_CRITICAL_BLOCK macros to protect data structures.
\r
49 Deadlocks due to inconsistent lock ordering (thread 1 locks cs_main
\r
50 and then cs_wallet, while thread 2 locks them in the opposite order:
\r
51 result, deadlock as each waits for the other to release its lock) are
\r
52 a problem. Compile with -DDEBUG_LOCKORDER to get lock order
\r
53 inconsistencies reported in the debug.log file.
\r
55 Re-architecting the core code so there are better-defined interfaces
\r
56 between the various components is a goal, with any necessary locking
\r
57 done by the components (e.g. see the self-contained CKeyStore class
\r
58 and its cs_KeyStore lock for example).
\r
63 StartNode : Starts other threads.
\r
65 ThreadGetMyExternalIP : Determines outside-the-firewall IP address,
\r
66 sends addr message to connected peers when it determines it.
\r
68 ThreadIRCSeed : Joins IRC bootstrapping channel, watching for new
\r
69 peers and advertising this node's IP address.
\r
71 ThreadSocketHandler : Sends/Receives data from peers on port 8333.
\r
73 ThreadMessageHandler : Higher-level message handling (sending and
\r
76 ThreadOpenConnections : Initiates new connections to peers.
\r
78 ThreadTopUpKeyPool : replenishes the keystore's keypool.
\r
80 ThreadCleanWalletPassphrase : re-locks an encrypted wallet after user
\r
81 has unlocked it for a period of time.
\r
83 SendingDialogStartTransfer : used by pay-via-ip-address code (obsolete)
\r
85 ThreadDelayedRepaint : repaint the gui
\r
87 ThreadFlushWalletDB : Close the wallet.dat file if it hasn't been used
\r
90 ThreadRPCServer : Remote procedure call handler, listens on port 8332
\r
91 for connections and services them.
\r
93 ThreadBitcoinMiner : Generates bitcoins
\r
95 ThreadMapPort : Universal plug-and-play startup/shutdown
\r
97 Shutdown : Does an orderly shutdown of everything
\r
99 ExitTimeout : Windows-only, sleeps 5 seconds then exits application
\r