20void ConnmanTestMsg::Handshake(
CNode&
node,
21 bool successfully_connected,
27 auto& peerman{
static_cast<PeerManager&
>(*m_msgproc)};
31 peerman.SendMessages(&
node);
49 (void)connman.ReceiveMsgFrom(
node, std::move(msg_version));
50 node.fPauseSend =
false;
51 connman.ProcessMessagesOnce(
node);
52 peerman.SendMessages(&
node);
54 if (
node.fDisconnect)
return;
58 assert(peerman.GetNodeStateStats(
node.GetId(), statestats));
61 if (successfully_connected) {
63 (void)connman.ReceiveMsgFrom(
node, std::move(msg_verack));
64 node.fPauseSend =
false;
65 connman.ProcessMessagesOnce(
node);
66 peerman.SendMessages(&
node);
73 assert(
node.ReceiveMsgBytes(msg_bytes, complete));
75 node.MarkReceivedMsgsForProcessing();
82 node.vSendMsg.clear();
83 node.m_send_memusage = 0;
85 const auto& [to_send, _more, _msg_type] =
node.m_transport->GetBytesToSend(
false);
86 if (to_send.empty())
break;
87 node.m_transport->MarkBytesSent(to_send.size());
93 bool queued =
node.m_transport->SetMessageToSend(ser_msg);
97 const auto& [to_send, _more, _msg_type] =
node.m_transport->GetBytesToSend(
false);
98 if (to_send.empty())
break;
100 node.m_transport->MarkBytesSent(to_send.size());
108 if (!
node)
return nullptr;
111 node->fSuccessfullyConnected =
true;
118 std::vector<NodeEvictionCandidate> candidates;
119 candidates.reserve(n_candidates);
120 for (
int id = 0;
id < n_candidates; ++id) {
121 candidates.push_back({
123 .m_connected=std::chrono::seconds{random_context.
randrange(100)},
124 .m_min_ping_time=std::chrono::microseconds{random_context.
randrange(100)},
125 .m_last_block_time=std::chrono::seconds{random_context.
randrange(100)},
126 .m_last_tx_time=std::chrono::seconds{random_context.
randrange(100)},
127 .fRelevantServices=random_context.
randbool(),
128 .m_relay_txs=random_context.
randbool(),
129 .fBloomFilter=random_context.
randbool(),
130 .nKeyedNetGroup=random_context.
randrange(100u),
131 .prefer_evict=random_context.
randbool(),
132 .m_is_local=random_context.
randbool(),
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.
virtual void InitializeNode(const CNode &node, ServiceFlags our_services)=0
Initialize a peer (setup state)
I randrange(I range) noexcept
Generate a random integer in the range [0..range), with range > 0.
bool randbool() noexcept
Generate a random boolean.
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)
constexpr const char * VERACK
The verack message acknowledges a previously-received version message, informing the connecting node ...
constexpr const char * VERSION
The version message provides information about the transmitting node to the receiving node at the beg...
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