Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/bitcoin.cpp
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | if (strCommand == NetMsgType::VERACK) { | ||||
vRecv.SetVersion(std::min(nVersion, PROTOCOL_VERSION)); | vRecv.SetVersion(std::min(nVersion, PROTOCOL_VERSION)); | ||||
// tfm::format(std::cout, "\n%s: version %i\n", ToString(you), | // tfm::format(std::cout, "\n%s: version %i\n", ToString(you), | ||||
// nVersion); | // nVersion); | ||||
if (vAddr) { | if (vAddr) { | ||||
BeginMessage(NetMsgType::GETADDR); | BeginMessage(NetMsgType::GETADDR); | ||||
EndMessage(); | EndMessage(); | ||||
doneAfter = time(nullptr) + GetTimeout(); | doneAfter = time(nullptr) + GetTimeout(); | ||||
} else { | } else { | ||||
// Create a getheaders message | |||||
BeginMessage(NetMsgType::GETHEADERS); | |||||
// Locator hash: Seeder requests the headers after the latest | |||||
// checkpoint | |||||
const CChainParams &chainParams = Params(); | |||||
const auto checkpoints = chainParams.Checkpoints().mapCheckpoints; | |||||
std::vector<BlockHash> locatorHashes(1, | |||||
checkpoints.rbegin()->second); | |||||
vSend << PROTOCOL_VERSION << locatorHashes << uint256(); | |||||
EndMessage(); | |||||
doneAfter = time(nullptr) + 1; | doneAfter = time(nullptr) + 1; | ||||
} | } | ||||
return PeerMessagingState::AwaitingMessages; | return PeerMessagingState::AwaitingMessages; | ||||
} | } | ||||
if (strCommand == NetMsgType::ADDR && vAddr) { | if (strCommand == NetMsgType::ADDR && vAddr) { | ||||
std::vector<CAddress> vAddrNew; | std::vector<CAddress> vAddrNew; | ||||
recv >> vAddrNew; | recv >> vAddrNew; | ||||
Show All 22 Lines | if (strCommand == NetMsgType::ADDR && vAddr) { | ||||
// tfm::format(std::cout, "%s: added address %s (#%i)\n", | // tfm::format(std::cout, "%s: added address %s (#%i)\n", | ||||
// ToString(you), | // ToString(you), | ||||
// addr.ToString(), (int)(vAddr->size())); | // addr.ToString(), (int)(vAddr->size())); | ||||
if (vAddr->size() > ADDR_SOFT_CAP) { | if (vAddr->size() > ADDR_SOFT_CAP) { | ||||
doneAfter = 1; | doneAfter = 1; | ||||
return PeerMessagingState::Finished; | return PeerMessagingState::Finished; | ||||
} | } | ||||
} | } | ||||
// Create a getheaders message | |||||
BeginMessage(NetMsgType::GETHEADERS); | |||||
// Locator hash: Seeder requests the headers after the latest checkpoint | |||||
const CChainParams &chainParams = Params(); | |||||
const auto checkpoints = chainParams.Checkpoints().mapCheckpoints; | |||||
std::vector<BlockHash> locatorHashes(1, checkpoints.rbegin()->second); | |||||
vSend << PROTOCOL_VERSION << locatorHashes << uint256(); | |||||
EndMessage(); | |||||
// Update socket timeout | |||||
doneAfter = time(nullptr) + GetTimeout(); | |||||
Fabien: As far as I can tell this is the only line that differentiate this block from the above one. | |||||
return PeerMessagingState::AwaitingMessages; | return PeerMessagingState::AwaitingMessages; | ||||
} | } | ||||
return PeerMessagingState::AwaitingMessages; | return PeerMessagingState::AwaitingMessages; | ||||
} | } | ||||
bool CSeederNode::ProcessMessages() { | bool CSeederNode::ProcessMessages() { | ||||
if (vRecv.empty()) { | if (vRecv.empty()) { | ||||
▲ Show 20 Lines • Show All 160 Lines • Show Last 20 Lines |
As far as I can tell this is the only line that differentiate this block from the above one. Please wrap this into a function to avoid copy and paste.