Skip to content

Commit c924d2f

Browse files
committed
Defer sending peer status after transitioning to full sync mode
1 parent 13fced7 commit c924d2f

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(
@@ -1053,6 +1062,7 @@ impl Extension {
10531062
downloader.update_pivot(best_hash);
10541063
}
10551064
self.state = State::Full;
1065+
self.send_status_broadcast();
10561066
}
10571067
}
10581068

0 commit comments

Comments
 (0)