Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/db.h
Show First 20 Lines • Show All 291 Lines • ▼ Show 20 Lines | private: | ||||
// set of good nodes (d, good e) | // set of good nodes (d, good e) | ||||
std::set<int> goodId; | std::set<int> goodId; | ||||
int nDirty; | int nDirty; | ||||
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_, Bad_, or Skipped_ on result | // get an IP to test (must call Good_ or Bad_ on result afterwards) | ||||
// afterwards) | |||||
bool Get_(CServiceResult &ip, int &wait); | bool Get_(CServiceResult &ip, int &wait); | ||||
bool GetMany_(std::vector<CServiceResult> &ips, int max, 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); | ||||
// 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); | ||||
// mark an IP as skipped (must have been returned by Get_) | |||||
void Skipped_(const CService &ip); | |||||
// 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); | ||||
public: | public: | ||||
// nodes that are banned, with their unban time (a) | // nodes that are banned, with their unban time (a) | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | public: | ||||
void Add(const std::vector<CAddress> &vAddr, bool fForce = false) { | void Add(const std::vector<CAddress> &vAddr, bool fForce = false) { | ||||
LOCK(cs); | LOCK(cs); | ||||
for (size_t i = 0; i < vAddr.size(); i++) { | for (size_t i = 0; i < vAddr.size(); i++) { | ||||
Add_(vAddr[i], fForce); | Add_(vAddr[i], fForce); | ||||
} | } | ||||
} | } | ||||
void Good(const CService &addr, int clientVersion, | |||||
std::string clientSubVersion, int blocks) { | |||||
LOCK(cs); | |||||
Good_(addr, clientVersion, clientSubVersion, blocks); | |||||
} | |||||
void Skipped(const CService &addr) { | |||||
LOCK(cs); | |||||
Skipped_(addr); | |||||
} | |||||
void Bad(const CService &addr, int ban = 0) { | |||||
LOCK(cs); | |||||
Bad_(addr, ban); | |||||
} | |||||
bool Get(CServiceResult &ip, int &wait) { | |||||
LOCK(cs); | |||||
return Get_(ip, wait); | |||||
} | |||||
void GetMany(std::vector<CServiceResult> &ips, int max, int &wait) { | void GetMany(std::vector<CServiceResult> &ips, int max, int &wait) { | ||||
LOCK(cs); | LOCK(cs); | ||||
while (max > 0) { | while (max > 0) { | ||||
CServiceResult ip = {}; | CServiceResult ip = {}; | ||||
if (!Get_(ip, wait)) { | if (!Get_(ip, wait)) { | ||||
return; | return; | ||||
} | } | ||||
ips.push_back(ip); | ips.push_back(ip); | ||||
Show All 24 Lines |