Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jenny Ryan
ouinet
Commits
4f2ad31c
Commit
4f2ad31c
authored
Nov 10, 2020
by
Ivan Vilata-i-Balaguer
Browse files
Periodically report number of injectors and helpers seen in the DHT.
parent
d508a038
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/ouiservice/bep5/client.cpp
View file @
4f2ad31c
...
...
@@ -381,6 +381,15 @@ void Bep5Client::start(asio::yield_context)
_injector_pinger
.
reset
(
new
InjectorPinger
(
_injector_swarm
,
_helpers_swarm_name
,
_dht
,
_cancel
));
}
if
(
logger
.
get_threshold
()
>
DEBUG
)
return
;
TRACK_SPAWN
(
get_executor
(),
[
=
]
(
asio
::
yield_context
yield
)
{
sys
::
error_code
ec
;
status_loop
(
yield
[
ec
]);
});
}
void
Bep5Client
::
stop
()
...
...
@@ -391,6 +400,36 @@ void Bep5Client::stop()
_injector_pinger
=
nullptr
;
}
void
Bep5Client
::
status_loop
(
asio
::
yield_context
yield
)
{
assert
(
!
_cancel
);
Cancel
cancel
(
_cancel
);
sys
::
error_code
ec
;
assert
(
_injector_swarm
);
{
_injector_swarm
->
wait_for_ready
(
cancel
,
yield
[
ec
]);
return_or_throw_on_error
(
yield
,
cancel
,
ec
);
}
if
(
_helpers_swarm
)
{
_helpers_swarm
->
wait_for_ready
(
cancel
,
yield
[
ec
]);
return_or_throw_on_error
(
yield
,
cancel
,
ec
);
}
while
(
!
cancel
)
{
auto
inj_n
=
_injector_swarm
->
peers
().
size
();
auto
hlp_n
=
_helpers_swarm
?
_helpers_swarm
->
peers
().
size
()
:
0
;
logger
.
debug
(
util
::
str
(
"Bep5Client: swarm status:"
,
" injectors="
,
inj_n
,
" bridges="
,
hlp_n
));
ec
=
{};
async_sleep
(
get_executor
(),
1min
,
cancel
,
yield
[
ec
]);
}
}
std
::
vector
<
Bep5Client
::
Candidate
>
Bep5Client
::
get_peers
(
Target
target
)
{
std
::
vector
<
Candidate
>
inj
;
...
...
src/ouiservice/bep5/client.h
View file @
4f2ad31c
...
...
@@ -60,6 +60,7 @@ public:
asio
::
executor
get_executor
();
private:
void
status_loop
(
asio
::
yield_context
);
std
::
vector
<
Candidate
>
get_peers
(
Target
);
GenericStream
connect_single
(
AbstractClient
&
,
bool
tls
,
Cancel
&
,
asio
::
yield_context
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment