mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Request historical shards when max shard range is increased (#266)
* Remove and request historical shards at the startup * Shard history requesting only at the first consensus round * Removed test log * Skip max shard seq no file in removing loop * Updated the code comments * Persisting condition changed * Fixed code comment typos * Fixed code comment typos * Resolved PR comments * Halt consensus until completing only the latest shard sync * Added meaningful comments * Resolved PR comments and updated hpfs binary * Logic enhancement and cleanup * Cleanup the code comment
This commit is contained in:
@@ -199,6 +199,7 @@ namespace consensus
|
||||
const std::string majority_shard_seq_no_str = std::to_string(majority_primary_shard_id.seq_no);
|
||||
const std::string sync_name = "primary shard " + majority_shard_seq_no_str;
|
||||
const std::string shard_path = std::string(ledger::PRIMARY_DIR).append("/").append(majority_shard_seq_no_str);
|
||||
ledger::ledger_sync_worker.is_last_primary_shard_syncing = true;
|
||||
ledger::ledger_sync_worker.set_target_push_front(hpfs::sync_target{sync_name, majority_primary_shard_id.hash, shard_path, hpfs::BACKLOG_ITEM_TYPE::DIR});
|
||||
}
|
||||
|
||||
@@ -238,10 +239,24 @@ namespace consensus
|
||||
const std::string majority_shard_seq_no_str = std::to_string(majority_blob_shard_id.seq_no);
|
||||
const std::string sync_name = "blob shard " + majority_shard_seq_no_str;
|
||||
const std::string shard_path = std::string(ledger::BLOB_DIR).append("/").append(majority_shard_seq_no_str);
|
||||
ledger::ledger_sync_worker.is_last_blob_shard_syncing = true;
|
||||
ledger::ledger_sync_worker.set_target_push_back(hpfs::sync_target{sync_name, majority_blob_shard_id.hash, shard_path, hpfs::BACKLOG_ITEM_TYPE::DIR});
|
||||
}
|
||||
}
|
||||
|
||||
// If shards aren't aligned with max shard count, Do the relevant shard cleanups and requests.
|
||||
// In the first consensus round sync completion after the startup.
|
||||
if (!ledger::ledger_sync_worker.is_syncing && (!ledger::ctx.primary_shards_persisted || !ledger::ctx.blob_shards_persisted) && ledger::ledger_fs.acquire_rw_session() != -1)
|
||||
{
|
||||
if (!ledger::ctx.primary_shards_persisted)
|
||||
ledger::persist_shard_history(majority_primary_shard_id.seq_no, ledger::PRIMARY_DIR);
|
||||
|
||||
if (!ledger::ctx.blob_shards_persisted)
|
||||
ledger::persist_shard_history(majority_blob_shard_id.seq_no, ledger::BLOB_DIR);
|
||||
|
||||
ledger::ledger_fs.release_rw_session();
|
||||
}
|
||||
|
||||
// Proceed further only if last primary shard, last blob shard, state and patch hashes are in sync with majority.
|
||||
if (!is_last_primary_shard_desync && !is_last_blob_shard_desync && !is_state_desync && !is_patch_desync)
|
||||
{
|
||||
@@ -263,7 +278,8 @@ namespace consensus
|
||||
*/
|
||||
void check_sync_completion()
|
||||
{
|
||||
if (conf::cfg.node.role == conf::ROLE::OBSERVER && !sc::contract_sync_worker.is_syncing && !ledger::ledger_sync_worker.is_syncing)
|
||||
// In ledger sync we only concern about last shard sync status to proceed with consensus.
|
||||
if (conf::cfg.node.role == conf::ROLE::OBSERVER && !sc::contract_sync_worker.is_syncing && !ledger::ledger_sync_worker.is_last_primary_shard_syncing && !ledger::ledger_sync_worker.is_last_blob_shard_syncing)
|
||||
conf::change_role(conf::ROLE::VALIDATOR);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user