Notes fix
[novacoin.git] / doc / coding.txt
index 4707476..b3c812a 100644 (file)
@@ -39,3 +39,61 @@ v       vector or similar list objects
 map     map or multimap\r
 set     set or multiset\r
 bn      CBigNum\r
+\r
+-------------------------\r
+Locking/mutex usage notes\r
+\r
+The code is multi-threaded, and uses mutexes and the\r
+CRITICAL_BLOCK/TRY_CRITICAL_BLOCK macros to protect data structures.\r
+\r
+Deadlocks due to inconsistent lock ordering (thread 1 locks cs_main\r
+and then cs_wallet, while thread 2 locks them in the opposite order:\r
+result, deadlock as each waits for the other to release its lock) are\r
+a problem. Compile with -DDEBUG_LOCKORDER to get lock order\r
+inconsistencies reported in the debug.log file.\r
+\r
+Re-architecting the core code so there are better-defined interfaces\r
+between the various components is a goal, with any necessary locking\r
+done by the components (e.g. see the self-contained CKeyStore class\r
+and its cs_KeyStore lock for example).\r
+\r
+-------\r
+Threads\r
+\r
+StartNode : Starts other threads.\r
+\r
+ThreadGetMyExternalIP : Determines outside-the-firewall IP address,\r
+sends addr message to connected peers when it determines it. \r
+\r
+ThreadIRCSeed : Joins IRC bootstrapping channel, watching for new\r
+peers and advertising this node's IP address. \r
+\r
+ThreadSocketHandler : Sends/Receives data from peers on port 8333.\r
+\r
+ThreadMessageHandler : Higher-level message handling (sending and\r
+receiving).\r
+\r
+ThreadOpenConnections : Initiates new connections to peers.\r
+\r
+ThreadTopUpKeyPool : replenishes the keystore's keypool.\r
+\r
+ThreadCleanWalletPassphrase : re-locks an encrypted wallet after user\r
+has unlocked it for a period of time. \r
+\r
+SendingDialogStartTransfer : used by pay-via-ip-address code (obsolete)\r
+\r
+ThreadDelayedRepaint : repaint the gui \r
+\r
+ThreadFlushWalletDB : Close the wallet.dat file if it hasn't been used\r
+in 500ms.\r
+\r
+ThreadRPCServer : Remote procedure call handler, listens on port 8332\r
+for connections and services them.\r
+\r
+ThreadBitcoinMiner : Generates bitcoins\r
+\r
+ThreadMapPort : Universal plug-and-play startup/shutdown\r
+\r
+Shutdown : Does an orderly shutdown of everything\r
+\r
+ExitTimeout : Windows-only, sleeps 5 seconds then exits application\r