Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/bitcoin.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | void GotVersion() { | ||||
BeginMessage("getaddr"); | BeginMessage("getaddr"); | ||||
EndMessage(); | EndMessage(); | ||||
doneAfter = time(nullptr) + GetTimeout(); | doneAfter = time(nullptr) + GetTimeout(); | ||||
} else { | } else { | ||||
doneAfter = time(nullptr) + 1; | doneAfter = time(nullptr) + 1; | ||||
} | } | ||||
} | } | ||||
bool ProcessMessage(std::string strCommand, CDataStream &vRecv) { | bool ProcessMessage(std::string strCommand, CDataStream &recv) { | ||||
// printf("%s: RECV %s\n", ToString(you).c_str(), | // printf("%s: RECV %s\n", ToString(you).c_str(), | ||||
// strCommand.c_str()); | // strCommand.c_str()); | ||||
if (strCommand == "version") { | if (strCommand == "version") { | ||||
int64_t nTime; | int64_t nTime; | ||||
CAddress addrMe; | CAddress addrMe; | ||||
CAddress addrFrom; | CAddress addrFrom; | ||||
uint64_t nNonce = 1; | uint64_t nNonce = 1; | ||||
uint64_t nServiceInt; | uint64_t nServiceInt; | ||||
vRecv >> nVersion >> nServiceInt >> nTime >> addrMe; | recv >> nVersion >> nServiceInt >> nTime >> addrMe; | ||||
you.nServices = ServiceFlags(nServiceInt); | you.nServices = ServiceFlags(nServiceInt); | ||||
if (nVersion == 10300) nVersion = 300; | if (nVersion == 10300) nVersion = 300; | ||||
if (nVersion >= 106 && !vRecv.empty()) vRecv >> addrFrom >> nNonce; | if (nVersion >= 106 && !recv.empty()) recv >> addrFrom >> nNonce; | ||||
if (nVersion >= 106 && !vRecv.empty()) vRecv >> strSubVer; | if (nVersion >= 106 && !recv.empty()) recv >> strSubVer; | ||||
if (nVersion >= 209 && !vRecv.empty()) vRecv >> nStartingHeight; | if (nVersion >= 209 && !recv.empty()) recv >> nStartingHeight; | ||||
if (nVersion >= 209) { | if (nVersion >= 209) { | ||||
BeginMessage("verack"); | BeginMessage("verack"); | ||||
EndMessage(); | EndMessage(); | ||||
} | } | ||||
vSend.SetVersion(std::min(nVersion, PROTOCOL_VERSION)); | vSend.SetVersion(std::min(nVersion, PROTOCOL_VERSION)); | ||||
if (nVersion < 209) { | if (nVersion < 209) { | ||||
this->vRecv.SetVersion(std::min(nVersion, PROTOCOL_VERSION)); | vRecv.SetVersion(std::min(nVersion, PROTOCOL_VERSION)); | ||||
GotVersion(); | GotVersion(); | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
if (strCommand == "verack") { | if (strCommand == "verack") { | ||||
this->vRecv.SetVersion(std::min(nVersion, PROTOCOL_VERSION)); | vRecv.SetVersion(std::min(nVersion, PROTOCOL_VERSION)); | ||||
GotVersion(); | GotVersion(); | ||||
return false; | return false; | ||||
} | } | ||||
if (strCommand == "addr" && vAddr) { | if (strCommand == "addr" && vAddr) { | ||||
std::vector<CAddress> vAddrNew; | std::vector<CAddress> vAddrNew; | ||||
vRecv >> vAddrNew; | recv >> vAddrNew; | ||||
// printf("%s: got %i addresses\n", ToString(you).c_str(), | // printf("%s: got %i addresses\n", ToString(you).c_str(), | ||||
// (int)vAddrNew.size()); | // (int)vAddrNew.size()); | ||||
int64_t now = time(nullptr); | int64_t now = time(nullptr); | ||||
std::vector<CAddress>::iterator it = vAddrNew.begin(); | std::vector<CAddress>::iterator it = vAddrNew.begin(); | ||||
if (vAddrNew.size() > 1) { | if (vAddrNew.size() > 1) { | ||||
if (doneAfter == 0 || doneAfter > now + 1) doneAfter = now + 1; | if (doneAfter == 0 || doneAfter > now + 1) doneAfter = now + 1; | ||||
} | } | ||||
while (it != vAddrNew.end()) { | while (it != vAddrNew.end()) { | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |