diff --git a/zebra-network/src/peer/handshake.rs b/zebra-network/src/peer/handshake.rs index ae7df8aeb76..2b57fc21824 100644 --- a/zebra-network/src/peer/handshake.rs +++ b/zebra-network/src/peer/handshake.rs @@ -27,7 +27,6 @@ use tracing::{span, Level, Span}; use tracing_futures::Instrument; use zebra_chain::{ - block, chain_tip::{ChainTip, NoChainTip}, parameters::Network, serialization::SerializationError, @@ -580,9 +579,7 @@ where address_from: AddrInVersion::new(our_listen_addr, our_services), nonce: local_nonce, user_agent: user_agent.clone(), - // The protocol works fine if we don't reveal our current block height, - // and not sending it means we don't need to be connected to the chain state. - start_height: block::Height(0), + start_height: minimum_peer_version.chain_tip_height(), relay, }; diff --git a/zebra-network/src/peer/minimum_peer_version.rs b/zebra-network/src/peer/minimum_peer_version.rs index 421915d8f9b..7eb6d6d787c 100644 --- a/zebra-network/src/peer/minimum_peer_version.rs +++ b/zebra-network/src/peer/minimum_peer_version.rs @@ -1,6 +1,6 @@ //! Watches for chain tip height updates to determine the minimum supported peer protocol version. -use zebra_chain::{chain_tip::ChainTip, parameters::Network}; +use zebra_chain::{block::Height, chain_tip::ChainTip, parameters::Network}; use crate::protocol::external::types::Version; @@ -66,6 +66,16 @@ where self.has_changed = true; } } + + /// Return the current chain tip height. + /// + /// If it is not available return height zero. + pub fn chain_tip_height(&self) -> Height { + match self.chain_tip.best_tip_height() { + Some(height) => height, + None => Height(0), + } + } } /// A custom [`Clone`] implementation to ensure that the first call to