From a1432635d0dba55f3777e897c09a12aca57798bb Mon Sep 17 00:00:00 2001 From: clemahieu Date: Tue, 12 Jul 2022 07:19:39 +0100 Subject: [PATCH] Cleaning up initialization of bulk_pull_client. --- nano/node/bootstrap/bootstrap_bulk_pull.cpp | 9 +++---- nano/node/bootstrap/bootstrap_bulk_pull.hpp | 29 +++++++++++++++++---- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/nano/node/bootstrap/bootstrap_bulk_pull.cpp b/nano/node/bootstrap/bootstrap_bulk_pull.cpp index 750e537b4..06a54f5ea 100644 --- a/nano/node/bootstrap/bootstrap_bulk_pull.cpp +++ b/nano/node/bootstrap/bootstrap_bulk_pull.cpp @@ -19,12 +19,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 const & connection_a, std::shared_ptr 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 } { attempt->condition.notify_all (); } diff --git a/nano/node/bootstrap/bootstrap_bulk_pull.hpp b/nano/node/bootstrap/bootstrap_bulk_pull.hpp index 762dc38c4..e92cc5b24 100644 --- a/nano/node/bootstrap/bootstrap_bulk_pull.hpp +++ b/nano/node/bootstrap/bootstrap_bulk_pull.hpp @@ -42,12 +42,31 @@ public: nano::block_hash first (); std::shared_ptr connection; std::shared_ptr 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 }; }; class bootstrap_attempt_wallet; class bulk_pull_account_client final : public std::enable_shared_from_this