Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/bitcoin/node/full_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class BCN_API full_node
/// Methods.
/// -----------------------------------------------------------------------

/// Expose the host pool fetch for administrative queries.
void fetch(network::address_handler&& handler) NOEXCEPT override;

/// Get current fee estimate.
void estimate(size_t target, estimator::mode mode,
estimate_handler&& handler) NOEXCEPT;
Expand Down
29 changes: 29 additions & 0 deletions include/bitcoin/node/protocols/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,42 @@ class BCN_API protocol
/// The number of inbound peer channels (counted, not quiet).
virtual size_t inbound_channel_count() const NOEXCEPT;

/// The number of host pool addresses.
virtual size_t address_count() const NOEXCEPT;

/// Methods.
/// -----------------------------------------------------------------------

/// Fetch a copy of the host pool addresses.
virtual void fetch_addresses(
network::address_handler&& handler) const NOEXCEPT;

/// Maintain a manual connection to the given endpoint.
virtual void connect(const network::config::endpoint& endpoint) NOEXCEPT;

/// Get current fee estimate.
void estimate(size_t target, estimator::mode mode,
estimate_handler&& handler) NOEXCEPT;

/// Suspensions.
/// -----------------------------------------------------------------------

/// Network suspension (does not affect administrative connections).
virtual bool suspended() const NOEXCEPT;
virtual void suspend(const code& ec) NOEXCEPT;
virtual void resume() NOEXCEPT;

/// Organizers.
/// -----------------------------------------------------------------------

/// Organize a validated header.
virtual void organize(const system::chain::header::cptr& header,
organize_handler&& handler) NOEXCEPT;

/// Organize a checked block.
virtual void organize(const system::chain::block::cptr& block,
organize_handler&& handler) NOEXCEPT;

/// Events subscription.
/// -----------------------------------------------------------------------

Expand Down
8 changes: 0 additions & 8 deletions include/bitcoin/node/protocols/protocol_peer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ class BCN_API protocol_peer
/// Organizers.
/// -----------------------------------------------------------------------

/// Organize a validated header.
virtual void organize(const system::chain::header::cptr& header,
organize_handler&& handler) NOEXCEPT;

/// Organize a checked block.
virtual void organize(const system::chain::block::cptr& block,
organize_handler&& handler) NOEXCEPT;

/// Get block hashes for blocks to download.
virtual void get_hashes(map_handler&& handler) NOEXCEPT;

Expand Down
16 changes: 16 additions & 0 deletions include/bitcoin/node/sessions/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ class BCN_API session
/// Methods.
/// -----------------------------------------------------------------------

/// Fetch a copy of the host pool addresses.
virtual void fetch_addresses(
network::address_handler&& handler) const NOEXCEPT;

/// Maintain a manual connection to the given endpoint.
virtual void connect(const network::config::endpoint& endpoint) NOEXCEPT;

/// Get current fee estimate.
void estimate(size_t target, estimator::mode mode,
estimate_handler&& handler) NOEXCEPT;
Expand All @@ -87,6 +94,11 @@ class BCN_API session
/// Suspensions.
/// -----------------------------------------------------------------------

/// Network suspension (does not affect administrative connections).
virtual bool suspended() const NOEXCEPT;
virtual void suspend(const code& ec) NOEXCEPT;
virtual void resume() NOEXCEPT;

/// Suspend all connections.
virtual void fault(const code& ec) NOEXCEPT;

Expand Down Expand Up @@ -118,6 +130,10 @@ class BCN_API session
/// The number of inbound peer channels (counted, not quiet).
virtual size_t inbound_channel_count() const NOEXCEPT;

/// The number of host pool addresses.
virtual size_t address_count() const NOEXCEPT;


protected:

/// Constructors.
Expand Down
5 changes: 5 additions & 0 deletions src/full_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ time_t full_node::start_time() const NOEXCEPT
// Methods.
// ----------------------------------------------------------------------------

void full_node::fetch(network::address_handler&& handler) NOEXCEPT
{
network::net::fetch(std::move(handler));
}

void full_node::estimate(size_t target, estimator::mode mode,
estimate_handler&& handler) NOEXCEPT
{
Expand Down
46 changes: 46 additions & 0 deletions src/protocols/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,52 @@ void protocol::estimate(size_t target, estimator::mode mode,
// Events subscription.
// ----------------------------------------------------------------------------

size_t protocol::address_count() const NOEXCEPT
{
return session_->address_count();
}

void protocol::fetch_addresses(
network::address_handler&& handler) const NOEXCEPT
{
session_->fetch_addresses(std::move(handler));
}

void protocol::connect(const network::config::endpoint& endpoint) NOEXCEPT
{
session_->connect(endpoint);
}

bool protocol::suspended() const NOEXCEPT
{
return session_->suspended();
}

void protocol::suspend(const code& ec) NOEXCEPT
{
session_->suspend(ec);
}

void protocol::resume() NOEXCEPT
{
session_->resume();
}

// Organizers.
// ----------------------------------------------------------------------------

void protocol::organize(const system::chain::header::cptr& header,
organize_handler&& handler) NOEXCEPT
{
session_->organize(header, std::move(handler));
}

void protocol::organize(const system::chain::block::cptr& block,
organize_handler&& handler) NOEXCEPT
{
session_->organize(block, std::move(handler));
}

void protocol::subscribe_chase(event_notifier&& handler) NOEXCEPT
{
// This is a shared instance multiply-derived from network::protocol.
Expand Down
12 changes: 0 additions & 12 deletions src/protocols/protocol_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ using namespace network;
// Organizers.
// ----------------------------------------------------------------------------

void protocol_peer::organize(const system::chain::header::cptr& header,
organize_handler&& handler) NOEXCEPT
{
session_->organize(header, std::move(handler));
}

void protocol_peer::organize(const system::chain::block::cptr& block,
organize_handler&& handler) NOEXCEPT
{
session_->organize(block, std::move(handler));
}

void protocol_peer::get_hashes(map_handler&& handler) NOEXCEPT
{
session_->get_hashes(std::move(handler));
Expand Down
31 changes: 31 additions & 0 deletions src/sessions/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,37 @@ size_t session::inbound_channel_count() const NOEXCEPT
return node_.inbound_channel_count();
}

size_t session::address_count() const NOEXCEPT
{
return node_.address_count();
}

void session::fetch_addresses(
network::address_handler&& handler) const NOEXCEPT
{
node_.fetch(std::move(handler));
}

void session::connect(const network::config::endpoint& endpoint) NOEXCEPT
{
node_.connect(endpoint);
}

bool session::suspended() const NOEXCEPT
{
return node_.suspended();
}

void session::suspend(const code& ec) NOEXCEPT
{
node_.suspend(ec);
}

void session::resume() NOEXCEPT
{
node_.resume();
}

BC_POP_WARNING()

} // namespace node
Expand Down
Loading