Skip to content

Commit

Permalink
Merge pull request #403 from evoskuil/master
Browse files Browse the repository at this point in the history
Expose stranded subscribe_close, make suspend() void.
  • Loading branch information
evoskuil committed May 16, 2024
2 parents 42a1cfb + abef9ef commit 72706cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions include/bitcoin/network/p2p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class BCT_API p2p
/// Network connections are suspended (incoming and/or outgoing).
virtual bool suspended() const NOEXCEPT;

/// Suspend all connections (echos parameter).
virtual code suspend(const code& ec) NOEXCEPT;
/// Suspend all connections.
virtual void suspend(const code& ec) NOEXCEPT;

/// Resume all connection.
virtual void resume() NOEXCEPT;
Expand Down Expand Up @@ -221,6 +221,7 @@ class BCT_API p2p

/// Notify subscribers of new non-seed connection, require strand.
virtual void notify_connect(const channel::ptr& channel) NOEXCEPT;
virtual void subscribe_close(stop_handler&& handler) NOEXCEPT;

/// Maintain address pool.
virtual void take(address_item_handler&& handler) NOEXCEPT;
Expand Down
10 changes: 8 additions & 2 deletions src/p2p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ void p2p::do_unsubscribe_connect(object_key key) NOEXCEPT
connect_subscriber_.notify_one(key, error::desubscribed, nullptr);
}

// protected
void p2p::subscribe_close(stop_handler&& handler) NOEXCEPT
{
BC_ASSERT_MSG(stranded(), "strand");
subscribe_close(std::move(handler), create_key());
}

// private
code p2p::subscribe_close(stop_handler&& handler, object_key key) NOEXCEPT
{
Expand Down Expand Up @@ -411,11 +418,10 @@ void p2p::resume_connectors() NOEXCEPT
connect_suspended_.store(false);
}

code p2p::suspend(const code& ec) NOEXCEPT
void p2p::suspend(const code&) NOEXCEPT
{
suspend_acceptors();
suspend_connectors();
return ec;
}

void p2p::resume() NOEXCEPT
Expand Down

0 comments on commit 72706cd

Please sign in to comment.