mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-06-17 02:24:48 +08:00
feat: track neighbors with stale views
This commit is contained in:
@@ -33,9 +33,9 @@ use crate::net::stackerdb::{
|
||||
StackerDBConfig, StackerDBSync, StackerDBSyncResult, StackerDBSyncState, StackerDBs,
|
||||
};
|
||||
use crate::net::{
|
||||
Error as net_error, NackData, Neighbor, NeighborAddress, NeighborKey, StackerDBChunkData,
|
||||
StackerDBChunkInvData, StackerDBGetChunkData, StackerDBGetChunkInvData, StackerDBPushChunkData,
|
||||
StacksMessageType,
|
||||
Error as net_error, NackData, NackErrorCodes, Neighbor, NeighborAddress, NeighborKey,
|
||||
StackerDBChunkData, StackerDBChunkInvData, StackerDBGetChunkData, StackerDBGetChunkInvData,
|
||||
StackerDBPushChunkData, StacksMessageType,
|
||||
};
|
||||
|
||||
const MAX_CHUNKS_IN_FLIGHT: usize = 6;
|
||||
@@ -71,6 +71,7 @@ impl<NC: NeighborComms> StackerDBSync<NC> {
|
||||
total_pushed: 0,
|
||||
last_run_ts: 0,
|
||||
need_resync: false,
|
||||
stale_neighbors: HashSet::new(),
|
||||
};
|
||||
dbsync.reset(None, config);
|
||||
dbsync
|
||||
@@ -177,6 +178,7 @@ impl<NC: NeighborComms> StackerDBSync<NC> {
|
||||
chunks_to_store: chunks,
|
||||
dead: self.comms.take_dead_neighbors(),
|
||||
broken: self.comms.take_broken_neighbors(),
|
||||
stale: std::mem::replace(&mut self.stale_neighbors, HashSet::new()),
|
||||
};
|
||||
|
||||
// keep all connected replicas, and replenish from config hints and the DB as needed
|
||||
@@ -678,6 +680,7 @@ impl<NC: NeighborComms> StackerDBSync<NC> {
|
||||
&network.get_chain_view().rc_consensus_hash,
|
||||
&db_data.rc_consensus_hash
|
||||
);
|
||||
self.connected_replicas.remove(&naddr);
|
||||
continue;
|
||||
}
|
||||
db_data
|
||||
@@ -689,6 +692,10 @@ impl<NC: NeighborComms> StackerDBSync<NC> {
|
||||
&naddr,
|
||||
data.error_code
|
||||
);
|
||||
self.connected_replicas.remove(&naddr);
|
||||
if data.error_code == NackErrorCodes::StaleView {
|
||||
self.stale_neighbors.insert(naddr);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
x => {
|
||||
@@ -802,10 +809,15 @@ impl<NC: NeighborComms> StackerDBSync<NC> {
|
||||
&naddr,
|
||||
data.error_code
|
||||
);
|
||||
self.connected_replicas.remove(&naddr);
|
||||
if data.error_code == NackErrorCodes::StaleView {
|
||||
self.stale_neighbors.insert(naddr);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
x => {
|
||||
info!("Received unexpected message {:?}", &x);
|
||||
self.connected_replicas.remove(&naddr);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@@ -934,10 +946,14 @@ impl<NC: NeighborComms> StackerDBSync<NC> {
|
||||
data.error_code
|
||||
);
|
||||
self.connected_replicas.remove(&naddr);
|
||||
if data.error_code == NackErrorCodes::StaleView {
|
||||
self.stale_neighbors.insert(naddr);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
x => {
|
||||
info!("Received unexpected message {:?}", &x);
|
||||
self.connected_replicas.remove(&naddr);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@@ -1076,6 +1092,9 @@ impl<NC: NeighborComms> StackerDBSync<NC> {
|
||||
data.error_code
|
||||
);
|
||||
self.connected_replicas.remove(&naddr);
|
||||
if data.error_code == NackErrorCodes::StaleView {
|
||||
self.stale_neighbors.insert(naddr);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
x => {
|
||||
|
||||
Reference in New Issue
Block a user