@ -18,11 +18,11 @@ void CAddrInfo::Update(bool good) {
stat1W . Update ( good , age , 3600 * 24 * 7 ) ;
stat1W . Update ( good , age , 3600 * 24 * 7 ) ;
int ign = GetIgnoreTime ( ) ;
int ign = GetIgnoreTime ( ) ;
if ( ign & & ( ignoreTill = = 0 | | ignoreTill < ign + now ) ) ignoreTill = ign + now ;
if ( ign & & ( ignoreTill = = 0 | | ignoreTill < ign + now ) ) ignoreTill = ign + now ;
printf ( " %s: got %s result: success=%i/%i; 2H:%.2f%%-%.2f%%(%.2f) 8H:%.2f%%-%.2f%%(%.2f) 1D:%.2f%%-%.2f%%(%.2f) 1W:%.2f%%-%.2f%%(%.2f) \n " , ToString ( ip ) . c_str ( ) , good ? " good " : " bad " , success , total ,
// printf(" %s: got %s result: success=%i/%i; 2H:%.2f%%-%.2f%%(%.2f) 8H:%.2f%%-%.2f%%(%.2f) 1D:%.2f%%-%.2f%%(%.2f) 1W:%.2f%%-%.2f%%(%.2f) \n", ToString(ip).c_str(), good ? "good" : "bad", success, total,
100.0 * stat2H . reliability , 100.0 * ( stat2H . reliability + 1.0 - stat2H . weight ) , stat2H . count ,
// 100.0 * stat2H.reliability, 100.0 * (stat2H.reliability + 1.0 - stat2H.weight), stat2H.count,
100.0 * stat8H . reliability , 100.0 * ( stat8H . reliability + 1.0 - stat8H . weight ) , stat8H . count ,
// 100.0 * stat8H.reliability, 100.0 * (stat8H.reliability + 1.0 - stat8H.weight), stat8H.count,
100.0 * stat1D . reliability , 100.0 * ( stat1D . reliability + 1.0 - stat1D . weight ) , stat1D . count ,
// 100.0 * stat1D.reliability, 100.0 * (stat1D.reliability + 1.0 - stat1D.weight), stat1D.count,
100.0 * stat1W . reliability , 100.0 * ( stat1W . reliability + 1.0 - stat1W . weight ) , stat1W . count ) ;
// 100.0 * stat1W.reliability, 100.0 * (stat1W.reliability + 1.0 - stat1W.weight), stat1W.count);
}
}
bool CAddrDb : : Get_ ( CIPPort & ip , int & wait ) {
bool CAddrDb : : Get_ ( CIPPort & ip , int & wait ) {
@ -92,7 +92,7 @@ void CAddrDb::Good_(const CIPPort &addr, int clientV) {
info . Update ( true ) ;
info . Update ( true ) ;
if ( info . IsGood ( ) & & goodId . count ( id ) = = 0 ) {
if ( info . IsGood ( ) & & goodId . count ( id ) = = 0 ) {
goodId . insert ( id ) ;
goodId . insert ( id ) ;
printf ( " %s: good; %i good nodes now \n " , ToString ( addr ) . c_str ( ) , ( int ) goodId . size ( ) ) ;
// printf("%s: good; %i good nodes now\n", ToString(addr).c_str(), (int)goodId.size());
}
}
nDirty + + ;
nDirty + + ;
ourId . push_back ( id ) ;
ourId . push_back ( id ) ;
@ -108,11 +108,11 @@ void CAddrDb::Bad_(const CIPPort &addr, int ban)
uint32_t now = time ( NULL ) ;
uint32_t now = time ( NULL ) ;
int ter = info . GetBanTime ( ) ;
int ter = info . GetBanTime ( ) ;
if ( ter ) {
if ( ter ) {
printf ( " %s: terrible \n " , ToString ( addr ) . c_str ( ) ) ;
// printf("%s: terrible\n", ToString(addr).c_str());
if ( ban < ter ) ban = ter ;
if ( ban < ter ) ban = ter ;
}
}
if ( ban > 0 ) {
if ( ban > 0 ) {
printf ( " %s: ban for %i seconds \n " , ToString ( addr ) . c_str ( ) , ban ) ;
// printf("%s: ban for %i seconds\n", ToString(addr).c_str(), ban);
banned [ info . ip ] = ban + now ;
banned [ info . ip ] = ban + now ;
ipToId . erase ( info . ip ) ;
ipToId . erase ( info . ip ) ;
goodId . erase ( id ) ;
goodId . erase ( id ) ;
@ -120,7 +120,7 @@ void CAddrDb::Bad_(const CIPPort &addr, int ban)
} else {
} else {
if ( ! info . IsGood ( ) & & goodId . count ( id ) = = 1 ) {
if ( ! info . IsGood ( ) & & goodId . count ( id ) = = 1 ) {
goodId . erase ( id ) ;
goodId . erase ( id ) ;
printf ( " %s: not good; %i good nodes left \n " , ToString ( addr ) . c_str ( ) , ( int ) goodId . size ( ) ) ;
// printf("%s: not good; %i good nodes left\n", ToString(addr).c_str(), (int)goodId.size());
}
}
ourId . push_back ( id ) ;
ourId . push_back ( id ) ;
}
}
@ -133,7 +133,7 @@ void CAddrDb::Skipped_(const CIPPort &addr)
if ( id = = - 1 ) return ;
if ( id = = - 1 ) return ;
unkId . erase ( id ) ;
unkId . erase ( id ) ;
ourId . push_back ( id ) ;
ourId . push_back ( id ) ;
printf ( " %s: skipped \n " , ToString ( addr ) . c_str ( ) ) ;
// printf("%s: skipped\n", ToString(addr).c_str());
nDirty + + ;
nDirty + + ;
}
}