-
Notifications
You must be signed in to change notification settings - Fork 226
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
dht dynamic mode switching. #367
Conversation
We now listen to local routability events to dynamically switch our DHT mode. Private/unknown routability transition us to client mode; public routability puts us in server mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems about right to me.
@Stebalien @whyrusleeping debouncing implemented. Can I get a quick sanity check? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at #369.
Do not review yet, I'm cleaning this up. |
} | ||
select { | ||
case <-debouncer.C: | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this is technically kind of racy because Stop doesn't wait for the timer to stop, but it shouldn't really be an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timer.Stop() is a huge headache. I never got it to work as described in godocs, so I went this route 🙃
@raulk I made |
6533504
to
68686f3
Compare
@Stebalien exactly the refactoring I was doing. I went a little further and fixed Still LGTY? |
dht := nn.DHT() | ||
|
||
proc := goprocess.Go(nn.subscribe) | ||
dht.host.Network().Notify(nn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly concerned that this will be triggered async. We can register for notifications after we receive connections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this applies to the other subscribers as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stebalien Please can you elaborate on this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember... I think my concern was that we could listen for new connections after the network has started and we already have connections, but that's already the case.
@aarshkshah1992 it looks like you're taking another stab at this PR. I don't think that the debouncer stuff necessarily makes a ton of sense, it should (and to some extent already does) exist in autonat. Adding a separate one for the DHT seems a little strange. I ported some of these changes into my DHT branch (35d3e4a). I wasn't sure what was going on with the peer event changes removal changes in this PR so I left it alone. |
We now listen to local routability events to dynamically switch our DHT mode.
Private/unknown routability transition us to client mode; public routability puts us in server mode.
Fixes #216.