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
4 changes: 4 additions & 0 deletions include/bitcoin/node/full_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ class BCN_API full_node
/// The confirmed chain is confirmed to maximum height or is current.
virtual bool is_recent() const NOEXCEPT;

/// Zulu time at which the node started.
virtual time_t start_time() const NOEXCEPT;

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

Expand Down Expand Up @@ -180,6 +183,7 @@ class BCN_API full_node

// These are thread safe.
const configuration& config_;
const time_t start_time_;
query& query_;

// These are protected by strand.
Expand Down
9 changes: 9 additions & 0 deletions include/bitcoin/node/protocols/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ class BCN_API protocol
/// The candidate|confirmed chain is current.
virtual bool is_current_chain(bool confirmed) const NOEXCEPT;

/// Zulu time at which the node started.
virtual time_t start_time() const NOEXCEPT;

/// The number of peer channels (counted, not quiet).
virtual size_t channel_count() const NOEXCEPT;

/// The number of inbound peer channels (counted, not quiet).
virtual size_t inbound_channel_count() const NOEXCEPT;

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

Expand Down
9 changes: 9 additions & 0 deletions include/bitcoin/node/sessions/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ class BCN_API session
/// The confirmed chain is confirmed to maximum height or is current.
virtual bool is_recent() const NOEXCEPT;

/// Zulu time at which the node started.
virtual time_t start_time() const NOEXCEPT;

/// The number of peer channels (counted, not quiet).
virtual size_t channel_count() const NOEXCEPT;

/// The number of inbound peer channels (counted, not quiet).
virtual size_t inbound_channel_count() const NOEXCEPT;

protected:

/// Constructors.
Expand Down
3 changes: 2 additions & 1 deletion src/chasers/chaser_estimate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ bool chaser_estimate::handle_chase(const code&, chase event_,
{
BC_ASSERT(std::holds_alternative<header_t>(value));
POST(do_reorganized, std::get<header_t>(value));
break;
}

break;
}
case chase::stop:
{
Expand Down
8 changes: 7 additions & 1 deletion src/full_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ full_node::full_node(query& query, const configuration& configuration,
const logger& log) NOEXCEPT
: net(configuration.network, log),
config_(configuration),
start_time_(zulu_time()),
query_(query),
chaser_block_(*this),
chaser_header_(*this),
Expand Down Expand Up @@ -431,13 +432,18 @@ bool full_node::is_current_header(const header_link& link) const NOEXCEPT

bool full_node::is_recent() const NOEXCEPT
{
if (is_nonzero(config_.node.maximum_height) &&
if (is_nonzero(config_.node.maximum_height) &&
(query_.get_top_confirmed() >= config_.node.maximum_height))
return true;

return is_current_chain(true);
}

time_t full_node::start_time() const NOEXCEPT
{
return start_time_;
}

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

Expand Down
15 changes: 15 additions & 0 deletions src/protocols/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ bool protocol::is_current_chain(bool confirmed) const NOEXCEPT
return session_->is_current_chain(confirmed);
}

time_t protocol::start_time() const NOEXCEPT
{
return session_->start_time();
}

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

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

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

Expand Down
15 changes: 15 additions & 0 deletions src/sessions/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ bool session::is_recent() const NOEXCEPT
return node_.is_recent();
}

time_t session::start_time() const NOEXCEPT
{
return node_.start_time();
}

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

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

BC_POP_WARNING()

} // namespace node
Expand Down
Loading