Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/db.h
#ifndef BITCOIN_SEEDER_DB_H | #ifndef BITCOIN_SEEDER_DB_H | ||||
#define BITCOIN_SEEDER_DB_H | #define BITCOIN_SEEDER_DB_H | ||||
#include "address.h" | |||||
#include "bitcoin.h" | |||||
#include "netbase.h" | #include "netbase.h" | ||||
#include "protocol.h" | #include "protocol.h" | ||||
#include "sync.h" | #include "sync.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "version.h" | #include "version.h" | ||||
#include <cmath> | #include <cmath> | ||||
#include <cstdint> | #include <cstdint> | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | private: | ||||
std::set<int> unkId; | std::set<int> unkId; | ||||
// 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 CSeederAddress &addr, bool force); | ||||
// get an IP to test (must call Good_, Bad_, or Skipped_ on result | // get an IP to test (must call Good_, Bad_, or Skipped_ on result | ||||
// afterwards) | // afterwards) | ||||
bool Get_(CSeederServiceResult &ip, int &wait); | bool Get_(CSeederServiceResult &ip, int &wait); | ||||
bool GetMany_(std::vector<CSeederServiceResult> &ips, int max, int &wait); | bool GetMany_(std::vector<CSeederServiceResult> &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 CSeederService &ip, int clientV, std::string clientSV, | void Good_(const CSeederService &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 | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | template <typename Stream> void Unserialize(Stream &s) { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
db->nDirty++; | db->nDirty++; | ||||
s >> banned; | s >> banned; | ||||
} | } | ||||
void Add(const CAddress &addr, bool fForce = false) { | void Add(const CSeederAddress &addr, bool fForce = false) { | ||||
LOCK(cs); | LOCK(cs); | ||||
Add_(addr, fForce); | Add_(addr, fForce); | ||||
} | } | ||||
void Add(const std::vector<CAddress> &vAddr, bool fForce = false) { | void Add(const std::vector<CSeederAddress> &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 CSeederService &addr, int clientVersion, | void Good(const CSeederService &addr, int clientVersion, | ||||
std::string clientSubVersion, int blocks) { | std::string clientSubVersion, int blocks) { | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |