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