20 void ConnmanTestMsg::Handshake(
CNode&
node,
21 bool successfully_connected,
27 auto& peerman{
static_cast<PeerManager&
>(*m_msgproc)};
48 (void)connman.ReceiveMsgFrom(
node, std::move(msg_version));
49 node.fPauseSend =
false;
50 connman.ProcessMessagesOnce(
node);
51 peerman.SendMessages(&
node);
53 if (
node.fDisconnect)
return;
57 assert(peerman.GetNodeStateStats(
node.GetId(), statestats));
60 if (successfully_connected) {
62 (void)connman.ReceiveMsgFrom(
node, std::move(msg_verack));
63 node.fPauseSend =
false;
64 connman.ProcessMessagesOnce(
node);
65 peerman.SendMessages(&
node);
72 assert(
node.ReceiveMsgBytes(msg_bytes, complete));
74 node.MarkReceivedMsgsForProcessing();
81 node.vSendMsg.clear();
82 node.m_send_memusage = 0;
84 const auto& [to_send, _more, _msg_type] =
node.m_transport->GetBytesToSend(
false);
85 if (to_send.empty())
break;
86 node.m_transport->MarkBytesSent(to_send.size());
92 bool queued =
node.m_transport->SetMessageToSend(ser_msg);
96 const auto& [to_send, _more, _msg_type] =
node.m_transport->GetBytesToSend(
false);
97 if (to_send.empty())
break;
99 node.m_transport->MarkBytesSent(to_send.size());
107 if (!
node)
return nullptr;
110 node->fSuccessfullyConnected =
true;
117 std::vector<NodeEvictionCandidate> candidates;
118 candidates.reserve(n_candidates);
119 for (
int id = 0;
id < n_candidates; ++id) {
120 candidates.push_back({
122 std::chrono::seconds{random_context.
randrange(100)},
123 std::chrono::microseconds{random_context.
randrange(100)},
124 std::chrono::seconds{random_context.
randrange(100)},
125 std::chrono::seconds{random_context.
randrange(100)},
A CService with information about it as peer.
CNode * ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure, ConnectionType conn_type, bool use_v2transport) EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex)
static constexpr SerParams V1
Information about a peer.
A combination of a network address (CNetAddr) and a (TCP) port.
bool randbool() noexcept
Generate a random boolean.
uint64_t randrange(uint64_t range) noexcept
Generate a random integer in the range [0..range).
virtual void InitializeNode(CNode &node, ServiceFlags our_services)=0
Initialize a peer (setup state, queue any initial messages)
A Span is an object that can refer to a contiguous sequence of objects.
ConnectionType
Different types of connections to a peer.
@ INBOUND
Inbound connections are those initiated by a peer.
CSerializedNetMsg Make(std::string msg_type, Args &&... args)
const char * VERSION
The version message provides information about the transmitting node to the receiving node at the beg...
const char * VERACK
The verack message acknowledges a previously-received version message, informing the connecting node ...
ServiceFlags
nServices flags
static const int PROTOCOL_VERSION
network protocol versioning
static Wrapper< Formatter, T & > Using(T &&t)
Cause serialization/deserialization of an object to be done using a specified formatter class.
ServiceFlags their_services
bool ReceiveMsgFrom(CNode &node, CSerializedNetMsg &&ser_msg) const
CNode * ConnectNodePublic(PeerManager &peerman, const char *pszDest, ConnectionType conn_type) EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex)
void NodeReceiveMsgBytes(CNode &node, Span< const uint8_t > msg_bytes, bool &complete) const
void AddTestNode(CNode &node)
void FlushSendBuffer(CNode &node) const
std::vector< NodeEvictionCandidate > GetRandomNodeEvictionCandidates(int n_candidates, FastRandomContext &random_context)
constexpr auto ALL_NETWORKS