Fix request aggregator reply for account open block
This commit is contained in:
parent
418c8ec592
commit
9594e8b2dc
1 changed files with 26 additions and 11 deletions
|
|
@ -202,21 +202,36 @@ auto nano::request_aggregator::aggregate (nano::secure::transaction const & tran
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<nano::block>> to_generate;
|
std::vector<std::shared_ptr<nano::block>> to_generate;
|
||||||
std::vector<std::shared_ptr<nano::block>> to_generate_final;
|
std::vector<std::shared_ptr<nano::block>> to_generate_final;
|
||||||
|
|
||||||
for (auto const & [hash, root] : requests_a)
|
for (auto const & [hash, root] : requests_a)
|
||||||
{
|
{
|
||||||
// Ledger by hash
|
auto search_for_block = [&] () -> std::shared_ptr<nano::block> {
|
||||||
std::shared_ptr<nano::block> block = ledger.any.block_get (transaction, hash);
|
// Ledger by hash
|
||||||
|
if (auto block = ledger.any.block_get (transaction, hash))
|
||||||
// Ledger by root
|
|
||||||
if (!block && !root.is_zero ())
|
|
||||||
{
|
|
||||||
// Search for block root
|
|
||||||
if (auto successor = ledger.any.block_successor (transaction, root.as_block_hash ()))
|
|
||||||
{
|
{
|
||||||
block = ledger.any.block_get (transaction, successor.value ());
|
return block;
|
||||||
release_assert (block);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Ledger by root
|
||||||
|
if (!root.is_zero ())
|
||||||
|
{
|
||||||
|
// Search for successor of root
|
||||||
|
if (auto successor = ledger.any.block_successor (transaction, root.as_block_hash ()))
|
||||||
|
{
|
||||||
|
return ledger.any.block_get (transaction, successor.value ());
|
||||||
|
}
|
||||||
|
|
||||||
|
// If that fails treat root as account
|
||||||
|
if (auto info = ledger.any.account_get (transaction, root.as_account ()))
|
||||||
|
{
|
||||||
|
return ledger.any.block_get (transaction, info->open_block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto block = search_for_block ();
|
||||||
|
|
||||||
auto should_generate_final_vote = [&] (auto const & block) {
|
auto should_generate_final_vote = [&] (auto const & block) {
|
||||||
release_assert (block);
|
release_assert (block);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue