bitcoin/src
Gavin Andresen 36cba8f118
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
2015-05-14 14:58:44 -04:00
..
compat build: Endian compatibility 2015-03-06 15:54:53 +01:00
config
consensus Consensus: Create consensus/consensus.h with some constants 2015-04-20 21:27:51 +02:00
crypto build: Endian compatibility 2015-03-06 15:54:53 +01:00
json
leveldb
obj
obj-test
policy Create new BlockPolicyEstimator for fee estimates 2015-05-13 10:36:24 -04:00
primitives Consensus: Create consensus/consensus.h with some constants 2015-04-20 21:27:51 +02:00
qt Merge pull request #5964 2015-05-14 14:27:07 -04:00
script Abstract out Ctransaction-specific signing into TransactionSignatureCreator 2015-03-21 07:06:18 -07:00
secp256k1 Update libsecp256k1 2015-04-22 14:03:10 -07:00
support ensure consistent header comment naming conventions 2015-04-20 13:29:22 +02:00
test Alert if it is very likely we are getting a bad chain 2015-05-14 14:58:44 -04:00
univalue Remove references to X11 licence 2014-12-16 15:56:50 +08:00
wallet Merge pull request #6055 2015-05-06 11:38:39 +02:00
.clang-format
addrman.cpp Merge pull request #6028 2015-04-24 16:11:23 +02:00
addrman.h Non-grammatical language improvements 2015-05-02 15:23:59 +00:00
alert.cpp Chainparams: Decouple CAlert from CChainParams 2015-04-04 12:58:14 +02:00
alert.h Chainparams: Decouple CAlert from CChainParams 2015-04-04 12:58:14 +02:00
amount.cpp Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
amount.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
arith_uint256.cpp src/arith_256.cpp: bigendian compatibility 2015-03-06 17:21:59 +01:00
arith_uint256.h ensure consistent header comment naming conventions 2015-04-20 13:29:22 +02:00
base58.cpp openssl: abstract out OPENSSL_cleanse 2015-02-15 11:34:02 -05:00
base58.h Non-grammatical language improvements 2015-05-02 15:23:59 +00:00
bitcoin-cli-res.rc Remove references to X11 licence 2014-12-16 15:56:50 +08:00
bitcoin-cli.cpp Separate CTranslationInterface from CClientUIInterface 2015-04-16 19:58:48 +02:00
bitcoin-tx.cpp Merge pull request #6047 2015-05-06 12:29:07 +02:00
bitcoind-res.rc Remove references to X11 licence 2014-12-16 15:56:50 +08:00
bitcoind.cpp Create a scheduler thread for lightweight tasks 2015-05-14 12:50:41 -04:00
bloom.cpp Rolling bloom filter class 2015-04-30 07:58:29 -07:00
bloom.h Merge pull request #6085 2015-05-04 08:01:58 +02:00
chain.cpp Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
chain.h Non-grammatical language improvements 2015-05-02 15:23:59 +00:00
chainparams.cpp Merge pull request #6055 2015-05-06 11:38:39 +02:00
chainparams.h Merge pull request #6055 2015-05-06 11:38:39 +02:00
chainparamsbase.cpp test: Remove UNITTEST params 2015-03-09 16:06:14 +01:00
chainparamsbase.h Bugfix: Grammar fixes 2015-05-01 11:21:27 +00:00
chainparamsseeds.h Update seed IPs, based on bitcoin.sipa.be crawler data 2015-01-05 17:23:23 +01:00
checkpoints.cpp Merge pull request #6055 2015-05-06 11:38:39 +02:00
checkpoints.h Merge pull request #6055 2015-05-06 11:38:39 +02:00
checkqueue.h Bugfix: Grammar fixes 2015-05-01 11:21:27 +00:00
clientversion.cpp Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
clientversion.h Bump project-wide COPYRIGHT_YEAR to 2015 2015-01-02 10:53:13 +01:00
coincontrol.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
coins.cpp Merge pull request #5597 2015-01-07 13:03:41 +01:00
coins.h Replace direct use of 0 with SetNull and IsNull 2015-01-05 15:45:34 +01:00
compat.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
compressor.cpp Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
compressor.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
core_io.h Merge pull request #5499 2014-12-31 10:50:06 +01:00
core_read.cpp namespace: drop most boost namespaces and a few header cleanups 2015-01-02 15:12:03 -05:00
core_write.cpp Replace direct use of 0 with SetNull and IsNull 2015-01-05 15:45:34 +01:00
eccryptoverify.cpp Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
eccryptoverify.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
ecwrapper.cpp Improve robustness of DER recoding code 2015-01-12 08:59:03 +01:00
ecwrapper.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
hash.cpp chaincodes: abstract away more chaincode behavior 2015-05-06 17:22:46 +02:00
hash.h chaincodes: abstract away more chaincode behavior 2015-05-06 17:22:46 +02:00
init.cpp Alert if it is very likely we are getting a bad chain 2015-05-14 14:58:44 -04:00
init.h Create a scheduler thread for lightweight tasks 2015-05-14 12:50:41 -04:00
key.cpp Merge pull request #6034 2015-05-06 18:37:49 +02:00
key.h Merge pull request #6034 2015-05-06 18:37:49 +02:00
keystore.cpp wallet: move crypter to wallet 2015-03-22 15:18:55 -04:00
keystore.h c++11: don't forward-declare types used in maps 2015-02-03 23:30:59 -05:00
leveldbwrapper.cpp Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
leveldbwrapper.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
limitedmap.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
main.cpp Alert if it is very likely we are getting a bad chain 2015-05-14 14:58:44 -04:00
main.h Alert if it is very likely we are getting a bad chain 2015-05-14 14:58:44 -04:00
Makefile.am Merge pull request #5964 2015-05-14 14:27:07 -04:00
Makefile.qt.include [QT] use alert icon with tooltip insted of "(out of sync)" text 2015-05-12 20:46:12 +02:00
Makefile.qttest.include
Makefile.test.include Merge pull request #5964 2015-05-14 14:27:07 -04:00
merkleblock.cpp Bugfix: Grammar fixes 2015-05-01 11:21:27 +00:00
merkleblock.h Bugfix: Grammar fixes 2015-05-01 11:21:27 +00:00
miner.cpp Avoid crash on start in TestBlockValidity with gen=1. 2015-05-12 14:07:43 +02:00
miner.h miner.h: fix clang warning because of class/struct mix 2015-04-16 10:32:47 +02:00
mruset.h Use ring buffer of set iterators instead of deque of copies in mruset 2015-04-30 08:16:30 -07:00
net.cpp Use CScheduler for net's DumpAddresses 2015-05-14 12:50:42 -04:00
net.h Use CScheduler for net's DumpAddresses 2015-05-14 12:50:42 -04:00
netbase.cpp use const reference as param in ConnectThroughProxy/Socks5 2015-04-28 14:44:56 +02:00
netbase.h privacy: Stream isolation for Tor 2015-04-17 13:26:47 +02:00
noui.cpp Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
noui.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
pow.cpp Use equivalent PoW for non-main-chain requests 2015-04-22 03:53:25 -07:00
pow.h Use equivalent PoW for non-main-chain requests 2015-04-22 03:53:25 -07:00
protocol.cpp nLastTry is only used for addrman entries 2015-04-19 11:10:23 -07:00
protocol.h nLastTry is only used for addrman entries 2015-04-19 11:10:23 -07:00
pubkey.cpp chaincodes: abstract away more chaincode behavior 2015-05-06 17:22:46 +02:00
pubkey.h chaincodes: abstract away more chaincode behavior 2015-05-06 17:22:46 +02:00
random.cpp WIN32 Seed Cleanup: Move nLastPerfmon behind win32 ifdef. 2015-02-25 18:37:06 -05:00
random.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
rest.cpp Merge pull request #6058 2015-05-11 16:40:58 +02:00
rpcblockchain.cpp Merge pull request #6058 2015-05-11 16:40:58 +02:00
rpcclient.cpp Merge pull request #6022 2015-04-30 16:37:18 +02:00
rpcclient.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
rpcmining.cpp Merge pull request #5696 2015-04-26 14:42:09 +02:00
rpcmisc.cpp privacy: Stream isolation for Tor 2015-04-17 13:26:47 +02:00
rpcnet.cpp privacy: Stream isolation for Tor 2015-04-17 13:26:47 +02:00
rpcprotocol.cpp namespace: drop most boost namespaces and a few header cleanups 2015-01-02 15:12:03 -05:00
rpcprotocol.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
rpcrawtransaction.cpp RPC: show script verification errors in "signrawtransaction" result 2015-05-05 09:40:55 +02:00
rpcserver.cpp Merge pull request #5420 2015-05-06 16:50:05 +02:00
rpcserver.h Merge pull request #5420 2015-05-06 16:50:05 +02:00
scheduler.cpp scheduler: fix with boost <= 1.50 2015-05-14 10:37:19 -04:00
scheduler.h CScheduler class for lightweight task scheduling 2015-05-14 10:37:19 -04:00
serialize.h src/serialize.h: base serialization level endianness neutrality 2015-03-06 17:21:58 +01:00
streams.h allocators: split allocators and pagelocker 2015-03-20 12:23:44 +01:00
sync.cpp Remove broken+useless lock/unlock log prints 2015-04-24 02:28:47 -07:00
sync.h [Trivial] format sync.h 2015-04-20 13:29:21 +02:00
threadsafety.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
timedata.cpp Merge pull request #5476 2015-01-02 17:54:21 +01:00
timedata.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
tinyformat.h
txdb.cpp Consensus: Refactor: Decouple pow.o from chainparams.o 2015-03-26 00:47:51 +01:00
txdb.h Fix clang compile warnings intriduced in #5681 2015-03-29 19:45:05 +08:00
txmempool.cpp Merge pull request #5159 2015-05-13 17:10:02 +02:00
txmempool.h Create new BlockPolicyEstimator for fee estimates 2015-05-13 10:36:24 -04:00
ui_interface.h Separate CTranslationInterface from CClientUIInterface 2015-04-16 19:58:48 +02:00
uint256.cpp BUGFIX: Stack around the variable 'rv' was corrupted 2015-03-12 22:17:22 +06:00
uint256.h uint256->arith_uint256 blob256->uint256 2015-01-05 15:45:35 +01:00
undo.h MOVEONLY: CBlockUndo from main.h to undo.h 2014-12-27 16:01:31 +01:00
util.cpp [squashme] simplify SetupEnvironment() (by dexX7) 2015-05-10 10:06:41 +02:00
util.h Use CScheduler for net's DumpAddresses 2015-05-14 12:50:42 -04:00
utilmoneystr.cpp Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
utilmoneystr.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
utilstrencodings.cpp Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
utilstrencodings.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
utiltime.cpp Trivial: useless cast (ptime)(I'm ptime) 2015-04-30 23:11:52 +03:00
utiltime.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00
validationinterface.cpp Regression test for ResendWalletTransactions 2015-03-24 15:29:20 -04:00
validationinterface.h Merge pull request #5940 2015-03-30 14:28:09 +02:00
version.h Added "Core" to copyright headers 2014-12-19 19:55:32 +01:00