Skip to content

Commit

Permalink
Merge of #4904
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Aug 29, 2022
2 parents 448c548 + 9ec3c07 commit 0e3c0e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 1 addition & 4 deletions zebra-network/src/peer/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
};

Expand Down
12 changes: 11 additions & 1 deletion zebra-network/src/peer/minimum_peer_version.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0e3c0e7

Please sign in to comment.