7#include <chainparams.h>
20#include <validation.h>
24#define BITCOIN_SEED_NONCE 0x0539a019ca550825ULL
50 recv >>
nVersion >> nServiceInt >> nTime;
75 auto doneAfterDelta{1s};
87 std::vector<BlockHash> locatorHash(
93 doneAfter = Now<NodeSeconds>() + doneAfterDelta;
99 std::vector<CAddress> vAddrNew;
104 auto now = Now<NodeSeconds>();
105 std::vector<CAddress>::iterator it = vAddrNew.begin();
106 if (vAddrNew.size() > 1) {
108 (TicksSinceEpoch<std::chrono::seconds>(
doneAfter) == 0 ||
113 while (it != vAddrNew.end()) {
120 addr.
nTime > now + 10min) {
121 addr.
nTime = now - 5 * 24h;
123 if (addr.
nTime > now - 7 * 24h) {
124 vAddr->push_back(addr);
197 uint32_t nHeaderSize =
199 if (
vRecv.
end() - pstart < nHeaderSize) {
206 std::vector<std::byte> vHeaderSave(
vRecv.
begin(),
261 bool connected =
false;
265 bool proxyConnectionFailed =
false;
274 proxyConnectionFailed);
296 uint64_t nLocalServices = 0;
300 uint8_t fRelayTxs = 0;
303 const std::string clientVersion =
309 nLocalServices,
GetTime(), your_services,
you,
316 while (now = Now<NodeSeconds>(),
318 (TicksSinceEpoch<std::chrono::seconds>(
doneAfter) == 0 ||
321 char pchBuf[0x10000];
325 FD_ZERO(&fdsetError);
326 FD_SET(
sock->Get(), &fdsetRecv);
327 FD_SET(
sock->Get(), &fdsetError);
329 if (TicksSinceEpoch<std::chrono::seconds>(
doneAfter) != 0) {
337 select(
sock->Get() + 1, &fdsetRecv,
nullptr, &fdsetError, &wa);
339 if (TicksSinceEpoch<std::chrono::seconds>(
doneAfter) == 0) {
344 int nBytes =
sock->Recv(pchBuf,
sizeof(pchBuf), 0);
348 memcpy(&
vRecv[nPos], pchBuf, nBytes);
349 }
else if (nBytes == 0) {
368 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 value_type x)
const_iterator end() const
vector_type::iterator iterator
void resize(size_type n, value_type c=value_type{})
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 * HEADERS
The headers message sends one or more block headers to a node which previously requested certain head...
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)
static const unsigned int MAX_HEADERS_RESULTS
Number of headers sent in one getheaders result.
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...
std::function< std::unique_ptr< Sock >(const CService &)> CreateSock
Socket factory.
bool ConnectSocketDirectly(const CService &addrConnect, const Sock &sock, int nTimeout, bool manual_connection)
Try to connect to the specified service on the specified socket.
ServiceFlags
nServices flags.
#define BITCOIN_SEED_NONCE
static const unsigned int ADDR_SOFT_CAP
static int GetRequireHeight()
static bool HasCheckpoint()
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...
uint64_t ReadCompactSize(Stream &is, bool range_check=true)
Decode a CompactSize-encoded variable-length integer.
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...
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds
static const int PROTOCOL_VERSION
network protocol versioning