mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Honor max_relays beyond just at startup
This commit is contained in:
parent
0782b21c06
commit
b8d402287a
@ -18,6 +18,9 @@ pub enum Error {
|
||||
#[error("Task join error: {0}")]
|
||||
JoinError(#[from] tokio::task::JoinError),
|
||||
|
||||
#[error("Maximum relay connections reached, will not connect to another")]
|
||||
MaxRelaysReached,
|
||||
|
||||
#[error("Error sending mpsc: {0}")]
|
||||
MpscSend(#[from] tokio::sync::mpsc::error::SendError<ToOverlordMessage>),
|
||||
|
||||
|
@ -249,10 +249,19 @@ impl Overlord {
|
||||
}
|
||||
|
||||
async fn start_minion(&mut self, url: String) -> Result<(), Error> {
|
||||
if GLOBALS.settings.read().await.offline {
|
||||
let (offline, max_relays) = {
|
||||
let settings = GLOBALS.settings.read().await;
|
||||
(settings.offline, settings.max_relays)
|
||||
};
|
||||
|
||||
if offline {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if GLOBALS.relays_watching.read().await.len() >= max_relays.into() {
|
||||
return Err(Error::MaxRelaysReached);
|
||||
}
|
||||
|
||||
let url = Url::new(&url);
|
||||
if !url.is_valid_relay_url() {
|
||||
return Err(Error::InvalidUrl(url.inner().to_owned()));
|
||||
|
Loading…
Reference in New Issue
Block a user