refactor use match instead of if/else
This commit is contained in:
parent
90aa3db5dd
commit
b8d448e56e
@ -211,20 +211,22 @@ where
|
|||||||
// TODO concat messages to same destination to reduce traffic.
|
// TODO concat messages to same destination to reduce traffic.
|
||||||
if let Some(event) = self.events.pop_front() {
|
if let Some(event) = self.events.pop_front() {
|
||||||
if let NetworkBehaviourAction::SendEvent { peer_id, event } = event {
|
if let NetworkBehaviourAction::SendEvent { peer_id, event } = event {
|
||||||
let ledger = self.connected_peers.get_mut(&peer_id);
|
match self.connected_peers.get_mut(&peer_id) {
|
||||||
if ledger.is_none() {
|
None => {
|
||||||
debug!(" requeueing send event to {}", peer_id.to_base58());
|
debug!(" requeueing send event to {}", peer_id.to_base58());
|
||||||
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
self.events.push_back(NetworkBehaviourAction::SendEvent {
|
||||||
peer_id,
|
peer_id,
|
||||||
event,
|
event,
|
||||||
});
|
})
|
||||||
} else {
|
},
|
||||||
ledger.unwrap().update_outgoing_stats(&event);
|
Some(ref mut ledger) => {
|
||||||
debug!(" send_message to {}", peer_id.to_base58());
|
ledger.update_outgoing_stats(&event);
|
||||||
return Async::Ready(NetworkBehaviourAction::SendEvent {
|
debug!(" send_message to {}", peer_id.to_base58());
|
||||||
peer_id,
|
return Async::Ready(NetworkBehaviourAction::SendEvent {
|
||||||
event,
|
peer_id,
|
||||||
});
|
event,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug!("{:?}", event);
|
debug!("{:?}", event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user