5#ifndef BITCOIN_SEEDER_DB_H
6#define BITCOIN_SEEDER_DB_H
8#include <chainparams.h>
26#define REQUIRE_VERSION 70001
39 while (str.size() < 22) {
55 double f = exp(-age /
tau);
62 READWRITE(obj.weight, obj.count, obj.reliability);
217 READWRITE(version, obj.ip, obj.services, obj.lastTry);
218 uint8_t tried = obj.ourLastTry != 0;
224 READWRITE(obj.ourLastTry, obj.ignoreTill, obj.stat2H, obj.stat8H,
225 obj.stat1D, obj.stat1W);
231 READWRITE(obj.total, obj.success, obj.clientVersion);
248 SER_READ(obj, obj.checkpointVerified =
true);
307 void Good_(
const CService &ip,
int clientV, std::string clientSV,
308 int blocks, uint64_t services,
bool checkpointVerified);
315 void GetIPs_(std::set<CNetAddr> &ips, uint64_t requestedFlags, uint32_t max,
329 if (
ourId.size() > 0) {
337 for (std::map<int, SeederAddrInfo>::iterator it =
idToInfo.begin();
339 (*it).second.ignoreTill = 0;
344 std::vector<CAddrReport> ret;
346 for (std::deque<int>::const_iterator it =
ourId.begin();
347 it !=
ourId.end(); it++) {
365 template <
typename Stream>
void Serialize(Stream &s)
const {
374 for (std::deque<int>::const_iterator it =
ourId.begin();
375 it !=
ourId.end(); it++) {
376 std::map<int, SeederAddrInfo>::iterator ci =
db->
idToInfo.find(*it);
379 for (std::set<int>::const_iterator it =
unkId.begin();
380 it !=
unkId.end(); it++) {
381 std::map<int, SeederAddrInfo>::iterator ci =
db->
idToInfo.find(*it);
397 for (
int i = 0; i < n; i++) {
423 void Add(
const std::vector<CAddress> &vAddr,
bool fForce =
false) {
425 for (
size_t i = 0; i < vAddr.size(); i++) {
426 Add_(vAddr[i], fForce);
430 void GetMany(std::vector<CServiceResult> &ips,
int max) {
444 for (
size_t i = 0; i < ips.size(); i++) {
446 Good_(ips[i].service, ips[i].nClientV, ips[i].strClientV,
447 ips[i].
nHeight, ips[i].services,
448 ips[i].checkpointVerified);
450 Bad_(ips[i].service, ips[i].nBanTime);
455 void GetIPs(std::set<CNetAddr> &ips, uint64_t requestedFlags, uint32_t max,
458 GetIPs_(ips, requestedFlags, max, nets);
const CChainParams & Params()
Return the currently selected parameters.
void Add(const CAddress &addr, bool fForce=false)
void GetMany(std::vector< CServiceResult > &ips, int max)
void Bad_(const CService &ip, int ban)
void ResultMany(const std::vector< CServiceResult > &ips)
void GetStats(CAddrDbStats &stats) const
void GetIPs_(std::set< CNetAddr > &ips, uint64_t requestedFlags, uint32_t max, const bool *nets)
void Good_(const CService &ip, int clientV, std::string clientSV, int blocks, uint64_t services, bool checkpointVerified)
std::vector< CAddrReport > GetAll()
void GetIPs(std::set< CNetAddr > &ips, uint64_t requestedFlags, uint32_t max, const bool *nets)
void Unserialize(Stream &s)
std::map< CService, int > ipToId
std::map< CService, int64_t > banned
std::map< int, SeederAddrInfo > idToInfo
bool Get_(CServiceResult &ip)
void Add(const std::vector< CAddress > &vAddr, bool fForce=false)
void Serialize(Stream &s) const
void Add_(const CAddress &addr, bool force)
int Lookup_(const CService &ip)
std::string clientSubVersion
ReliabilityStatus reliabilityStatus
SERIALIZE_METHODS(CAddrStat, obj)
void Update(bool good, int64_t age, double tau)
A CService with information about it as peer.
const CCheckpointData & Checkpoints() const
A combination of a network address (CNetAddr) and a (TCP) port.
std::string ToString() const
SERIALIZE_METHODS(SeederAddrInfo, obj)
int64_t GetIgnoreTime() const
CAddrReport GetReport() const
int64_t GetBanTime() const
std::string clientSubVersion
ReliabilityStatus GetReliabilityStatus() const
static const uint8_t tau[]
static int GetRequireHeight()
static bool HasCheckpoint()
static std::string ToString(const CService &ip)
#define SER_WRITE(obj, code)
#define SER_READ(obj, code)
MapCheckpoints mapCheckpoints
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.