Skip to content

Commit

Permalink
impl in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ksrichard committed Aug 1, 2024
1 parent 5f397fa commit 566c346
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/server/p2p/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ where
if self.sync_in_progress.load(Ordering::SeqCst) {
self.sync_in_progress.store(false, Ordering::SeqCst);
}
info!(target: LOG_TARGET, "Share chain sync response: {response:?}");
debug!(target: LOG_TARGET, "Share chain sync response: {response:?}");
match self.share_chain.submit_blocks(response.blocks, true).await {
Ok(result) => {
if result.need_sync {
Expand All @@ -427,11 +427,11 @@ where
}
self.sync_in_progress.store(true, Ordering::SeqCst);

info!(target: LOG_TARGET, "Syncing share chain...");
debug!(target: LOG_TARGET, "Syncing share chain...");
match self.peer_store.tip_of_block_height().await {
Some(result) => {
info!(target: LOG_TARGET, "Found highest known block height: {result:?}");
info!(target: LOG_TARGET, "Send share chain sync request: {result:?}");
debug!(target: LOG_TARGET, "Found highest known block height: {result:?}");
debug!(target: LOG_TARGET, "Send share chain sync request: {result:?}");
// we always send from_height as zero now, to not miss any blocks
self.swarm
.behaviour_mut()
Expand Down
7 changes: 2 additions & 5 deletions src/server/p2p/peer_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ impl PeerStore {
/// If a peer already exists, just replaces it.
pub async fn add(&self, peer_id: PeerId, peer_info: PeerInfo) {
self.inner.insert(peer_id, PeerStoreRecord::new(peer_info)).await;

self.inner.iter().for_each(|(peer_id, record)| {
info!("[PEER STORE] {:?} -> Height: {:?}", peer_id, record.peer_info.current_height);
});

self.set_tip_of_block_height().await;
self.set_last_connected().await;
}
Expand All @@ -116,6 +111,8 @@ impl PeerStore {
*tip_height_opt = Some(PeerStoreBlockHeightTip::new(*k, v.peer_info.current_height));
}
}
} else if let Ok(mut tip_height_opt) = self.tip_of_block_height.write() {
*tip_height_opt = None;
}
}

Expand Down

0 comments on commit 566c346

Please sign in to comment.