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

Network: enable DHT server mode only while consensus is established #3038

Open
wants to merge 1 commit into
base: albatross
Choose a base branch
from

Conversation

styppo
Copy link
Member

@styppo styppo commented Nov 12, 2024

With #3014, we can only properly verify DHT records once we have the staking contract. Therefore, this PR defers the switch to DHT server mode to when consensus is established. The DHT switches back to client mode when consensus is lost.

@@ -534,6 +535,10 @@ impl Network for MockNetwork {
// TODO implement
}

async fn dht_set_mode(&self, _mode: DhtMode) {
// TODO implement
Copy link
Member

Choose a reason for hiding this comment

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

Set an unimplemented!() here? Same for validate_message. Otherwise the caller has no idea this still needs an actual impl

@@ -1041,6 +1052,27 @@ fn perform_action(action: NetworkAction, swarm: &mut NimiqSwarm, state: &mut Tas
let result = swarm.dial(dial_opts).map_err(Into::into);
output.send(result).ok();
}
NetworkAction::DhtSetMode { mode } => {
#[cfg(feature = "kad")]
Copy link
Member

Choose a reason for hiding this comment

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

Feature annotations support { } to encapsulate a block of code:

#[cfg(feature = "kad")]
{
    ...
}

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.

2 participants