21 #define BITCOIN_SEED_NONCE 0x0539a019ca550825ULL
47 recv >>
nVersion >> nServiceInt >> nTime;
74 std::vector<BlockHash> locatorHash(
86 std::vector<CAddress> vAddrNew;
91 auto now = Now<NodeSeconds>();
92 std::vector<CAddress>::iterator it = vAddrNew.begin();
93 if (vAddrNew.size() > 1) {
94 if (TicksSinceEpoch<std::chrono::seconds>(
doneAfter) == 0 ||
99 while (it != vAddrNew.end()) {
106 addr.
nTime > now + 10min) {
107 addr.
nTime = now - 5 * 24h;
109 if (addr.
nTime > now - 7 * 24h) {
110 vAddr->push_back(addr);
136 uint32_t nHeaderSize =
138 if (
vRecv.
end() - pstart < nHeaderSize) {
145 std::vector<uint8_t> vHeaderSave(
vRecv.
begin(),
190 nMessageStart(-1), nVersion(0), vAddr(vAddrIn), ban(0),
202 bool connected =
false;
206 bool proxyConnectionFailed =
false;
215 proxyConnectionFailed);
237 uint64_t nLocalServices = 0;
241 uint8_t fRelayTxs = 0;
244 const std::string clientVersion =
250 nLocalServices,
GetTime(), your_services,
you,
257 while (now = Now<NodeSeconds>(),
259 (TicksSinceEpoch<std::chrono::seconds>(
doneAfter) == 0 ||
262 char pchBuf[0x10000];
266 FD_ZERO(&fdsetError);
267 FD_SET(
sock->Get(), &fdsetRecv);
268 FD_SET(
sock->Get(), &fdsetError);
270 if (TicksSinceEpoch<std::chrono::seconds>(
doneAfter) != 0) {
278 select(
sock->Get() + 1, &fdsetRecv,
nullptr, &fdsetError, &wa);
280 if (TicksSinceEpoch<std::chrono::seconds>(
doneAfter) == 0) {
285 int nBytes =
sock->Recv(pchBuf,
sizeof(pchBuf), 0);
289 memcpy(&
vRecv[nPos], pchBuf, nBytes);
290 }
else if (nBytes == 0) {
309 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.
NodeSeconds nTime
Always included in serialization, except in the network format on INIT_PROTO_VERSION.
const CMessageHeader::MessageMagic & NetMagic() const
Double ended buffer combining vector and stream-like interfaces.
const_iterator begin() const
iterator insert(iterator it, const uint8_t x)
const_iterator end() const
void resize(size_type n, value_type c=0)
vector_type::iterator iterator
iterator erase(iterator it)
std::string ToStringIP() const
enum Network GetNetwork() const
CSeederNode(const CService &ip, std::vector< CAddress > *vAddrIn)
std::vector< CAddress > * vAddr
ServiceFlags yourServices
PeerMessagingState ProcessMessage(std::string strCommand, CDataStream &recv)
std::chrono::seconds GetTimeout()
std::unique_ptr< Sock > sock
A combination of a network address (CNetAddr) and a (TCP) port.
A Span is an object that can refer to a contiguous sequence of objects.
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 auto MakeUCharSpan(V &&v) -> decltype(UCharSpanCast(Span{std::forward< V >(v)}))
Like the Span constructor, but for (const) uint8_t member types only.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds
static const int PROTOCOL_VERSION
network protocol versioning