Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/bitcoin.cpp
Show First 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | do { | ||||
} | } | ||||
// tfm::format(std::cout, "%s: done processing %s\n", | // tfm::format(std::cout, "%s: done processing %s\n", | ||||
// ToString(you).c_str(), | // ToString(you).c_str(), | ||||
// strCommand.c_str()); | // strCommand.c_str()); | ||||
} while (1); | } while (1); | ||||
return false; | return false; | ||||
} | } | ||||
CSeederNode::CSeederNode(const CService &ip, std::vector<CAddress> *vAddrIn) | CSeederNode::CSeederNode(const CService &ip, const bool reliable, | ||||
const bool triedBefore, | |||||
const int64_t timeFirstFoundOrLastSuccess, | |||||
std::vector<CAddress> *vAddrIn) | |||||
: sock(INVALID_SOCKET), vSend(SER_NETWORK, 0), vRecv(SER_NETWORK, 0), | : sock(INVALID_SOCKET), vSend(SER_NETWORK, 0), vRecv(SER_NETWORK, 0), | ||||
nHeaderStart(-1), nMessageStart(-1), nVersion(0), vAddr(vAddrIn), ban(0), | nHeaderStart(-1), nMessageStart(-1), nVersion(0), vAddr(vAddrIn), ban(0), | ||||
doneAfter(0), you(ip, ServiceFlags(NODE_NETWORK | NODE_BITCOIN_CASH)), | doneAfter(0), you(ip, ServiceFlags(NODE_NETWORK | NODE_BITCOIN_CASH)), | ||||
checkpointState(CheckpointState::NotChecked) { | checkpointState(CheckpointState::NotChecked), isReliable(reliable), | ||||
hasBeenTriedBefore(triedBefore), | |||||
timeSinceFoundOrLastSuccess(timeFirstFoundOrLastSuccess) { | |||||
if (time(nullptr) > 1329696000) { | if (time(nullptr) > 1329696000) { | ||||
vSend.SetVersion(209); | vSend.SetVersion(209); | ||||
vRecv.SetVersion(209); | vRecv.SetVersion(209); | ||||
} | } | ||||
} | } | ||||
void CSeederNode::DetermineBan(bool testResult) { | |||||
// Post p2p-commincation banning logic | |||||
// Ban nodes that have failed this test, are not reliable, have been tested | |||||
// before, and whose last successful test was more than 2 days ago. | |||||
if (!testResult && !isReliable && hasBeenTriedBefore && | |||||
timeSinceFoundOrLastSuccess > 2 * 86400) { | |||||
ban = 100000; | |||||
} | |||||
} | |||||
bool CSeederNode::Run() { | bool CSeederNode::Run() { | ||||
// FIXME: This logic is duplicated with CConnman::ConnectNode for no | // FIXME: This logic is duplicated with CConnman::ConnectNode for no | ||||
// good reason. | // good reason. | ||||
bool connected = false; | bool connected = false; | ||||
proxyType proxy; | proxyType proxy; | ||||
if (you.IsValid()) { | if (you.IsValid()) { | ||||
bool proxyConnectionFailed = false; | bool proxyConnectionFailed = false; | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | while (now = time(nullptr), ban == 0 && | ||||
ProcessMessages(); | ProcessMessages(); | ||||
Send(); | Send(); | ||||
} | } | ||||
if (sock == INVALID_SOCKET) { | if (sock == INVALID_SOCKET) { | ||||
res = false; | res = false; | ||||
} | } | ||||
close(sock); | close(sock); | ||||
sock = INVALID_SOCKET; | sock = INVALID_SOCKET; | ||||
DetermineBan(res); | |||||
return (ban == 0) && res; | return (ban == 0) && res; | ||||
} | } |