Skip to content

Commit

Permalink
Documenting and encapsulating member variables for bulk_pull_client a…
Browse files Browse the repository at this point in the history
…long with misc cleanup.
  • Loading branch information
clemahieu committed Jul 9, 2022
1 parent eff3fd5 commit 94cdae7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
12 changes: 4 additions & 8 deletions nano/node/bootstrap/bootstrap_bulk_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ nano::pull_info::pull_info (nano::hash_or_account const & account_or_head_a, nan
}

nano::bulk_pull_client::bulk_pull_client (std::shared_ptr<nano::bootstrap_client> const & connection_a, std::shared_ptr<nano::bootstrap_attempt> const & attempt_a, nano::pull_info const & pull_a) :
connection (connection_a),
attempt (attempt_a),
known_account{},
pull (pull_a),
pull_blocks (0),
unexpected_count (0),
connection{ connection_a },
attempt{ attempt_a },
pull{ pull_a },
block_deserializer{ std::make_shared<nano::bootstrap::block_deserializer> () }
{
attempt->condition.notify_all ();
Expand Down Expand Up @@ -214,8 +211,7 @@ void nano::bulk_pull_client::received_block (boost::system::error_code ec, std::
nano::bulk_pull_account_client::bulk_pull_account_client (std::shared_ptr<nano::bootstrap_client> const & connection_a, std::shared_ptr<nano::bootstrap_attempt_wallet> const & attempt_a, nano::account const & account_a) :
connection (connection_a),
attempt (attempt_a),
account (account_a),
pull_blocks (0)
account (account_a)
{
attempt->condition.notify_all ();
}
Expand Down
27 changes: 22 additions & 5 deletions nano/node/bootstrap/bootstrap_bulk_pull.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,31 @@ class bulk_pull_client final : public std::enable_shared_from_this<nano::bulk_pu
nano::block_hash first ();
std::shared_ptr<nano::bootstrap_client> connection;
std::shared_ptr<nano::bootstrap_attempt> attempt;
nano::block_hash expected;
nano::account known_account;
nano::pull_info pull;
uint64_t pull_blocks;
uint64_t unexpected_count;
bool network_error{ false };

private:
/**
* Tracks the next block expected to be received starting with the block hash that was expected and followed by previous blocks for this account chain
*/
nano::block_hash expected{ 0 };
/**
* Tracks the account number for this account chain
* Used when an account chain has a mix between state blocks and legacy blocks which do not encode the account number in the block
* 0 if the account is unknown
*/
nano::account known_account{ 0 };
/**
* Original pull request
*/
nano::pull_info pull;
/**
* Tracks the number of blocks successfully deserialized
*/
uint64_t pull_blocks{ 0 };
/**
* Tracks the number of times an unexpected block was received
*/
uint64_t unexpected_count{ 0 };
std::shared_ptr<nano::bootstrap::block_deserializer> block_deserializer;
};
class bootstrap_attempt_wallet;
Expand Down

0 comments on commit 94cdae7

Please sign in to comment.