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

Stratum v2 connman #50

Open
wants to merge 26 commits into
base: sv2-transport
Choose a base branch
from
Open

Stratum v2 connman #50

wants to merge 26 commits into from

Commits on Sep 27, 2024

  1. net: reduce CAddress usage to CService or CNetAddr

    * `CConnman::CalculateKeyedNetGroup()` needs `CNetAddr`, not `CAddress`,
      thus change its argument.
    
    * Both callers of `CConnman::CreateNodeFromAcceptedSocket()` create a
      dummy `CAddress` from `CService`, so use `CService` instead.
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    1bfc1ca View commit details
    Browse the repository at this point in the history
  2. net: split CConnman::BindListenPort() off CConnman

    Introduce a new low-level socket managing class `SockMan`
    and move the `CConnman::BindListenPort()` method to it.
    
    Also, separate the listening socket from the permissions -
    they were coupled in `struct ListenSocket`, but the socket
    is protocol agnostic, whereas the permissions are specific
    to the application of the Bitcoin P2P protocol.
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    41c87dd View commit details
    Browse the repository at this point in the history
  3. style: modernize the style of SockMan::BindListenPort()

    It was copied verbatim from `CConnman::BindListenPort()` in the previous
    commit. Modernize its variables and style and log the error messages
    from the caller.
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    b5362b7 View commit details
    Browse the repository at this point in the history
  4. net: split CConnman::AcceptConnection() off CConnman

    Move the `CConnman::AcceptConnection()` method to `SockMan` and split
    parts of it:
    * the flip-to-CJDNS part: to just after the `AcceptConnection()` call
    * the permissions part: at the start of `CreateNodeFromAcceptedSocket()`
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    708398c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    0398a8a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    5d4920f View commit details
    Browse the repository at this point in the history
  7. net: move CConnman-specific parts away from ThreadI2PAcceptIncoming()

    CConnman-specific or in other words, Bitcoin P2P specific. Now
    the `ThreadI2PAcceptIncoming()` method is protocol agnostic and
    can be moved to `SockMan`.
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    1898277 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    b94f9d3 View commit details
    Browse the repository at this point in the history
  9. net: index nodes in CConnman by id

    Change `CConnman::m_nodes` from `std::vector<CNode*>` to
    `std::unordered_map<NodeId, CNode*>` because interaction
    between `CConnman` and `SockMan` is going to be based on
    `NodeId` and finding a node by its id would better be fast.
    
    As a nice side effect the existent search-by-id operations in
    `CConnman::AttemptToEvictConnection()`,
    `CConnman::DisconnectNode()` and
    `CConnman::ForNode()` now become `O(1)` (were `O(number of nodes)`),
    as well as the erase in `CConnman::DisconnectNodes()`.
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    b96beb2 View commit details
    Browse the repository at this point in the history
  10. net: isolate P2P specifics from GenerateWaitSockets()

    Move the parts of `CConnman::GenerateWaitSockets()` that are specific to
    the Bitcoin-P2P protocol to dedicated methods:
    `ShouldTryToSend()` and `ShouldTryToRecv()`.
    
    This brings us one step closer to moving `GenerateWaitSockets()` to the
    protocol agnostic `SockMan` (which would call `ShouldTry...()` from
    `CConnman`).
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    bb5b91d View commit details
    Browse the repository at this point in the history
  11. net: isolate P2P specifics from SocketHandlerConnected() and ThreadSo…

    …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`).
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    50cb524 View commit details
    Browse the repository at this point in the history
  12. net: isolate all remaining P2P specifics from SocketHandlerConnected()

    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()`.
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    96974ff View commit details
    Browse the repository at this point in the history
  13. net: split CConnman::ConnectNode()

    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`.
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    3bb0145 View commit details
    Browse the repository at this point in the history
  14. net: tweak EventNewConnectionAccepted()

    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()`.
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    9d1b352 View commit details
    Browse the repository at this point in the history
  15. net: move sockets from CNode to SockMan

    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()`.
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    c133a63 View commit details
    Browse the repository at this point in the history
  16. net: move-only: improve encapsulation of SockMan

    `SockMan` members
    
    `AcceptConnection()`
    `NewSockAccepted()`
    `GetNewNodeId()`
    `m_i2p_sam_session`
    `m_listen private`
    
    are now used only by `SockMan`, thus make them private.
    vasild committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    70c2f13 View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2024

  1. Add sv2 SETUP_CONNECTION messages

    Co-Authored-By: Christopher Coverdale <[email protected]>
    Sjors and ccdle12 committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    c211a16 View commit details
    Browse the repository at this point in the history
  2. Add strings for Sv2MsgType

    Sjors committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    818e124 View commit details
    Browse the repository at this point in the history
  3. test: move the implementation of StaticContentsSock to .cpp

    Move the implementation (method definitions) from `test/util/net.h` to
    `test/util/net.cpp` to make the header easier to follow.
    vasild authored and Sjors committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    c085339 View commit details
    Browse the repository at this point in the history
  4. test: put the generic parts from StaticContentsSock into a separate c…

    …lass
    
    This allows reusing them in other mocked implementations.
    vasild authored and Sjors committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    ae25a75 View commit details
    Browse the repository at this point in the history
  5. test: add a mocked Sock that allows inspecting what has been Send() t…

    …o it
    
    And also allows gradually providing the data to be returned by `Recv()`
    and sending and receiving net messages (`CNetMessage`).
    vasild authored and Sjors committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    e7733c0 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    9ee662c View commit details
    Browse the repository at this point in the history
  7. Move i2p from node to common

    Sjors committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    558c9e0 View commit details
    Browse the repository at this point in the history
  8. init storage to make MSAN happy

    Sjors committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    28d0915 View commit details
    Browse the repository at this point in the history
  9. Add Sv2Connman

    Co-Authored-By: Vasil Dimov <[email protected]>
    Sjors and vasild committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    a1f543b View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    e8d8aea View commit details
    Browse the repository at this point in the history