diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2015-03-26 11:20:59 -0400 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2015-05-14 14:58:44 -0400 |
commit | 36cba8f1182e8284ec0017e57c5ffb519cd9798f (patch) | |
tree | 96f6581ba15b309d7dccc48ca6a89927fc12db08 /src/main.h | |
parent | b4c219b622235e66fecd5dee1883908d5336a6c0 (diff) |
Alert if it is very likely we are getting a bad chain
Create a monitoring task that counts how many blocks have been found in the last four hours.
If very few or too many have been found, an alert is triggered.
"Very few" and "too many" are set based on a false positive rate of once every fifty years of constant running with constant hashing power, which works out to getting 5 or fewer or 48 or more blocks in four hours (instead of the average of 24).
Only one alert per day is triggered, so if you get disconnected from the network (or are being Sybil'ed) -alertnotify will be triggered after 3.5 hours but you won't get another -alertnotify for 24 hours.
Tested with a new unit test and by running on the main network with -debug=partitioncheck
Run test/test_bitcoin --log_level=message to see the alert messages:
WARNING: check your network connection, 3 blocks received in the last 4 hours (24 expected)
WARNING: abnormally high number of blocks generated, 60 blocks received in the last 4 hours (24 expected)
The -debug=partitioncheck debug.log messages look like:
ThreadPartitionCheck : Found 22 blocks in the last 4 hours
ThreadPartitionCheck : likelihood: 0.0777702
Diffstat (limited to 'src/main.h')
-rw-r--r-- | src/main.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/main.h b/src/main.h index 90b809e85e..873f21330b 100644 --- a/src/main.h +++ b/src/main.h @@ -192,6 +192,8 @@ bool ProcessMessages(CNode* pfrom); bool SendMessages(CNode* pto, bool fSendTrickle); /** Run an instance of the script checking thread */ void ThreadScriptCheck(); +/** Try to detect Partition (network isolation) attacks against us */ +void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const CChain& chain, int64_t nPowTargetSpacing); /** Check whether we are doing an initial block download (synchronizing from disk or network) */ bool IsInitialBlockDownload(); /** Format a string that describes several potential problems detected by the core */ |