Skip to content

Commit

Permalink
Add class description to mostly of bootstrap classes (#3725)
Browse files Browse the repository at this point in the history
  • Loading branch information
thsfs committed Feb 9, 2022
1 parent 7ea11f8 commit d67f7be
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nano/node/bootstrap/bootstrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class pulls_cache final
// clang-format on
constexpr static std::size_t cache_size_max = 10000;
};

/**
* Container for bootstrap sessions that are active. Owned by bootstrap_initiator.
*/
class bootstrap_attempts final
{
public:
Expand All @@ -76,6 +80,10 @@ class bootstrap_attempts final
std::map<uint64_t, std::shared_ptr<nano::bootstrap_attempt>> attempts;
};

/**
* Client side portion to initiate bootstrap sessions. Prevents multiple legacy-type bootstrap sessions from being started at the same time. Does permit
* lazy/wallet bootstrap sessions to overlap with legacy sessions.
*/
class bootstrap_initiator final
{
public:
Expand Down Expand Up @@ -117,6 +125,10 @@ class bootstrap_initiator final
};

std::unique_ptr<container_info_component> collect_container_info (bootstrap_initiator & bootstrap_initiator, std::string const & name);

/**
* Defines the numeric values for the bootstrap feature.
*/
class bootstrap_limits final
{
public:
Expand Down
4 changes: 4 additions & 0 deletions nano/node/bootstrap/bootstrap_attempt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class node;

class frontier_req_client;
class bulk_push_client;

/**
* Polymorphic base class for bootstrap sessions.
*/
class bootstrap_attempt : public std::enable_shared_from_this<bootstrap_attempt>
{
public:
Expand Down
10 changes: 10 additions & 0 deletions nano/node/bootstrap/bootstrap_bulk_pull.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class pull_info
uint64_t bootstrap_id{ 0 };
};
class bootstrap_client;

/**
* Client side of a bulk_pull request. Created when the bootstrap_attempt wants to make a bulk_pull request to the remote side.
*/
class bulk_pull_client final : public std::enable_shared_from_this<nano::bulk_pull_client>
{
public:
Expand Down Expand Up @@ -59,6 +63,12 @@ class bulk_pull_account_client final : public std::enable_shared_from_this<nano:
};
class bootstrap_server;
class bulk_pull;

/**
* Server side of a bulk_pull request. Created when bootstrap_server receives a bulk_pull message and is exited after the contents
* have been sent. If the 'start' in the bulk_pull message is an account, send blocks for that account down to 'end'. If the 'start'
* is a block hash, send blocks for that chain down to 'end'. If end doesn't exist, send all accounts in the chain.
*/
class bulk_pull_server final : public std::enable_shared_from_this<nano::bulk_pull_server>
{
public:
Expand Down
8 changes: 8 additions & 0 deletions nano/node/bootstrap/bootstrap_bulk_push.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ namespace nano
{
class bootstrap_attempt;
class bootstrap_client;

/**
* Client side of a bulk_push request. Sends a sequence of blocks the other side did not report in their frontier_req response.
*/
class bulk_push_client final : public std::enable_shared_from_this<nano::bulk_push_client>
{
public:
Expand All @@ -23,6 +27,10 @@ class bulk_push_client final : public std::enable_shared_from_this<nano::bulk_pu
std::pair<nano::block_hash, nano::block_hash> current_target;
};
class bootstrap_server;

/**
* Server side of a bulk_push request. Receives blocks and puts them in the block processor to be processed.
*/
class bulk_push_server final : public std::enable_shared_from_this<nano::bulk_push_server>
{
public:
Expand Down
8 changes: 8 additions & 0 deletions nano/node/bootstrap/bootstrap_connections.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class bootstrap_attempt;
class bootstrap_connections;
class frontier_req_client;
class pull_info;

/**
* Owns the client side of the bootstrap connection.
*/
class bootstrap_client final : public std::enable_shared_from_this<bootstrap_client>
{
public:
Expand All @@ -42,6 +46,10 @@ class bootstrap_client final : public std::enable_shared_from_this<bootstrap_cli
std::chrono::steady_clock::time_point start_time_m;
};

/**
* Container for bootstrap_client objects. Owned by bootstrap_initiator which pools open connections and makes them available
* for use by different bootstrap sessions.
*/
class bootstrap_connections final : public std::enable_shared_from_this<bootstrap_connections>
{
public:
Expand Down
8 changes: 8 additions & 0 deletions nano/node/bootstrap/bootstrap_frontier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ namespace nano
{
class bootstrap_attempt;
class bootstrap_client;

/**
* Client side of a frontier request. Created to send and listen for frontier sequences from the server.
*/
class frontier_req_client final : public std::enable_shared_from_this<nano::frontier_req_client>
{
public:
Expand Down Expand Up @@ -36,6 +40,10 @@ class frontier_req_client final : public std::enable_shared_from_this<nano::fron
};
class bootstrap_server;
class frontier_req;

/**
* Server side of a frontier request. Created when a bootstrap_server receives a frontier_req message and exited when end-of-list is reached.
*/
class frontier_req_server final : public std::enable_shared_from_this<nano::frontier_req_server>
{
public:
Expand Down
9 changes: 9 additions & 0 deletions nano/node/bootstrap/bootstrap_lazy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class lazy_state_backlog_item final
nano::uint128_t balance{ 0 };
unsigned retry_limit{ 0 };
};

/**
* Lazy bootstrap session. Started with a block hash, this will "trace down" the blocks obtained to find a connection to the ledger.
* This attempts to quickly bootstrap a section of the ledger given a hash that's known to be confirmed.
*/
class bootstrap_attempt_lazy final : public bootstrap_attempt
{
public:
Expand Down Expand Up @@ -60,6 +65,10 @@ class bootstrap_attempt_lazy final : public bootstrap_attempt
/** The maximum number of records to be read in while iterating over long lazy containers */
static uint64_t constexpr batch_read_size = 256;
};

/**
* Wallet bootstrap session. This session will trace down accounts within local wallets to try and bootstrap those blocks first.
*/
class bootstrap_attempt_wallet final : public bootstrap_attempt
{
public:
Expand Down
3 changes: 3 additions & 0 deletions nano/node/bootstrap/bootstrap_legacy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace nano
{
class node;

/**
* Legacy bootstrap session. This is made up of 3 phases: frontier requests, bootstrap pulls, bootstrap pushes.
*/
class bootstrap_attempt_legacy : public bootstrap_attempt
{
public:
Expand Down
8 changes: 8 additions & 0 deletions nano/node/bootstrap/bootstrap_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
namespace nano
{
class bootstrap_server;

/**
* Server side portion of bootstrap sessions. Listens for new socket connections and spawns bootstrap_server objects when connected.
*/
class bootstrap_listener final
{
public:
Expand All @@ -32,6 +36,10 @@ class bootstrap_listener final
std::unique_ptr<container_info_component> collect_container_info (bootstrap_listener & bootstrap_listener, std::string const & name);

class message;

/**
* Owns the server side of a bootstrap connection. Responds to bootstrap messages sent over the socket.
*/
class bootstrap_server final : public std::enable_shared_from_this<nano::bootstrap_server>
{
public:
Expand Down

0 comments on commit d67f7be

Please sign in to comment.