Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
bitcoin.h
Go to the documentation of this file.
1// Copyright (c) 2017-2019 The Bitcoin developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_SEEDER_BITCOIN_H
6#define BITCOIN_SEEDER_BITCOIN_H
7
8#include <chainparams.h>
9#include <protocol.h>
10#include <streams.h>
11#include <util/time.h>
12
13#include <chrono>
14#include <cstdint>
15#include <string>
16#include <vector>
17
18static inline uint16_t GetDefaultPort() {
19 return Params().GetDefaultPort();
20}
21
22// After the 1000th addr, the seeder will only add one more address per addr
23// message.
24static const unsigned int ADDR_SOFT_CAP = 1000;
25
30
31class Sock;
32
33namespace {
34class CSeederNodeTest;
35}
36
38 friend class ::CSeederNodeTest;
39
40private:
41 std::unique_ptr<Sock> sock;
44 int nVersion{0};
45 std::string strSubVer;
47 std::vector<CAddress> *vAddr;
48 int ban{0};
52 bool checkpointVerified{false};
53 bool needAddrReply{false};
54
55 std::chrono::seconds GetTimeout() { return you.IsTor() ? 120s : 30s; }
56
57 void BeginMessage(const char *pszCommand);
58
60
61 void EndMessage();
62
63 void Send();
64
66
67 bool ProcessMessages();
68
69protected:
72
73public:
74 CSeederNode(const CService &ip, std::vector<CAddress> *vAddrIn);
75
76 bool Run();
77
78 int GetBan() { return ban; }
79
80 int GetClientVersion() { return nVersion; }
81
82 std::string GetClientSubVersion() { return strSubVer; }
83
85
87
89};
90
91#endif // BITCOIN_SEEDER_BITCOIN_H
const CChainParams & Params()
Return the currently selected parameters.
uint16_t GetDefaultPort() const
Definition chainparams.h:95
Double ended buffer combining vector and stream-like interfaces.
Definition streams.h:177
bool IsTor() const
Check whether this object represents a TOR address.
void BeginMessage(const char *pszCommand)
CDataStream vRecv
Definition bitcoin.h:43
CService you
Definition bitcoin.h:50
bool IsCheckpointVerified() const
Definition bitcoin.h:88
CDataStream vSend
Definition bitcoin.h:42
bool Run()
Definition bitcoin.cpp:258
int nStartingHeight
Definition bitcoin.h:46
int GetBan()
Definition bitcoin.h:78
bool needAddrReply
Definition bitcoin.h:53
int nVersion
Definition bitcoin.h:44
std::string GetClientSubVersion()
Definition bitcoin.h:82
std::vector< CAddress > * vAddr
Definition bitcoin.h:47
ServiceFlags yourServices
Definition bitcoin.h:51
bool ProcessMessages()
Definition bitcoin.cpp:187
std::string strSubVer
Definition bitcoin.h:45
PeerMessagingState ProcessMessage(std::string strCommand, CDataStream &recv)
Definition bitcoin.cpp:41
int GetClientVersion()
Definition bitcoin.h:80
void Send()
Definition bitcoin.cpp:26
void PushVersion()
std::chrono::seconds GetTimeout()
Definition bitcoin.h:55
bool checkpointVerified
Definition bitcoin.h:52
void AbortMessage()
int GetStartingHeight()
Definition bitcoin.h:84
uint64_t GetServices()
Definition bitcoin.h:86
NodeSeconds doneAfter
Definition bitcoin.h:49
void EndMessage()
std::unique_ptr< Sock > sock
Definition bitcoin.h:41
A combination of a network address (CNetAddr) and a (TCP) port.
Definition netaddress.h:545
RAII helper class that manages a socket.
Definition sock.h:28
ServiceFlags
nServices flags.
Definition protocol.h:335
@ NODE_NETWORK
Definition protocol.h:342
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
PeerMessagingState
Definition bitcoin.h:26
static const unsigned int ADDR_SOFT_CAP
Definition bitcoin.h:24
static uint16_t GetDefaultPort()
Definition bitcoin.h:18
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds
Definition time.h:25