Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/db.h
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | public: | ||||
bool fGood; | bool fGood; | ||||
uint64_t services; | uint64_t services; | ||||
}; | }; | ||||
class CAddrInfo { | class CAddrInfo { | ||||
private: | private: | ||||
CService ip; | CService ip; | ||||
uint64_t services; | uint64_t services; | ||||
int64_t timeFirstFound; | |||||
int64_t lastTry; | int64_t lastTry; | ||||
int64_t ourLastTry; | int64_t ourLastTry; | ||||
int64_t ourLastSuccess; | int64_t ourLastSuccess; | ||||
int64_t ignoreTill; | int64_t ignoreTill; | ||||
CAddrStat stat2H; | CAddrStat stat2H; | ||||
CAddrStat stat8H; | CAddrStat stat8H; | ||||
CAddrStat stat1D; | CAddrStat stat1D; | ||||
CAddrStat stat1W; | CAddrStat stat1W; | ||||
CAddrStat stat1M; | CAddrStat stat1M; | ||||
int clientVersion; | int clientVersion; | ||||
int blocks; | int blocks; | ||||
int total; | int total; | ||||
int success; | int success; | ||||
std::string clientSubVersion; | std::string clientSubVersion; | ||||
protected: | |||||
bool hasRunTestNodeBefore() const { return total > 0; } | |||||
jasonbcox: This name indicates information about its caller, which it shouldn't know in the first place. | |||||
int64_t timeSinceFoundOrLastSuccess(int64_t now = time(nullptr)) { | |||||
jasonbcoxUnsubmitted Not Done Inline Actionsnow is never set by the caller, so why make it a parameter? jasonbcox: `now` is never set by the caller, so why make it a parameter? | |||||
return now - success > 0 ? ourLastSuccess : timeFirstFound; | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsThis was very confusing to read. Order of operations... jasonbcox: This was very confusing to read. Order of operations... | |||||
} | |||||
public: | public: | ||||
CAddrInfo() | CAddrInfo() | ||||
: services(0), lastTry(0), ourLastTry(0), ourLastSuccess(0), | : services(0), timeFirstFound(time(nullptr)), lastTry(0), ourLastTry(0), | ||||
ignoreTill(0), clientVersion(0), blocks(0), total(0), success(0) {} | ourLastSuccess(0), ignoreTill(0), clientVersion(0), blocks(0), | ||||
total(0), success(0) {} | |||||
CAddrReport GetReport() const { | CAddrReport GetReport() const { | ||||
CAddrReport ret; | CAddrReport ret; | ||||
ret.ip = ip; | ret.ip = ip; | ||||
ret.clientVersion = clientVersion; | ret.clientVersion = clientVersion; | ||||
ret.clientSubVersion = clientSubVersion; | ret.clientSubVersion = clientSubVersion; | ||||
ret.blocks = blocks; | ret.blocks = blocks; | ||||
ret.uptime[0] = stat2H.reliability; | ret.uptime[0] = stat2H.reliability; | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
READWRITE(services); | READWRITE(services); | ||||
READWRITE(lastTry); | READWRITE(lastTry); | ||||
uint8_t tried = ourLastTry != 0; | uint8_t tried = ourLastTry != 0; | ||||
READWRITE(tried); | READWRITE(tried); | ||||
if (!tried) { | if (!tried) { | ||||
return; | return; | ||||
} | } | ||||
READWRITE(timeFirstFound); | |||||
READWRITE(ourLastTry); | READWRITE(ourLastTry); | ||||
READWRITE(ignoreTill); | READWRITE(ignoreTill); | ||||
READWRITE(stat2H); | READWRITE(stat2H); | ||||
READWRITE(stat8H); | READWRITE(stat8H); | ||||
READWRITE(stat1D); | READWRITE(stat1D); | ||||
READWRITE(stat1W); | READWRITE(stat1W); | ||||
if (version >= 1) { | if (version >= 1) { | ||||
READWRITE(stat1M); | READWRITE(stat1M); | ||||
Show All 23 Lines | public: | ||||
int nNew; | int nNew; | ||||
int nGood; | int nGood; | ||||
int nAge; | int nAge; | ||||
}; | }; | ||||
struct CServiceResult { | struct CServiceResult { | ||||
CService service; | CService service; | ||||
bool fGood; | bool fGood; | ||||
bool fReliable; | |||||
int nBanTime; | int nBanTime; | ||||
int nHeight; | int nHeight; | ||||
int nClientV; | int nClientV; | ||||
std::string strClientV; | std::string strClientV; | ||||
int64_t ourLastSuccess; | int64_t ourLastSuccess; | ||||
bool hasRunTestNodeBefore; | |||||
int64_t timeSinceFoundOrLastSuccess; | |||||
jasonbcoxUnsubmitted Not Done Inline Actionswhy expose these here? Can't fReliable be inclusive of this information? jasonbcox: why expose these here? Can't fReliable be inclusive of this information? | |||||
}; | }; | ||||
/** | /** | ||||
* seen nodes | * seen nodes | ||||
* / \ | * / \ | ||||
* (a) banned nodes available nodes-------------- | * (a) banned nodes available nodes-------------- | ||||
* / | \ | * / | \ | ||||
* tracked nodes (b) unknown nodes (e) active nodes | * tracked nodes (b) unknown nodes (e) active nodes | ||||
▲ Show 20 Lines • Show All 183 Lines • Show Last 20 Lines |
This name indicates information about its caller, which it shouldn't know in the first place. This class doesn't know what "TestNode" is and that name is liable to change anyway.
In the context of this specific class, hasBeenTriedBefore() makes more sense IMO. If this comment is confusing, reread my older comments carefully.