Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/bitcoin.cpp
// Copyright (c) 2017-2020 The Bitcoin developers | // Copyright (c) 2017-2020 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <seeder/bitcoin.h> | #include <seeder/bitcoin.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <clientversion.h> | |||||
#include <hash.h> | #include <hash.h> | ||||
#include <netbase.h> | #include <netbase.h> | ||||
#include <primitives/blockhash.h> | #include <primitives/blockhash.h> | ||||
#include <seeder/db.h> | #include <seeder/db.h> | ||||
#include <seeder/messagewriter.h> | #include <seeder/messagewriter.h> | ||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <util/time.h> | #include <util/time.h> | ||||
▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | if (!connected) { | ||||
return false; | return false; | ||||
} | } | ||||
// Write version message | // Write version message | ||||
uint64_t nLocalServices = 0; | uint64_t nLocalServices = 0; | ||||
uint64_t nLocalNonce = BITCOIN_SEED_NONCE; | uint64_t nLocalNonce = BITCOIN_SEED_NONCE; | ||||
CService myService; | CService myService; | ||||
CAddress me(myService, ServiceFlags(NODE_NETWORK)); | CAddress me(myService, ServiceFlags(NODE_NETWORK)); | ||||
std::string ver = "/bitcoin-cash-seeder:0.15/"; | |||||
const std::string clientName = gArgs.GetArg("-uaclientname", CLIENT_NAME); | |||||
const std::string clientVersion = | |||||
gArgs.GetArg("-uaclientversion", FormatVersion(CLIENT_VERSION)); | |||||
const std::string userAgent = | |||||
FormatUserAgent(clientName, clientVersion, {"seeder"}); | |||||
MessageWriter::WriteMessage(vSend, NetMsgType::VERSION, PROTOCOL_VERSION, | MessageWriter::WriteMessage(vSend, NetMsgType::VERSION, PROTOCOL_VERSION, | ||||
nLocalServices, GetTime(), you, me, nLocalNonce, | nLocalServices, GetTime(), you, me, nLocalNonce, | ||||
ver, GetRequireHeight()); | userAgent, GetRequireHeight()); | ||||
Send(); | Send(); | ||||
bool res = true; | bool res = true; | ||||
int64_t now; | int64_t now; | ||||
while (now = GetTime(), ban == 0 && (doneAfter == 0 || doneAfter > now) && | while (now = GetTime(), ban == 0 && (doneAfter == 0 || doneAfter > now) && | ||||
sock != INVALID_SOCKET) { | sock != INVALID_SOCKET) { | ||||
char pchBuf[0x10000]; | char pchBuf[0x10000]; | ||||
fd_set fdsetRecv; | fd_set fdsetRecv; | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |