eth: avoid ws provider race condition by checking before replacing

This commit is contained in:
hosted-fornet 2024-07-19 14:46:10 -07:00
parent b4813e4fdd
commit 2259449321
3 changed files with 14 additions and 7 deletions

6
Cargo.lock generated
View File

@ -3203,7 +3203,7 @@ dependencies = [
[[package]]
name = "kinode"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"aes-gcm",
"alloy",
@ -3259,7 +3259,7 @@ dependencies = [
[[package]]
name = "kinode_lib"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"lib",
]
@ -3376,7 +3376,7 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67"
[[package]]
name = "lib"
version = "0.8.6"
version = "0.8.7"
dependencies = [
"alloy",
"kit",

View File

@ -626,8 +626,11 @@ async fn fulfill_request(
is_replacement_successful = false;
return ();
};
aps.urls.remove(index);
aps.urls.insert(0, url_provider.clone());
let old_provider = aps.urls.remove(index);
match old_provider.pubsub {
None => aps.urls.insert(0, url_provider.clone()),
Some(_) => aps.urls.insert(0, old_provider),
}
});
if !is_replacement_successful {
verbose_print(

View File

@ -232,8 +232,12 @@ async fn build_subscription(
is_replacement_successful = false;
return ();
};
aps.urls.remove(index);
aps.urls.insert(0, url_provider.clone());
let old_provider = aps.urls.remove(index);
match old_provider.pubsub {
None => aps.urls.insert(0, url_provider.clone()),
Some(_) => aps.urls.insert(0, old_provider),
}
});
if !is_replacement_successful {
verbose_print(