Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for new peer discovery when the tip is stale #1292

Merged
merged 7 commits into from
Oct 24, 2023

Conversation

ImplOfAnImpl
Copy link
Contributor

Making the tests work required some changes in production code as well:

  1. I added last_tip_block_time to PeerManager, which is now used to force a call to reload_dns_seed.
    Also, I had to add PeerManagerEvent::NewLocalTip, so that the peer manager could learn about locally-produced tips too. This in turn required to add BlockSource to ChainstateEvent::NewTip.
  2. The logic from reload_dns_seed was moved to DefaultDnsSeed::obtain_addresses.

Comment on lines +55 to +56
async fn obtain_addresses(&self) -> Vec<SocketAddress> {
let dns_seed = match self.chain_config.chain_type() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: the logic in this function is not new; it was moved here from reload_dns_seed

Comment on lines 1590 to 1593
// This will be called at the end of "heartbeat" function.
fn on_heartbeat(&mut self);
// This will be called for both incoming and outgoing connections.
fn on_connection_acccepted(&mut self, address: SocketAddress);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: I ended up not needing these functions in the final implementation of the tests; but I decided to keep them (and the corresponding PeerManagerNotification variants), because they may become useful in the future.

…NewLocalTip with NewChainstateTip, which is produced unconditionally.
@ImplOfAnImpl ImplOfAnImpl marked this pull request as ready for review October 24, 2023 15:18
@TheQuantumPhysicist TheQuantumPhysicist merged commit a08e4a5 into master Oct 24, 2023
31 checks passed
@TheQuantumPhysicist TheQuantumPhysicist deleted the peer_discovery_on_stale_tip branch October 24, 2023 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants