-
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
New node methods for tools and otherwise #265
Conversation
@ZenGround0 @jhiesey clarification re: https://github.com/anacrolix/go-libp2p-dht-tool, note this tool fires up a separate libp2p host, which is not what we want. We want to call diagnostics, metrics and tracing on a running application. But the APIs @anacrolix is introducing here and in subsequent PRs will enable Filecoin and other apps to extract these insights and offer them through porcelain in the form you prefer. |
@anacrolix – looking good here. I just feel strongly about the mode switching enum as I see more modes coming soon (see comment thread). Once that and the unit test are sorted, I'm happy to approve and merge this PR. |
09a3acd
to
97ea640
Compare
I don't foresee any other modes, but I can see that |
e4c2454
to
cbe1799
Compare
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.
Needs fixing: Missing gx dependencies for xerrors and testify.
Re: SetClientMode discussion, we will likely have feature flags for DHT subsystems (content routing, peer routing, provider records), and SetClientMode can serve as a global switch.
Seeing that the requirement has now arisen for more granular knobs to turn specific features on/off in #274, my suggestion is as follows.
|
@raulk your proposal assumes we won't want to dynamically change a node from client to server or vice versa. I am not sure what the real requirements are, but I'd guess we want both an option to configure at construction time and dynamically. As the daemon becomes more of a focus I think we're going to want as much as possible to be changed dynamically. Is there an idiomatic way of doing "reactive configuration" in go? By that I mean configuration that can be set either on construction or dynamically, with listeners to handle the change? Then |
I was tempted to model runtime mode changes, but intentionally kept it simple for now as this requirement hasn't really surfaced anywhere yet. In fact, in prior feedback to @anacrolix I argued that +1 on reactive configuration. In the Java world, netflix/archaius was a clever solution. In Go land I found: Could you add your thoughts on this issue about system-wide configuration trees? libp2p/go-libp2p#526 Also, I propose you take this feature into account in your DHT rewrite proposal ;-) |
I only need the ability to dynamically downgrade the inbound message handling to be passive at the moment. Handling specific subsystems dynamically is well beyond the scope of this PR (not to mention orthogonal to the way I'm using "client" here). The project is now version 0, consider this an experimental API until the dust clears on other stuff, I'd like to just move forward. |
I'm not able to push xerrors to gx for some reason. The working repo is here: https://github.com/anacrolix/xerrors. Also whyrusleeping/gx#230. I've removed the |
If a node is running in client-only mode, doesn't it need to indicate that in the RPCs it sends, so that the receivers of its FIND_NODE/FIND_PROVIDERS/etc. messages don't add the client to their routing tables? If there is nothing doing that, then the client-only peer will be cluttering up other nodes' routing tables even though it won't answer queries. |
@jhiesey Yes it does in the BitTorrent DHT. It's not a hard requirement (since it will get evicted for not responding eventually anyway, and won't be able to barge into a correctly implemented routing table), but it's a nice to have. It's also out of scope for this PR. I've removed the SetClientMode method now anyway. |
…-methods # Conflicts: # go.mod
This is ready for merging. |
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.
…-methods # Conflicts: # go.mod # go.sum
Adds several new methods, SetClientMode, to enter client mode after initialization, PeerId and PeerKey, and BootstrapSelf and BootstrapRandom. @ZenGround0 @jhiesey. All are used by https://github.com/anacrolix/go-libp2p-dht-tool and provide finer-grained access to node functionality.