feat(network): update n2n handshake versions & add keepalive miniprotocol (#362)

This commit is contained in:
Andrew Westberg 2023-12-19 05:56:10 -05:00 committed by GitHub
parent 4c651c0c3a
commit b6399333da
12 changed files with 302 additions and 41 deletions

View file

@ -2,6 +2,7 @@ use pallas::network::{
facades::PeerClient,
miniprotocols::{chainsync, Point, MAINNET_MAGIC},
};
use tokio::time::Instant;
use tracing::info;
async fn do_blockfetch(peer: &mut PeerClient) {
@ -35,7 +36,12 @@ async fn do_chainsync(peer: &mut PeerClient) {
info!("intersected point is {:?}", point);
let mut keepalive_timer = Instant::now();
for _ in 0..10 {
if keepalive_timer.elapsed().as_secs() > 20 {
peer.keepalive().send_keepalive().await.unwrap();
keepalive_timer = Instant::now();
}
let next = peer.chainsync().request_next().await.unwrap();
match next {