mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-20 15:05:19 +00:00
Terminate file sync if connecting peers too long (#136)
This commit is contained in:
parent
7d73ccd1e1
commit
ae9c52c0e6
@ -126,7 +126,7 @@ impl Batcher {
|
||||
Ok(Some(SyncResult::Failed))
|
||||
}
|
||||
|
||||
// file sync timeout
|
||||
// finding peers timeout
|
||||
Some(SyncState::FindingPeers { origin, .. })
|
||||
if origin.elapsed() > self.config.find_peer_timeout =>
|
||||
{
|
||||
@ -135,6 +135,15 @@ impl Batcher {
|
||||
Ok(Some(SyncResult::Timeout))
|
||||
}
|
||||
|
||||
// connecting peers timeout
|
||||
Some(SyncState::ConnectingPeers { origin, .. })
|
||||
if origin.elapsed() > self.config.find_peer_timeout =>
|
||||
{
|
||||
debug!(%tx_seq, "Terminate file sync due to connecting peers timeout");
|
||||
self.terminate_file_sync(tx_seq, false).await;
|
||||
Ok(Some(SyncResult::Timeout))
|
||||
}
|
||||
|
||||
// others
|
||||
_ => Ok(None),
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ pub enum SyncState {
|
||||
},
|
||||
FoundPeers,
|
||||
ConnectingPeers {
|
||||
origin: InstantWrapper,
|
||||
since: InstantWrapper,
|
||||
},
|
||||
AwaitingOutgoingConnection {
|
||||
@ -253,6 +254,7 @@ impl SerialSyncController {
|
||||
info!(%self.tx_seq, %num_peers_dailed, "Connecting peers");
|
||||
|
||||
self.state = SyncState::ConnectingPeers {
|
||||
origin: self.since,
|
||||
since: Instant::now().into(),
|
||||
};
|
||||
}
|
||||
@ -632,6 +634,7 @@ impl SerialSyncController {
|
||||
SyncState::FoundPeers => {
|
||||
if self.peers.all_shards_available(vec![Connecting, Connected]) {
|
||||
self.state = SyncState::ConnectingPeers {
|
||||
origin: self.since,
|
||||
since: Instant::now().into(),
|
||||
};
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user