more compact CAddrInfo serialization + bugfix

This commit is contained in:
Pieter Wuille 2011-12-23 13:43:28 +01:00
parent 8b2c4eca5f
commit 0553a002d4
2 changed files with 15 additions and 11 deletions

4
db.cpp
View file

@ -61,7 +61,7 @@ bool CAddrDb::Get_(CIPPort &ip, int &wait) {
} }
unkId.erase(ret); unkId.erase(ret);
} else { } else {
int ret = ourId.front(); ret = ourId.front();
if (time(NULL) - idToInfo[ret].ourLastTry < MIN_RETRY) return false; if (time(NULL) - idToInfo[ret].ourLastTry < MIN_RETRY) return false;
ourId.pop_front(); ourId.pop_front();
} }
@ -169,7 +169,7 @@ void CAddrDb::Add_(const CAddress &addr) {
int id = nId++; int id = nId++;
idToInfo[id] = ai; idToInfo[id] = ai;
ipToId[ipp] = id; ipToId[ipp] = id;
printf("%s: added\n", ToString(ipp).c_str(), ipToId[ipp]); // printf("%s: added\n", ToString(ipp).c_str(), ipToId[ipp]);
unkId.insert(id); unkId.insert(id);
nDirty++; nDirty++;
} }

22
db.h
View file

@ -100,15 +100,19 @@ public:
READWRITE(ip); READWRITE(ip);
READWRITE(services); READWRITE(services);
READWRITE(lastTry); READWRITE(lastTry);
READWRITE(ourLastTry); unsigned char tried = ourLastTry != 0;
READWRITE(ignoreTill); READWRITE(tried);
READWRITE(stat2H); if (tried) {
READWRITE(stat8H); READWRITE(ourLastTry);
READWRITE(stat1D); READWRITE(ignoreTill);
READWRITE(stat1W); READWRITE(stat2H);
READWRITE(total); READWRITE(stat8H);
READWRITE(success); READWRITE(stat1D);
READWRITE(clientVersion); READWRITE(stat1W);
READWRITE(total);
READWRITE(success);
READWRITE(clientVersion);
}
) )
}; };