Keep network status & ring in a tokio::sync::watch

advantages
- reads don't prevent preparing writes
- can be followed from other parts of the system by cloning the receiver
This commit is contained in:
Alex Auvolat
2020-04-11 23:53:32 +02:00
parent 5dd59e437d
commit 9c931f5eda
9 changed files with 165 additions and 133 deletions
+2 -2
View File
@@ -79,8 +79,8 @@ pub async fn rpc_call(
timeout: Duration,
) -> Result<Message, Error> {
let addr = {
let members = sys.members.read().await;
match members.status.get(to) {
let status = sys.status.borrow().clone();
match status.nodes.get(to) {
Some(status) => status.addr.clone(),
None => return Err(Error::Message(format!("Peer ID not found"))),
}