Skip to content

Commit 3ef1080

Browse files
committed
Defer sending peer status after transitioning to full sync mode
1 parent 2853816 commit 3ef1080

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
@@ -19,6 +19,7 @@ use std::collections::{HashMap, HashSet};
1919
use std::fs;
2020
use std::sync::Arc;
2121
use std::time::Duration;
22+
use std::mem::discriminant;
2223

2324
use ccore::encoded::Header as EncodedHeader;
2425
use ccore::{
@@ -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)