7 #include <chainparams.h> 16 void ConnmanTestMsg::Handshake(
CNode&
node,
17 bool successfully_connected,
23 auto& peerman{
static_cast<PeerManager&
>(*m_msgproc)};
27 peerman.InitializeNode(
node, local_services);
45 (void)connman.ReceiveMsgFrom(
node, std::move(msg_version));
46 node.fPauseSend =
false;
47 connman.ProcessMessagesOnce(
node);
48 peerman.SendMessages(&
node);
50 if (
node.fDisconnect)
return;
54 assert(peerman.GetNodeStateStats(
node.GetId(), statestats));
55 assert(statestats.m_relay_txs == (relay_txs && !
node.IsBlockOnlyConn()));
56 assert(statestats.their_services == remote_services);
57 if (successfully_connected) {
59 (void)connman.ReceiveMsgFrom(
node, std::move(msg_verack));
60 node.fPauseSend =
false;
61 connman.ProcessMessagesOnce(
node);
62 peerman.SendMessages(&
node);
69 assert(
node.ReceiveMsgBytes(msg_bytes, complete));
71 node.MarkReceivedMsgsForProcessing();
78 node.vSendMsg.clear();
79 node.m_send_memusage = 0;
81 const auto& [to_send, _more, _msg_type] =
node.m_transport->GetBytesToSend(
false);
82 if (to_send.empty())
break;
83 node.m_transport->MarkBytesSent(to_send.size());
89 bool queued =
node.m_transport->SetMessageToSend(ser_msg);
93 const auto& [to_send, _more, _msg_type] =
node.m_transport->GetBytesToSend(
false);
94 if (to_send.empty())
break;
96 node.m_transport->MarkBytesSent(to_send.size());
103 std::vector<NodeEvictionCandidate> candidates;
104 candidates.reserve(n_candidates);
105 for (
int id = 0;
id < n_candidates; ++
id) {
106 candidates.push_back({
108 std::chrono::seconds{random_context.
randrange(100)},
109 std::chrono::microseconds{random_context.
randrange(100)},
110 std::chrono::seconds{random_context.
randrange(100)},
111 std::chrono::seconds{random_context.
randrange(100)},
ServiceFlags
nServices flags
Inbound connections are those initiated by a peer.
void FlushSendBuffer(CNode &node) const
static Wrapper< Formatter, T & > Using(T &&t)
Cause serialization/deserialization of an object to be done using a specified formatter class...
A combination of a network address (CNetAddr) and a (TCP) port.
static constexpr SerParams V1
void NodeReceiveMsgBytes(CNode &node, Span< const uint8_t > msg_bytes, bool &complete) const
bool ReceiveMsgFrom(CNode &node, CSerializedNetMsg &&ser_msg) const
const char * VERACK
The verack message acknowledges a previously-received version message, informing the connecting node ...
const char * VERSION
The version message provides information about the transmitting node to the receiving node at the beg...
static const int PROTOCOL_VERSION
network protocol versioning
bool randbool() noexcept
Generate a random boolean.
constexpr auto ALL_NETWORKS
std::vector< NodeEvictionCandidate > GetRandomNodeEvictionCandidates(int n_candidates, FastRandomContext &random_context)
A Span is an object that can refer to a contiguous sequence of objects.
Information about a peer.
uint64_t randrange(uint64_t range) noexcept
Generate a random integer in the range [0..range).