Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
Defensive check for the subtree syncing (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejfitzgerald authored Jun 10, 2019
1 parent e335be6 commit 421fdf4
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions libs/ledger/src/storage_unit/transaction_store_sync_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,27 @@ TransactionStoreSyncService::State TransactionStoreSyncService::OnQuerySubtree()
assert(!roots_to_sync_.empty());

FETCH_LOCK(mutex_);
for (auto const &connection : muddle_->AsEndpoint().GetDirectlyConnectedPeers())

// sanity check that this is not the case
if (!roots_to_sync_.empty())
{
auto root = roots_to_sync_.front();
roots_to_sync_.pop();
for (auto const &connection : muddle_->AsEndpoint().GetDirectlyConnectedPeers())
{
auto root = roots_to_sync_.front();
roots_to_sync_.pop();

byte_array::ByteArray transactions_prefix;
byte_array::ByteArray transactions_prefix;

transactions_prefix.Resize(std::size_t{ResourceID::RESOURCE_ID_SIZE_IN_BYTES});
transactions_prefix[0] = root;
transactions_prefix.Resize(std::size_t{ResourceID::RESOURCE_ID_SIZE_IN_BYTES});
transactions_prefix[0] = root;

auto promise = PromiseOfTxList(client_->CallSpecificAddress(
connection, RPC_TX_STORE_SYNC, TransactionStoreSyncProtocol::PULL_SUBTREE,
transactions_prefix, root_size_));
auto promise = PromiseOfTxList(client_->CallSpecificAddress(
connection, RPC_TX_STORE_SYNC, TransactionStoreSyncProtocol::PULL_SUBTREE,
transactions_prefix, root_size_));

promise_id_to_roots_[promise.id()] = root;
pending_subtree_.Add(root, promise);
promise_id_to_roots_[promise.id()] = root;
pending_subtree_.Add(root, promise);
}
}

if (!roots_to_sync_.empty())
Expand Down

0 comments on commit 421fdf4

Please sign in to comment.