mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
refactor: rpc: Pass CBlockIndex by reference instead of pointer
All functions assume that the pointer is never null, so pass by reference, to avoid accidental segfaults at runtime, or at least make them more obvious. Also, remove unused c-style casts in touched lines. Also, add CHECK_NONFATAL checks, to turn segfault crashes into an recoverable runtime error with debug information.
This commit is contained in:
@@ -41,7 +41,7 @@ static void RejectDifficultyMismatch(double difficulty, double expected_difficul
|
||||
static void TestDifficulty(uint32_t nbits, double expected_difficulty)
|
||||
{
|
||||
CBlockIndex* block_index = CreateBlockIndexWithNbits(nbits);
|
||||
double difficulty = GetDifficulty(block_index);
|
||||
double difficulty = GetDifficulty(*block_index);
|
||||
delete block_index;
|
||||
|
||||
RejectDifficultyMismatch(difficulty, expected_difficulty);
|
||||
|
||||
Reference in New Issue
Block a user