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
5 changes: 5 additions & 0 deletions include/bitcoin/node/channels/channel_peer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class BCN_API channel_peer
/// The hash is (probably) known to the peer.
bool was_announced(const system::hash_digest& hash) const NOEXCEPT;

/// Peer told not to announce txs (requires strand).
void set_silenced(bool value) NOEXCEPT;
bool silenced() const NOEXCEPT;

/// Set the handler of work offered by the channel's own protocols.
void set_downloader(downloader&& handler) NOEXCEPT;

Expand Down Expand Up @@ -80,6 +84,7 @@ class BCN_API channel_peer

// These are protected by strand.
rolling_bloom_filter announced_{};
bool silenced_{};
downloader downloader_{};
};

Expand Down
42 changes: 21 additions & 21 deletions include/bitcoin/node/chase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ enum class chase
/// Issued by 'confirm' and handled by 'snapshot'.
snap,

/// Chaser directed to attempt start from its current position.
/// Chaser directed to attempt start from current position.
/// Issued by 'organize' and handled by 'download', 'validate', 'confirm'.
bump,

/// Channels (all) directed to stop with the given code.
/// Channels (all) directed to stop with given code.
/// Issued by 'full_node' and handled by 'observer'.
suspend,

Expand Down Expand Up @@ -85,22 +85,22 @@ enum class chase
/// Issued by 'download' and handled by 'block_in_31800'.
purge,

/// Channels (all) directed to write work count to the log.
/// Channels (all) directed to write work count to log.
/// Issued by 'executor' and handled by 'block_in_31800'.
report,

/// Candidate Chain.
/// -----------------------------------------------------------------------

/// A new candidate branch exists from given branch point.
/// New candidate branch exists from given branch point.
/// Issued by 'header' and handled by 'download'.
headers,

/// New candidate headers without txs exist.
/// Issued by 'download' and handled by 'block_in_31800'.
download,

/// The candidate chain has been reorganized (branched below its top).
/// Candidate chain has been reorganized (branched below its top).
/// Issued by 'organize' and handled by 'download', 'validate', 'confirm'.
regressed,

Expand All @@ -111,81 +111,81 @@ enum class chase
/// Check/Identify.
/// -----------------------------------------------------------------------

/// A block has been downloaded, checked and stored.
/// Block has been downloaded, checked and stored.
/// Issued by 'block_in_31800', handled by 'download', 'validate'.
/// Populate is bypassed for checkpoint/milestone blocks.
checked,

/// A downloaded block has failed check.
/// Downloaded block has failed check.
/// Issued by 'block_in_31800', 'transaction' and handled by 'organize'.
unchecked,

/// A downloaded window is completed by check.
/// Downloaded window is completed by check.
/// Issued by 'download' and handled by 'validate'.
windowed,

/// Accept/Connect.
/// -----------------------------------------------------------------------

/// A branch has become valid.
/// Branch has become valid.
/// Issued by 'validate' and handled by 'download', 'confirm'.
valid,

/// A checked block has failed validation.
/// Checked block has failed validation.
/// Issued by 'validate' and handled by 'organize'.
unvalid,

/// Confirm (block).
/// -----------------------------------------------------------------------

/// A connected block has become confirmable.
/// Connected block has become confirmable.
/// Issued by 'confirm' and handled by none.
confirmable,

/// A connected block has failed confirmability.
/// Connected block has failed confirmability.
/// Issued by 'confirm' and handled by 'organize'.
unconfirmable,

/// Confirm (chain).
/// -----------------------------------------------------------------------

/// A current block has been organized.
/// Current block has been organized.
/// Issued by 'confirm' and handled by 'transaction',
/// 'protocol_header/block_out'.
block,

/// A current block has been settled in the pool.
/// Current block has been settled in pool.
/// Issued by 'transaction' and handled by 'snapshot'.
block_settled,

/// The store has been pruned (once, following the first settled block).
/// Store has been pruned (once, following first settled block).
/// Issued by 'snapshot' and handled by 'transaction'.
pruned,

