Skip to content

Commit b3d36f6

Browse files
committed
Defer sending peer status after transitioning to full sync mode
1 parent 341983b commit b3d36f6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sync/src/block/extension.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use std::collections::hash_map::Entry;
1818
use std::collections::{HashMap, HashSet};
1919
use std::fs;
20+
use std::mem::discriminant;
2021
use std::sync::Arc;
2122
use std::time::Duration;
2223

@@ -174,6 +175,10 @@ impl Extension {
174175
}
175176

176177
fn send_status(&mut self, id: &NodeId) {
178+
if discriminant(&self.state) != discriminant(&State::Full) {
179+
return
180+
}
181+
177182
let chain_info = self.client.chain_info();
178183
self.api.send(
179184
id,
@@ -190,6 +195,10 @@ impl Extension {
190195
}
191196

192197
fn send_status_broadcast(&mut self) {
198+
if discriminant(&self.state) != discriminant(&State::Full) {
199+
return
200+
}
201+
193202
let chain_info = self.client.chain_info();
194203
for id in self.connected_nodes.iter() {
195204
self.api.send(
@@ -1057,6 +1066,7 @@ impl Extension {
10571066
downloader.update_pivot(best_hash);
10581067
}
10591068
self.state = State::Full;
1069+
self.send_status_broadcast();
10601070
}
10611071
}
10621072

0 commit comments

Comments
 (0)