-
Notifications
You must be signed in to change notification settings - Fork 11
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
Stratum v2 connman #50
base: sv2-transport
Are you sure you want to change the base?
Conversation
@pinheadmz wrote in the original PR:
I plan to take a look at this. |
3cf779b
to
b549fd6
Compare
bdc8542
to
199234a
Compare
b549fd6
to
22d033c
Compare
199234a
to
922fd8a
Compare
22d033c
to
6b5ee20
Compare
CMake rebase. |
6b5ee20
to
4f957ee
Compare
922fd8a
to
50b6eb8
Compare
4f957ee
to
b69544c
Compare
50b6eb8
to
6a02367
Compare
b69544c
to
1ca68d2
Compare
6a02367
to
ce4269c
Compare
1ca68d2
to
b578e0a
Compare
8220337
to
5fca2c5
Compare
b578e0a
to
489c9fb
Compare
5fca2c5
to
dfb9a6d
Compare
489c9fb
to
a55fa83
Compare
Rebased to move everything into a |
…cketHandler() Move some parts of `CConnman::SocketHandlerConnected()` and `CConnman::ThreadSocketHandler()` that are specific to the Bitcoin-P2P protocol to dedicated methods: `EventIOLoopCompletedForNode()` and `EventIOLoopCompletedForAllPeers()`. This brings us one step closer to moving `SocketHandlerConnected()` and `ThreadSocketHandler()` to the protocol agnostic `SockMan` (which would call `EventIOLoopCompleted...()` from `CConnman`).
Introduce 4 new methods for the interaction between `CConnman` and `SockMan`: * `EventReadyToSend()`: called when there is readiness to send and do the actual sending of data. * `EventGotData()`, `EventGotEOF()`, `EventGotPermanentReadError()`: called when the corresponing recv events occur. These methods contain logic that is specific to the Bitcoin-P2P protocol and move it away from `CConnman::SocketHandlerConnected()` which will become a protocol agnostic method of `SockMan`. Also, move the counting of sent bytes to `CConnman::SocketSendData()` - both callers of that method called `RecordBytesSent()` just after the call, so move it from the callers to inside `CConnman::SocketSendData()`.
Move the protocol agnostic parts of `CConnman::ConnectNode()` into `SockMan::ConnectAndMakeNodeId()` and leave the Bitcoin-P2P specific stuff in `CConnman::ConnectNode()`. Move the protocol agnostic `CConnman::m_unused_i2p_sessions`, its mutex and `MAX_UNUSED_I2P_SESSIONS_SIZE` to `SockMan`. Move `GetBindAddress()` from `net.cpp` to `sockman.cpp`.
Move `MaybeFlipIPv6toCJDNS()`, which is Bitcoin P2P specific from the callers of `CConnman::EventNewConnectionAccepted()` to inside that method. Move the IsSelectable check, the `TCP_NODELAY` option set and the generation of new node id out of `CConnman::EventNewConnectionAccepted()` because those are protocol agnostic. Move those to a new method `SockMan::NewSockAccepted()` which is called instead of `CConnman::EventNewConnectionAccepted()`.
Move `CNode::m_sock` and `CNode::m_i2p_sam_session` to `SockMan::m_connected`. Also move all the code that handles sockets to `SockMan`. `CNode::CloseSocketDisconnect()` becomes `CConnman::MarkAsDisconnectAndCloseConnection()`. `CConnman::SocketSendData()` is renamed to `CConnman::SendMessagesAsBytes()` and its sockets-touching bits are moved to `SockMan::SendBytes()`. `CConnman::GenerateWaitSockets()` goes to `SockMan::GenerateWaitSockets()`. `CConnman::ThreadSocketHandler()` and `CConnman::SocketHandler()` are combined into `SockMan::ThreadSocketHandler()`. `CConnman::SocketHandlerConnected()` goes to `SockMan::SocketHandlerConnected()`. `CConnman::SocketHandlerListening()` goes to `SockMan::SocketHandlerListening()`.
`SockMan` members `AcceptConnection()` `NewSockAccepted()` `GetNewNodeId()` `m_i2p_sam_session` `m_listen private` are now used only by `SockMan`, thus make them private.
e28078f
to
62b255c
Compare
53f852b
to
d0ae2f6
Compare
I turned Two open questions:
MSAN is unhappy:
Maybe a4d8293 makes it happy? |
476161f
to
96f953f
Compare
MSAN is happy. The last push just adds the dependency on |
Co-Authored-By: Christopher Coverdale <[email protected]>
Move the implementation (method definitions) from `test/util/net.h` to `test/util/net.cpp` to make the header easier to follow.
…lass This allows reusing them in other mocked implementations.
…o it And also allows gradually providing the data to be returned by `Recv()` and sending and receiving net messages (`CNetMessage`).
Co-Authored-By: Vasil Dimov <[email protected]>
96f953f
to
e8d8aea
Compare
|
||
m_connman = std::make_unique<Sv2Connman>(TP_SUBPROTOCOL, static_key, m_connman_authority_pubkey, certificate); | ||
|
||
BOOST_REQUIRE(m_connman->Start(this, "127.0.0.1", 18447)); |
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.
How are you able to Start() the connman but never break out of ThreadSocketHandler()
with interruptNet()
? If I leave the thread running in my HTTP unit test I get an error when the SockMan instance is destroyed.
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.
No idea :-)
cc @vasild?
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.
The destructor of Sv2Connman
calls the Interrupt()
method which signals the interruptNet
variable.
Based on #67, bitcoin#30205 and bitcoin#30988. Followed by #49.
Parent PR #68
This PR introduces
Sv2Connman
, a subclass ofSockMan
(bitcoin#30988). It uses theSv2Transport
introduced in bitcoin#30315 to enable incoming connections from other Stratum v2 roles.It's main target user is the Template Provider role introduced in #49.
There may be other Stratum v2 roles we want to support in the future.
Note to self, to keep this rebased until bitcoin#30988 lands:
Earlier version(s): bitcoin#30332
Note that this code will most likely not be upstreamed to Bitcoin Core, but instead used to create a standalone c++ application that connects to a running node via an IPC interface. See bitcoin#31098.