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