@ -482,6 +482,7 @@ public:
@@ -482,6 +482,7 @@ public:
//! Return the number of (unique) addresses in all tables.
size_t size ( ) const
{
LOCK ( cs ) ; // TODO: Cache this in an atomic to avoid this overhead
return vRandom . size ( ) ;
}
@ -501,13 +502,11 @@ public:
@@ -501,13 +502,11 @@ public:
//! Add a single address.
bool Add ( const CAddress & addr , const CNetAddr & source , int64_t nTimePenalty = 0 )
{
LOCK ( cs ) ;
bool fRet = false ;
{
LOCK ( cs ) ;
Check ( ) ;
fRet | = Add_ ( addr , source , nTimePenalty ) ;
Check ( ) ;
}
Check ( ) ;
fRet | = Add_ ( addr , source , nTimePenalty ) ;
Check ( ) ;
if ( fRet )
LogPrint ( " addrman " , " Added %s from %s: %i tried, %i new \n " , addr . ToStringIPPort ( ) , source . ToString ( ) , nTried , nNew ) ;
return fRet ;
@ -516,14 +515,12 @@ public:
@@ -516,14 +515,12 @@ public:
//! Add multiple addresses.
bool Add ( const std : : vector < CAddress > & vAddr , const CNetAddr & source , int64_t nTimePenalty = 0 )
{
LOCK ( cs ) ;
int nAdd = 0 ;
{
LOCK ( cs ) ;
Check ( ) ;
for ( std : : vector < CAddress > : : const_iterator it = vAddr . begin ( ) ; it ! = vAddr . end ( ) ; it + + )
nAdd + = Add_ ( * it , source , nTimePenalty ) ? 1 : 0 ;
Check ( ) ;
}
Check ( ) ;
for ( std : : vector < CAddress > : : const_iterator it = vAddr . begin ( ) ; it ! = vAddr . end ( ) ; it + + )
nAdd + = Add_ ( * it , source , nTimePenalty ) ? 1 : 0 ;
Check ( ) ;
if ( nAdd )
LogPrint ( " addrman " , " Added %i addresses from %s: %i tried, %i new \n " , nAdd , source . ToString ( ) , nTried , nNew ) ;
return nAdd > 0 ;
@ -532,23 +529,19 @@ public:
@@ -532,23 +529,19 @@ public:
//! Mark an entry as accessible.
void Good ( const CService & addr , int64_t nTime = GetAdjustedTime ( ) )
{
{
LOCK ( cs ) ;
Check ( ) ;
Good_ ( addr , nTime ) ;
Check ( ) ;
}
LOCK ( cs ) ;
Check ( ) ;
Good_ ( addr , nTime ) ;
Check ( ) ;
}
//! Mark an entry as connection attempted to.
void Attempt ( const CService & addr , bool fCountFailure , int64_t nTime = GetAdjustedTime ( ) )
{
{
LOCK ( cs ) ;
Check ( ) ;
Attempt_ ( addr , fCountFailure , nTime ) ;
Check ( ) ;
}
LOCK ( cs ) ;
Check ( ) ;
Attempt_ ( addr , fCountFailure , nTime ) ;
Check ( ) ;
}
/**
@ -582,12 +575,10 @@ public:
@@ -582,12 +575,10 @@ public:
//! Mark an entry as currently-connected-to.
void Connected ( const CService & addr , int64_t nTime = GetAdjustedTime ( ) )
{
{
LOCK ( cs ) ;
Check ( ) ;
Connected_ ( addr , nTime ) ;
Check ( ) ;
}
LOCK ( cs ) ;
Check ( ) ;
Connected_ ( addr , nTime ) ;
Check ( ) ;
}
void SetServices ( const CService & addr , ServiceFlags nServices )