21 #define BITCOIN_SEED_NONCE 0x0539a019ca550825ULL
48 recv >>
nVersion >> nServiceInt >> nTime >> addrMe;
50 recv >> addrFrom >> nNonce;
65 std::vector<BlockHash> locatorHash(
77 std::vector<CAddress> vAddrNew;
83 std::vector<CAddress>::iterator it = vAddrNew.begin();
84 if (vAddrNew.size() > 1) {
89 while (it != vAddrNew.end()) {
95 if (addr.
nTime <= 100000000 || addr.
nTime > now + 600) {
96 addr.
nTime = now - 5 * 86400;
98 if (addr.
nTime > now - 604800) {
99 vAddr->push_back(addr);
125 uint32_t nHeaderSize =
127 if (
vRecv.
end() - pstart < nHeaderSize) {
178 nMessageStart(-1), nVersion(0), vAddr(vAddrIn), ban(0), doneAfter(0),
189 bool connected =
false;
193 bool proxyConnectionFailed =
false;
202 proxyConnectionFailed);
223 uint64_t nLocalServices = 0;
227 uint8_t fRelayTxs = 0;
230 const std::string clientVersion =
236 nLocalServices,
GetTime(),
you, me, nLocalNonce,
244 char pchBuf[0x10000];
248 FD_ZERO(&fdsetError);
249 FD_SET(
sock->Get(), &fdsetRecv);
250 FD_SET(
sock->Get(), &fdsetError);
260 select(
sock->Get() + 1, &fdsetRecv,
nullptr, &fdsetError, &wa);
267 int nBytes =
sock->Recv(pchBuf,
sizeof(pchBuf), 0);
271 memcpy(&
vRecv[nPos], pchBuf, nBytes);
272 }
else if (nBytes == 0) {
291 return (
ban == 0) && res;
const CChainParams & Params()
Return the currently selected parameters.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
A CService with information about it as peer.
const CMessageHeader::MessageMagic & NetMagic() const
Double ended buffer combining vector and stream-like interfaces.
const_iterator begin() const
const_iterator end() const
void resize(size_type n, value_type c=0)
vector_type::iterator iterator
iterator erase(iterator it)
iterator insert(iterator it, const char x=char())
std::string ToStringIP() const
enum Network GetNetwork() const
CSeederNode(const CService &ip, std::vector< CAddress > *vAddrIn)
std::vector< CAddress > * vAddr
PeerMessagingState ProcessMessage(std::string strCommand, CDataStream &recv)
std::unique_ptr< Sock > sock
A combination of a network address (CNetAddr) and a (TCP) port.
std::string FormatVersion(int nVersion)
std::string FormatUserAgent(const std::string &name, const std::string &version, const std::vector< std::string > &comments)
Format the subversion field according to BIP 14 spec.
static constexpr int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
const std::string CLIENT_NAME
uint256 Hash(const T &in1)
Compute the 256-bit hash of an object.
Block-chain checkpoints are compiled-in sanity checks.
static void WriteMessage(CDataStream &stream, std::string command, Args &&...args)
const char * GETADDR
The getaddr message requests an addr message from the receiving node, preferably one with lots of IP ...
const char * ADDR
The addr (IP address) message relays connection information for peers on the network.
const char * VERSION
The version message provides information about the transmitting node to the receiving node at the beg...
const char * GETHEADERS
The getheaders message requests a headers message that provides block headers starting from a particu...
const char * VERACK
The verack message acknowledges a previously-received version message, informing the connecting node ...
std::string userAgent(const Config &config)
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
bool ConnectThroughProxy(const proxyType &proxy, const std::string &strDest, uint16_t port, const Sock &sock, int nTimeout, bool &outProxyConnectionFailed)
Connect to a specified destination service through a SOCKS5 proxy by first connecting to the SOCKS5 p...
bool ConnectSocketDirectly(const CService &addrConnect, const Sock &sock, int nTimeout, bool manual_connection)
Try to connect to the specified service on the specified socket.
std::function< std::unique_ptr< Sock >const CService &)> CreateSock
Socket factory.
ServiceFlags
nServices flags.
#define BITCOIN_SEED_NONCE
static const unsigned int ADDR_SOFT_CAP
static int GetRequireHeight()
static constexpr uint64_t MAX_SIZE
The maximum size of a serialized object in bytes or number of elements (for eg vectors) when the size...
size_t GetSerializeSize(const T &t, int nVersion=0)
constexpr Span< A > MakeSpan(A(&a)[N])
MakeSpan for arrays:
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
T GetTime()
Return system time (or mocked time, if set)
static const int PROTOCOL_VERSION
network protocol versioning