Add vConnect to CConnman::Options#10596
Conversation
|
@theuni please take a look if you can. |
src/net.h
Outdated
There was a problem hiding this comment.
std::thread takes arguments by value/rvalue only. Taking a reference would be dangerous as the arg could go out of scope before it's used in the thread.
Edit: Thinking more about this, std::thread's constructor turns references into copies anyway, so I suppose a const reference here would just extend the lifetime of the copy as usual.
There was a problem hiding this comment.
I also read that the reference is turned into a copy, but I figured it's better to be explicit about it being a copy. I also didn't use a pointer because dealing with its lifetime is not worth it.
There was a problem hiding this comment.
I also prefer it this way, explicitly.
|
@benma Thanks, will review asap. |
theuni
left a comment
There was a problem hiding this comment.
Concept ACK. Looks good, just a few nits.
src/init.cpp
Outdated
There was a problem hiding this comment.
I didn't mention it on your first PRs because I didn't want to scare you away, but we've just agreed to change our code style from hungarian to snake_case. Mind updating? See https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md.
Don't worry about changing everything around this code, just what you're touching.
There was a problem hiding this comment.
Done (I originally thought it was better to keep the local style and fix them all in batches)
src/init.cpp
Outdated
There was a problem hiding this comment.
Please rename this so that they're more clear, since this is exposed outside of CConnman now.
connOptions.vConnect -> connOptions.m_specified_outgoing
connOptions.bNoConnect -> (!) connOptions.m_use_addrman_outgoing
src/net.cpp
Outdated
There was a problem hiding this comment.
All outbound connections are moving to one thread soon, but for now, we should return an error if connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing.empty().
Also, If addrman isn't being used for outgoing and there are no specified connections (incoming connections only), we can just skip creating the thread completely.
There was a problem hiding this comment.
Done, but should the error maybe be an assert? That code path cannot be triggered and is not meaningful to the user. If other things want to use Connman and mess it up, it's a coding error and they'll see the assert.
There was a problem hiding this comment.
It will be possible (and reasonable) when vAddedNodes is added as an connman option like the others. It might be a good next target :)
There was a problem hiding this comment.
What does it have to do with vAddedNodes? The specifc new error that is introduced doesn't depend on it.
|
@theuni just to let you know that I'll address everything in about two weeks (will be pretty much offline until then). Cheers. |
8466609 to
89bee24
Compare
src/init.cpp
Outdated
There was a problem hiding this comment.
connOptions.m_use_addrman_outgoing should be false if !connect.size() == 1 && connect[0] == "0"
89bee24 to
4286fd4
Compare
src/net.h
Outdated
There was a problem hiding this comment.
I'd rather not do this, as everything else here is set to null, false, or uninitialized. A value of true is unexpected.
There was a problem hiding this comment.
Done. Note that now, the default options are to not make any outbound connections (I put it to true to have it make outbound connections by default, like bitcoind does).
Split the "-connect" argument parsing out of CConnman and put it into AppInitMain().
4286fd4 to
352d582
Compare
| if (!connOptions.m_use_addrman_outgoing) { | ||
| const auto connect = gArgs.GetArgs("-connect"); | ||
| if (connect.size() != 1 || connect[0] != "0") { | ||
| connOptions.m_specified_outgoing = connect; |
There was a problem hiding this comment.
this is broken again if connect.size() == 1 && connect[0] == "0" :)
There was a problem hiding this comment.
How? If connect.size() == 1 && connect[0] == "0", then m_use_addrman_outgoing = false and m_specified_outgoing is empty, and the thread is not started.
|
@theuni does the PR look good to you? |
|
utACK 352d582. This will need to go in after the 0.15 split though, due to the new strings. |
|
@theuni thanks. Did you mean this string? If so, maybe we can just remove it (resp. replace it with an assertion)? See #10596 (comment) (sorry for the late response, somehow I missed it). |
352d582 Add vConnect to CConnman::Options (Marko Bencun) Pull request description: Split the "-connect" argument parsing out of CConnman and put it into AppInitMain(). Tree-SHA512: f2d3efc4e2c5808ff98696ea20dd96df599bc472ed5afc9c3eea305d94c36a6ab50c632aa05396c7c34d1917d91b1e7ccd725656ff2631e2a36d9eac477455dc
|
Add BTC my wallet |
352d582 Add vConnect to CConnman::Options (Marko Bencun) Pull request description: Split the "-connect" argument parsing out of CConnman and put it into AppInitMain(). Tree-SHA512: f2d3efc4e2c5808ff98696ea20dd96df599bc472ed5afc9c3eea305d94c36a6ab50c632aa05396c7c34d1917d91b1e7ccd725656ff2631e2a36d9eac477455dc
352d582 Add vConnect to CConnman::Options (Marko Bencun) Pull request description: Split the "-connect" argument parsing out of CConnman and put it into AppInitMain(). Tree-SHA512: f2d3efc4e2c5808ff98696ea20dd96df599bc472ed5afc9c3eea305d94c36a6ab50c632aa05396c7c34d1917d91b1e7ccd725656ff2631e2a36d9eac477455dc
e1d12d3 Add Clang thread safety analysis annotations (furszy) 5716940 net: Add missing locks in net.{cpp,h} (furszy) 8c02b59 net: simplify fRelayTxes flag processing (furszy) 71667df remove unused IsArgSet check (Marko Bencun) 729c63d add m_added_nodes to connman options (Marko Bencun) 8c8ad18 [net] Fix use of uninitialized value in getnetworkinfo(const JSONRPCRequest& request) (practicalswift) a13b7c9 Add vConnect to CConnman::Options (Marko Bencun) 987342e ActiveMasternode: fix not initialized socket. (furszy) 8d788ba add SeedNodes to CConnman::Options (Marko Bencun) d9e91ff add Binds, WhiteBinds to CConnman::Options (Marko Bencun) 41c89af add WhitelistedRange to CConnman::Options (Marko Bencun) Pull request description: More groundwork for the LLMQ sessions connections work, built on top of #2586 and #2587 (starts in 10efb72a). Focused on cleaning the connman init/start by decoupling the command line arguments. Backported PRs list: * bitcoin#10467. * bitcoin#10496. * bitcoin#10596. * bitcoin#10977. * bitcoin#11301. * bitcoin#11744 (partially, without the outbound members changes as we don't have them). ACKs for top commit: random-zebra: utACK e1d12d3 Fuzzbawls: ACK e1d12d3 Tree-SHA512: 81a1ab7a1e7f487330354631ee728be9ec78223fe4978c8b9c97b7fbc8d2bfe4f4ea9e88ac4a3d1f0553f7adad871c81261b1a7545bae710a4e3200b8a5031d7
Split the "-connect" argument parsing out of CConnman and put it into
AppInitMain().