/// The confirmed chain is no longer current.
/// Confirmed chain is no longer current.
/// Issued by 'confirm' and handled by 'protocol_transaction_out'.
stale,

/// A confirmable block has been confirmed.
/// Confirmable block has been confirmed.
/// Issued by 'confirm' and handled by 'transaction'.
organized,

/// A previously confirmed block has been unconfirmed.
/// Previously confirmed block has been unconfirmed.
/// Issued by 'confirm' and handled by 'transaction'.
reorganized,

/// Mining.
/// -----------------------------------------------------------------------

/// A transaction has been added to the pool.
/// Transaction has been added to pool.
/// Issued by 'transaction' and handled by [clients].
transaction,

/// A pooled transaction has been relayed to a word of slots, in order.
/// Pooled transaction has been relayed to word of slots, in order.
/// Issued by 'transaction' and handled by 'protocol_transaction_out'.
relay,

/// A candidate block (template) has been created, upon request.
/// Candidate block (template) has been created, upon request.
/// Issued by 'template' and handled by [miners].
template_,

Expand Down
10 changes: 5 additions & 5 deletions include/bitcoin/node/chasers/chaser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class full_node;

/// Abstract base chaser for thread safe chain state management classes.
/// Chasers impose order on blockchain/pool construction as necessary.
/// Each chaser operates on its own strand, implemented here, allowing
/// concurrent chaser operations to the extent that threads are available.
/// Events are passed between chasers using the full_node shared notifier.
/// Unlike protocols chasers can stop the node.
/// Each chaser operates on own strand, implemented here, allowing concurrent
/// chaser operations to extent threads are available.
/// Events are passed between chasers using full_node shared notifier.
/// Unlike protocols, chasers can stop node.
class BCN_API chaser
: public network::reporter
{
Expand Down Expand Up @@ -79,7 +79,7 @@ class BCN_API chaser
virtual bool suspended() const NOEXCEPT;

/// Suspend all existing and future network connections.
/// A race condition could result in an unsuspended connection.
/// Race condition could result in unsuspended connection.
virtual code fault(const code& ec) NOEXCEPT;

/// Resume all network connections.
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/node/chasers/chaser_download.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class BCN_API chaser_download
virtual void put_hashes(const map_ptr& map,
network::result_handler&& handler) NOEXCEPT;

/// Interface for a protocol to obtain the block of a compact block that
/// it did not fill, as work for its own channel (empty if issued before).
/// Interface for protocol to obtain block of compact block it did not fill,
/// as work for its own channel (empty if issued before).
virtual void get_unfilled(header_t link, map_handler&& handler) NOEXCEPT;

protected:
Expand Down
8 changes: 4 additions & 4 deletions include/bitcoin/node/chasers/chaser_header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ namespace node {

class full_node;

/// Chase down stronger header branches for the candidate chain.
/// Weak branches are retained in a hash table if not store populated.
/// Strong branches reorganize the candidate chain and fire the 'header' event.
/// Headers are validated and proven by the protocol, so all are storable.
/// Chase down stronger header branches for candidate chain.
/// Weak branches are retained in hash table if not store populated.
/// Strong branches reorganize candidate chain and fire 'header' event.
/// Headers are validated and proven by protocol, so all are storable.
class BCN_API chaser_header
: public chaser
{
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/chasers/chaser_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace node {

class full_node;

/// Monitor storage capacity following a disk full condition.
/// Monitor storage capacity following disk full condition.
/// Clear disk full condition and restart network given increased capacity.
class BCN_API chaser_storage
: public chaser
Expand Down
3 changes: 1 addition & 2 deletions include/bitcoin/node/chasers/chaser_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class BCN_API chaser_template

code start() NOEXCEPT override;

/// A template of pooled txs built upon the request, parents first, and
/// its height.
/// Template of pooled txs built on request, parents first, and its height.
virtual void get_template(template_handler&& handler) NOEXCEPT;

protected:
Expand Down
55 changes: 27 additions & 28 deletions include/bitcoin/node/chasers/chaser_transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,26 @@ class BCN_API chaser_transaction
void stopping(const code& ec) NOEXCEPT override;
void stop() NOEXCEPT override;

/// Validate and archive a submitted set, admitted prefix by prefix until
/// one tx fails. The set is only validated when test, nothing archived.
/// Validate and archive submitted set, admitted prefix by prefix until one
/// tx fails. Set is only validated when test, nothing archived.
virtual void submit(const system::chain::transactions_cptr& txs,
bool test, submit_handler&& handler) NOEXCEPT;

/// Validate and archive an announced set, admitted prefix by prefix, a tx
/// that is not accepted passed over (the first such failure reported).
/// Validate and archive announced set, admitted prefix by prefix, tx not
/// accepted passed over (first such failure reported).
virtual void submit_announced(
const system::chain::transactions_cptr& txs, size_t slot,
submit_handler&& handler) NOEXCEPT;

/// Validate, archive and associate the txs of an identified compact block,
/// in block order, the txs filling the terminal links.
/// Validate, archive and associate txs of identified compact block, in
/// block order, txs filling terminal links.
virtual void submit_compact(const system::chain::transactions_cptr& txs,
const database::tx_links& links, const database::header_link& link,
submit_handler&& handler) NOEXCEPT;

/// Archive and associate the txs of an identified block. Not pooling, on
/// the calling thread, returning true with the code. Pooling, on the
/// strand with compact blocks, returning false and handling the code
/// (thread safe).
/// Archive and associate txs of identified block. Not pooling, on calling
/// thread, returning true with code. Pooling, on strand with compact
/// blocks, returning false and handling code (thread safe).
virtual bool archive_block(code& ec,
const system::chain::view::block::cptr& block,
const database::header_link& link, bool strong, bool bypass,
Expand All @@ -91,8 +90,8 @@ class BCN_API chaser_transaction
/// Reserve a free slot of the tier, relay_slots if none (thread safe).
virtual size_t reserve_relay(relay_tier tier) NOEXCEPT;

/// Start relay to the slot, once its channel is notified of relay.
virtual void activate_relay(size_t slot) NOEXCEPT;
/// Start relay to slot, its channel notified by events key.
virtual void activate_relay(size_t slot, object_key key) NOEXCEPT;

/// Release the relay slot, free once cleared from the marks.
virtual void release_relay(size_t slot) NOEXCEPT;
Expand Down Expand Up @@ -132,24 +131,24 @@ class BCN_API chaser_transaction
virtual void do_get_confirmable_fees(
const confirmable_fees_handler& handler) NOEXCEPT;

/// Recompute the pool context and sweep the index by it if due, closing
/// the pool if not current or the context is not reusable, and map scan
/// starts: built once current, extended by block until pooling, and
/// remapped when a block archived before the latch is organized.
/// Recompute pool context and sweep index by it if due, closing pool if not
/// current or context not reusable, and map scan starts: built once
/// current, extended by block until pooling, and remapped when block
/// archived before latch is organized.
virtual void do_bump() NOEXCEPT;

/// Retain the pool subscription.
virtual void do_subscribe_pool(const pool_notifier& handler) NOEXCEPT;

/// Relay slot management.
virtual void do_activate_relay(size_t slot) NOEXCEPT;
virtual void do_activate_relay(size_t slot, object_key key) NOEXCEPT;
virtual void do_release_relay(size_t slot) NOEXCEPT;
virtual void do_set_relay_rate(size_t slot, uint64_t rate) NOEXCEPT;
virtual void do_set_relayed(size_t slot,
const database::tx_links& links) NOEXCEPT;
virtual void do_relay_pool(size_t slot) NOEXCEPT;

/// Sweep the pool to one slot owed a sweep, then post for the next.
/// Sweep pool to one slot owed a sweep, then post for next.
virtual void do_sweep_relay() NOEXCEPT;

/// Apply the organized block to the pool index, then bump.
Expand Down Expand Up @@ -243,20 +242,19 @@ class BCN_API chaser_transaction
void start_scan(bool remap) NOEXCEPT;
void start_revalidation() NOEXCEPT;

/// Relay the txs with their unconfirmed ancestry, marked held by origin,
/// to each of the slots whose rate the sum of the rows it lacks clears.
/// Relay txs with their unconfirmed ancestry, marked held by origin, to
/// each slot whose rate the sum of rows it lacks clears.
bool relay(const database::tx_links& links, size_t origin,
uint64_t slots) NOEXCEPT;
uint64_t slots, object_key key={}) NOEXCEPT;

/// Relay the confirmable txs in row order, each with the ancestry the
/// slot lacks, where that clears the slot's rate.
/// Relay confirmable txs in row order, each with ancestry slot lacks, where
/// that clears slot's rate.
bool sweep_relay(size_t slot) NOEXCEPT;

/// Owe the slot a sweep, made at once unless it was swept since the last
/// block, and otherwise after the next.
/// Owe slot a sweep, made now unless swept since last block.
void owe_relay(size_t slot) NOEXCEPT;

/// The relaying slots owed a sweep and not swept since the last block.
/// Relaying slots owed a sweep and not swept since last block.
uint64_t sweepable() const NOEXCEPT;

/// The marks of the pool row, grown with the table.
Expand All @@ -276,8 +274,8 @@ class BCN_API chaser_transaction
static uint64_t arriving(const query::pool_arrivals& arrivals,
uint64_t rate, estimate_mode mode) NOEXCEPT;

/// Notify pool subscribers of the scan, timed from its start, and fire
/// its event (other than for coverage, which fires only when it clears).
/// Notify pool subscribers of scan, timed from its start, and fire its
/// event (other than for coverage, which fires only when it clears).
using time_point = std::chrono::steady_clock::time_point;
static time_point now() NOEXCEPT;
void report(pool_scan scan, const time_point& start) NOEXCEPT;
Expand Down Expand Up @@ -316,6 +314,7 @@ class BCN_API chaser_transaction
system::chain::context retried_{};
std::vector<uint64_t> marks_{};
std::array<uint64_t, relay_slots> rates_{};
std::array<object_key, relay_slots> keys_{};
uint64_t relaying_{};
uint64_t owed_{};
uint64_t swept_{};
Expand Down
10 changes: 5 additions & 5 deletions include/bitcoin/node/chasers/chaser_validate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class BCN_API chaser_validate
const header_link& link, bool bypass, bool startup=false) NOEXCEPT;

/// Batching (lock-free, self-serviced by completing pool threads).
/// Batch state is the store: sig tables carry rows, prevalid table
/// carries the per-block link set (write-through, crash-durable).
/// Tables are banked, commits fill one bank while the other drains.
/// Batch state is store: sig tables carry rows, prevalid table carries
/// per-block link set (write-through, crash-durable).
/// Tables are banked, commits fill one bank while other drains.
virtual code start_batch() NOEXCEPT;
virtual void process_batch(bool residual) NOEXCEPT;
virtual code do_process_batch(bool bank, bool startup) NOEXCEPT;
Expand All @@ -106,8 +106,8 @@ class BCN_API chaser_validate
virtual void exit_capture(bool bank) NOEXCEPT;

/// Silent payment batch.
/// Banked and drained independently of signatures, and computed in the
/// drain, after which their blocks can be confirmed if also valid.
/// Banked and drained independently of signatures, computed in drain, after
/// which their blocks can be confirmed if also valid.
virtual code start_silent_batch() NOEXCEPT;
virtual void process_silent_batch(bool residual) NOEXCEPT;
virtual code do_process_silent_batch(bool bank) NOEXCEPT;
Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/node/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ typedef std::error_code code;

namespace error {

/// Asio failures are normalized to the error codes below.
/// Stop by explicit call is mapped to channel_stopped or service_stopped
/// depending on the context. Asio errors returned on cancel calls are ignored.
/// Asio failures are normalized to error codes below.
/// Stop by explicit call mapped to channel_stopped or service_stopped depending
/// on context. Asio errors returned on cancel calls are ignored.
enum error_t : uint8_t
{
/// general
Expand Down
Loading
Loading