@ -35,7 +35,7 @@
# include <boost/filesystem.hpp>
# include <boost/filesystem.hpp>
# include <boost/thread.hpp>
# include <boost/thread.hpp>
// Dump addresses to peers.dat every 15 minutes (900s)
// Dump addresses to peers.dat and banlist.dat every 15 minutes (900s)
# define DUMP_ADDRESSES_INTERVAL 900
# define DUMP_ADDRESSES_INTERVAL 900
# if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
# if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
@ -555,11 +555,13 @@ void CNode::SweepBanned()
banmap_t : : iterator it = setBanned . begin ( ) ;
banmap_t : : iterator it = setBanned . begin ( ) ;
while ( it ! = setBanned . end ( ) )
while ( it ! = setBanned . end ( ) )
{
{
CSubNet subNet = ( * it ) . first ;
CBanEntry banEntry = ( * it ) . second ;
CBanEntry banEntry = ( * it ) . second ;
if ( now > banEntry . nBanUntil )
if ( now > banEntry . nBanUntil )
{
{
setBanned . erase ( it + + ) ;
setBanned . erase ( it + + ) ;
setBannedIsDirty = true ;
setBannedIsDirty = true ;
LogPrint ( " net " , " %s: Removed banned node ip/subnet from banlist.dat: %s \n " , __func__ , subNet . ToString ( ) ) ;
}
}
else
else
+ + it ;
+ + it ;
@ -1898,15 +1900,19 @@ void static Discover(boost::thread_group& threadGroup)
void StartNode ( boost : : thread_group & threadGroup , CScheduler & scheduler )
void StartNode ( boost : : thread_group & threadGroup , CScheduler & scheduler )
{
{
uiInterface . InitMessage ( _ ( " Loading addresses... " ) ) ;
uiInterface . InitMessage ( _ ( " Loading addresses... " ) ) ;
// Load addresses for peers.dat
// Load addresses from peers.dat
int64_t nStart = GetTimeMillis ( ) ;
int64_t nStart = GetTimeMillis ( ) ;
{
{
CAddrDB adb ;
CAddrDB adb ;
if ( ! adb . Read ( addrman ) )
if ( adb . Read ( addrman ) )
LogPrintf ( " Loaded %i addresses from peers.dat %dms \n " , addrman . size ( ) , GetTimeMillis ( ) - nStart ) ;
else
LogPrintf ( " Invalid or missing peers.dat; recreating \n " ) ;
LogPrintf ( " Invalid or missing peers.dat; recreating \n " ) ;
}
}
//try to read stored banlist
uiInterface . InitMessage ( _ ( " Loading banlist... " ) ) ;
// Load addresses from banlist.dat
nStart = GetTimeMillis ( ) ;
CBanDB bandb ;
CBanDB bandb ;
banmap_t banmap ;
banmap_t banmap ;
if ( bandb . Read ( banmap ) ) {
if ( bandb . Read ( banmap ) ) {
@ -1923,7 +1929,7 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
if ( semOutbound = = NULL ) {
if ( semOutbound = = NULL ) {
// initialize semaphore
// initialize semaphore
int nMaxOutbound = min ( MAX_OUTBOUND_CONNECTIONS , nMaxConnections ) ;
int nMaxOutbound = std : : min ( MAX_OUTBOUND_CONNECTIONS , nMaxConnections ) ;
semOutbound = new CSemaphore ( nMaxOutbound ) ;
semOutbound = new CSemaphore ( nMaxOutbound ) ;
}
}