@@ -129,6 +129,7 @@ namespace cryptonote
129
129
void cryptonote_connection_context::add_requested_from_peer ()
130
130
{
131
131
epee::write_lock w_lock (m_connection_stats->mutex );
132
+ add_in_flight_requests ();
132
133
++m_connection_stats->requested_from_peer ;
133
134
}
134
135
@@ -138,6 +139,25 @@ namespace cryptonote
138
139
++m_connection_stats->sent ;
139
140
}
140
141
142
+ void cryptonote_connection_context::add_in_flight_requests ()
143
+ {
144
+ epee::write_lock w_lock (m_connection_stats->mutex );
145
+ ++m_connection_stats->in_flight_requests ;
146
+ }
147
+
148
+ void cryptonote_connection_context::remove_in_flight_request ()
149
+ {
150
+ epee::write_lock w_lock (m_connection_stats->mutex );
151
+ if (m_connection_stats->in_flight_requests > 0 )
152
+ --m_connection_stats->in_flight_requests ;
153
+ }
154
+
155
+ bool cryptonote_connection_context::can_process_additional_request (size_t requests)
156
+ {
157
+ epee::read_lock r_lock (m_connection_stats->mutex );
158
+ return (m_connection_stats->in_flight_requests + requests) < P2P_MAX_IN_FLIGHT_REQUESTS;
159
+ }
160
+
141
161
size_t cryptonote_connection_context::get_announcement_size () const
142
162
{
143
163
epee::read_lock r_lock (m_connection_stats->mutex );
@@ -184,6 +204,12 @@ namespace cryptonote
184
204
return m_connection_stats->missed ;
185
205
}
186
206
207
+ size_t cryptonote_connection_context::get_in_flight_requests () const
208
+ {
209
+ epee::read_lock r_lock (m_connection_stats->mutex );
210
+ return m_connection_stats->in_flight_requests ;
211
+ }
212
+
187
213
std::string cryptonote_connection_context::get_info () const
188
214
{
189
215
epee::read_lock r_lock (m_connection_stats->mutex );
0 commit comments