@@ -12,12 +12,13 @@ Developer Notes
12
12
- [ Development tips and tricks] ( #development-tips-and-tricks )
13
13
- [ Compiling for debugging] ( #compiling-for-debugging )
14
14
- [ Compiling for gprof profiling] ( #compiling-for-gprof-profiling )
15
- - [ debug.log] ( #debuglog )
15
+ - [ ` debug.log ` ] ( #debuglog )
16
16
- [ Testnet and Regtest modes] ( #testnet-and-regtest-modes )
17
17
- [ DEBUG_LOCKORDER] ( #debug_lockorder )
18
18
- [ Valgrind suppressions file] ( #valgrind-suppressions-file )
19
19
- [ Compiling for test coverage] ( #compiling-for-test-coverage )
20
20
- [ Performance profiling with perf] ( #performance-profiling-with-perf )
21
+ - [ Sanitizers] ( #sanitizers )
21
22
- [ Locking/mutex usage notes] ( #lockingmutex-usage-notes )
22
23
- [ Threads] ( #threads )
23
24
- [ Ignoring IDE/editor files] ( #ignoring-ideeditor-files )
@@ -63,7 +64,7 @@ tool to clean up patches automatically before submission.
63
64
- Braces on the same line for everything else.
64
65
- 4 space indentation (no tabs) for every block except namespaces.
65
66
- No indentation for ` public ` /` protected ` /` private ` or for ` namespace ` .
66
- - No extra spaces inside parenthesis; don't do ( this ).
67
+ - No extra spaces inside parenthesis; don't do ` ( this ) ` .
67
68
- No space after function names; one space after ` if ` , ` for ` and ` while ` .
68
69
- If an ` if ` only has a single-statement ` then ` -clause, it can appear
69
70
on the same line as the ` if ` , without braces. In every other case,
77
78
separate words (snake_case).
78
79
- Class member variables have a ` m_ ` prefix.
79
80
- Global variables have a ` g_ ` prefix.
80
- - Constant names are all uppercase, and use ` _ ` to separate words.
81
+ - Compile-time constant names are all uppercase, and use ` _ ` to separate words.
81
82
- Class names, function names, and method names are UpperCamelCase
82
83
(PascalCase). Do not prefix class names with ` C ` .
83
84
- Test suite naming convention: The Boost test suite in file
@@ -208,15 +209,15 @@ produce better debugging builds.
208
209
209
210
Run configure with the ` --enable-gprof ` option, then make.
210
211
211
- ### debug.log
212
+ ### ` debug.log `
212
213
213
- If the code is behaving strangely, take a look in the debug.log file in the data directory;
214
+ If the code is behaving strangely, take a look in the ` debug.log ` file in the data directory;
214
215
error and debugging messages are written there.
215
216
216
217
The ` -debug=... ` command-line option controls debugging; running with just ` -debug ` or ` -debug=1 ` will turn
217
- on all categories (and give you a very large debug.log file).
218
+ on all categories (and give you a very large ` debug.log ` file).
218
219
219
- The Qt code routes ` qDebug() ` output to debug.log under category "qt": run with ` -debug=qt `
220
+ The Qt code routes ` qDebug() ` output to ` debug.log ` under category "qt": run with ` -debug=qt `
220
221
to see it.
221
222
222
223
### Testnet and Regtest modes
@@ -234,7 +235,7 @@ Bitcoin Core is a multi-threaded application, and deadlocks or other
234
235
multi-threading bugs can be very difficult to track down. The ` --enable-debug `
235
236
configure option adds ` -DDEBUG_LOCKORDER ` to the compiler flags. This inserts
236
237
run-time checks to keep track of which locks are held and adds warnings to the
237
- debug.log file if inconsistencies are detected.
238
+ ` debug.log ` file if inconsistencies are detected.
238
239
239
240
### Valgrind suppressions file
240
241
@@ -276,8 +277,7 @@ the functional test framework. Perf can observe a running process and sample
276
277
(at some frequency) where its execution is.
277
278
278
279
Perf installation is contingent on which kernel version you're running; see
279
- [ this StackExchange
280
- thread] ( https://askubuntu.com/questions/50145/how-to-install-perf-monitoring-tool )
280
+ [ this thread] ( https://askubuntu.com/questions/50145/how-to-install-perf-monitoring-tool )
281
281
for specific instructions.
282
282
283
283
Certain kernel parameters may need to be set for perf to be able to inspect the
@@ -312,7 +312,7 @@ or using a graphical tool like [Hotspot](https://github.com/KDAB/hotspot).
312
312
See the functional test documentation for how to invoke perf within tests.
313
313
314
314
315
- ** Sanitizers**
315
+ ### Sanitizers
316
316
317
317
Bitcoin Core can be compiled with various "sanitizers" enabled, which add
318
318
instrumentation for issues regarding things like memory safety, thread race
@@ -373,7 +373,7 @@ Deadlocks due to inconsistent lock ordering (thread 1 locks `cs_main` and then
373
373
` cs_wallet ` , while thread 2 locks them in the opposite order: result, deadlock
374
374
as each waits for the other to release its lock) are a problem. Compile with
375
375
` -DDEBUG_LOCKORDER ` (or use ` --enable-debug ` ) to get lock order inconsistencies
376
- reported in the debug.log file.
376
+ reported in the ` debug.log ` file.
377
377
378
378
Re-architecting the core code so there are better-defined interfaces
379
379
between the various components is a goal, with any necessary locking
@@ -387,8 +387,6 @@ Threads
387
387
388
388
- ThreadImport : Loads blocks from ` blk*.dat ` files or ` -loadblock=<file> ` .
389
389
390
- - StartNode : Starts other threads.
391
-
392
390
- ThreadDNSAddressSeed : Loads addresses of peers from the DNS.
393
391
394
392
- ThreadMapPort : Universal plug-and-play startup/shutdown.
@@ -401,7 +399,7 @@ Threads
401
399
402
400
- ThreadMessageHandler : Higher-level message handling (sending and receiving).
403
401
404
- - DumpAddresses : Dumps IP addresses of nodes to peers.dat.
402
+ - DumpAddresses : Dumps IP addresses of nodes to ` peers.dat ` .
405
403
406
404
- ThreadRPCServer : Remote procedure call handler, listens on port 8332 for connections and services them.
407
405
@@ -467,11 +465,6 @@ Wallet
467
465
468
466
- Make sure that no crashes happen with run-time option ` -disablewallet ` .
469
467
470
- - * Rationale* : In RPC code that conditionally uses the wallet (such as
471
- ` validateaddress ` ), it is easy to forget that global pointer ` pwalletMain `
472
- can be nullptr. See ` test/functional/disablewallet.py ` for functional tests
473
- exercising the API with ` -disablewallet ` .
474
-
475
468
- Include ` db_cxx.h ` (BerkeleyDB header) only when ` ENABLE_WALLET ` is set.
476
469
477
470
- * Rationale* : Otherwise compilation of the disable-wallet build will fail in environments without BerkeleyDB.
@@ -546,11 +539,10 @@ class A
546
539
}
547
540
```
548
541
549
- - By default, declare single-argument constructors `explicit`.
542
+ - By default, declare constructors `explicit`.
550
543
551
- - *Rationale*: This is a precaution to avoid unintended conversions that might
552
- arise when single-argument constructors are used as implicit conversion
553
- functions.
544
+ - *Rationale*: This is a precaution to avoid unintended
545
+ [conversions](https://en.cppreference.com/w/cpp/language/converting_constructor).
554
546
555
547
- Use explicitly signed or unsigned `char`s, or even better `uint8_t` and
556
548
`int8_t`. Do not use bare `char` unless it is to pass to a third-party API.
0 commit comments