Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/db.h
Show First 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | public: | ||||
int nTracked; | int nTracked; | ||||
int nNew; | int nNew; | ||||
int nGood; | int nGood; | ||||
int nAge; | int nAge; | ||||
}; | }; | ||||
struct CServiceResult { | struct CServiceResult { | ||||
CService service; | CService service; | ||||
uint64_t services; | |||||
bool fGood; | bool fGood; | ||||
int nBanTime; | int nBanTime; | ||||
int nHeight; | int nHeight; | ||||
int nClientV; | int nClientV; | ||||
std::string strClientV; | std::string strClientV; | ||||
int64_t ourLastSuccess; | int64_t ourLastSuccess; | ||||
}; | }; | ||||
Show All 26 Lines | |||||
protected: | protected: | ||||
// internal routines that assume proper locks are acquired | // internal routines that assume proper locks are acquired | ||||
// add an address | // add an address | ||||
void Add_(const CAddress &addr, bool force); | void Add_(const CAddress &addr, bool force); | ||||
// get an IP to test (must call Good_ or Bad_ on result afterwards) | // get an IP to test (must call Good_ or Bad_ on result afterwards) | ||||
bool Get_(CServiceResult &ip, int &wait); | bool Get_(CServiceResult &ip, int &wait); | ||||
// mark an IP as good (must have been returned by Get_) | // mark an IP as good (must have been returned by Get_) | ||||
void Good_(const CService &ip, int clientV, std::string clientSV, | void Good_(const CService &ip, int clientV, std::string clientSV, | ||||
int blocks); | int blocks, uint64_t services); | ||||
// mark an IP as bad (and optionally ban it) (must have been returned by | // mark an IP as bad (and optionally ban it) (must have been returned by | ||||
// Get_) | // Get_) | ||||
void Bad_(const CService &ip, int ban); | void Bad_(const CService &ip, int ban); | ||||
// look up id of an IP | // look up id of an IP | ||||
int Lookup_(const CService &ip); | int Lookup_(const CService &ip); | ||||
// get a random set of IPs (shared lock only) | // get a random set of IPs (shared lock only) | ||||
void GetIPs_(std::set<CNetAddr> &ips, uint64_t requestedFlags, uint32_t max, | void GetIPs_(std::set<CNetAddr> &ips, uint64_t requestedFlags, uint32_t max, | ||||
const bool *nets); | const bool *nets); | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | void GetMany(std::vector<CServiceResult> &ips, int max, int &wait) { | ||||
} | } | ||||
} | } | ||||
void ResultMany(const std::vector<CServiceResult> &ips) { | void ResultMany(const std::vector<CServiceResult> &ips) { | ||||
LOCK(cs); | LOCK(cs); | ||||
for (size_t i = 0; i < ips.size(); i++) { | for (size_t i = 0; i < ips.size(); i++) { | ||||
if (ips[i].fGood) { | if (ips[i].fGood) { | ||||
Good_(ips[i].service, ips[i].nClientV, ips[i].strClientV, | Good_(ips[i].service, ips[i].nClientV, ips[i].strClientV, | ||||
ips[i].nHeight); | ips[i].nHeight, ips[i].services); | ||||
} else { | } else { | ||||
Bad_(ips[i].service, ips[i].nBanTime); | Bad_(ips[i].service, ips[i].nBanTime); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void GetIPs(std::set<CNetAddr> &ips, uint64_t requestedFlags, uint32_t max, | void GetIPs(std::set<CNetAddr> &ips, uint64_t requestedFlags, uint32_t max, | ||||
const bool *nets) { | const bool *nets) { | ||||
LOCK(cs); | LOCK(cs); | ||||
GetIPs_(ips, requestedFlags, max, nets); | GetIPs_(ips, requestedFlags, max, nets); | ||||
} | } | ||||
}; | }; | ||||
#endif // BITCOIN_SEEDER_DB_H | #endif // BITCOIN_SEEDER_DB_H |