@ -4272,6 +4272,9 @@ bool RewindBlockIndex(const CChainParams& params)
return true ;
return true ;
}
}
// May NOT be used after any connections are up as much
// of the peer-processing logic assumes a consistent
// block index state
void UnloadBlockIndex ( )
void UnloadBlockIndex ( )
{
{
LOCK ( cs_main ) ;
LOCK ( cs_main ) ;
@ -4282,18 +4285,12 @@ void UnloadBlockIndex()
mempool . clear ( ) ;
mempool . clear ( ) ;
mapOrphanTransactions . clear ( ) ;
mapOrphanTransactions . clear ( ) ;
mapOrphanTransactionsByPrev . clear ( ) ;
mapOrphanTransactionsByPrev . clear ( ) ;
nSyncStarted = 0 ;
mapBlocksUnlinked . clear ( ) ;
mapBlocksUnlinked . clear ( ) ;
vinfoBlockFile . clear ( ) ;
vinfoBlockFile . clear ( ) ;
nLastBlockFile = 0 ;
nLastBlockFile = 0 ;
nBlockSequenceId = 1 ;
nBlockSequenceId = 1 ;
mapBlockSource . clear ( ) ;
mapBlocksInFlight . clear ( ) ;
nPreferredDownload = 0 ;
setDirtyBlockIndex . clear ( ) ;
setDirtyBlockIndex . clear ( ) ;
setDirtyFileInfo . clear ( ) ;
setDirtyFileInfo . clear ( ) ;
mapNodeState . clear ( ) ;
recentRejects . reset ( NULL ) ;
versionbitscache . Clear ( ) ;
versionbitscache . Clear ( ) ;
for ( int b = 0 ; b < VERSIONBITS_NUM_BITS ; b + + ) {
for ( int b = 0 ; b < VERSIONBITS_NUM_BITS ; b + + ) {
warningcache [ b ] . clear ( ) ;
warningcache [ b ] . clear ( ) ;
@ -4318,9 +4315,6 @@ bool InitBlockIndex(const CChainParams& chainparams)
{
{
LOCK ( cs_main ) ;
LOCK ( cs_main ) ;
// Initialize global variables that cannot be constructed at startup.
recentRejects . reset ( new CRollingBloomFilter ( 120000 , 0.000001 ) ) ;
// Check whether we're already initialized
// Check whether we're already initialized
if ( chainActive . Genesis ( ) ! = NULL )
if ( chainActive . Genesis ( ) ! = NULL )
return true ;
return true ;
@ -4709,6 +4703,11 @@ std::string GetWarnings(const std::string& strFor)
// blockchain -> download logic notification
// blockchain -> download logic notification
//
//
PeerLogicValidation : : PeerLogicValidation ( CConnman * connmanIn ) : connman ( connmanIn ) {
// Initialize global variables that cannot be constructed at startup.
recentRejects . reset ( new CRollingBloomFilter ( 120000 , 0.000001 ) ) ;
}
void PeerLogicValidation : : UpdatedBlockTip ( const CBlockIndex * pindexNew , const CBlockIndex * pindexFork , bool fInitialDownload ) {
void PeerLogicValidation : : UpdatedBlockTip ( const CBlockIndex * pindexNew , const CBlockIndex * pindexFork , bool fInitialDownload ) {
const int nNewHeight = pindexNew - > nHeight ;
const int nNewHeight = pindexNew - > nHeight ;
connman - > SetBestHeight ( nNewHeight ) ;
connman - > SetBestHeight ( nNewHeight ) ;