Updating election fields inside election class.
This commit is contained in:
parent
945c8ca3a1
commit
c0a09fa0e9
2 changed files with 9 additions and 7 deletions
|
|
@ -632,14 +632,10 @@ void nano::active_transactions::update_difficulty (std::shared_ptr<nano::block>
|
||||||
{
|
{
|
||||||
node.logger.try_log (boost::str (boost::format ("Block %1% was updated from difficulty %2% to %3%") % block_a->hash ().to_string () % nano::to_string_hex (existing_election->difficulty) % nano::to_string_hex (difficulty)));
|
node.logger.try_log (boost::str (boost::format ("Block %1% was updated from difficulty %2% to %3%") % block_a->hash ().to_string () % nano::to_string_hex (existing_election->difficulty) % nano::to_string_hex (difficulty)));
|
||||||
}
|
}
|
||||||
roots.get<tag_root> ().modify (existing_election, [&block_a, difficulty](nano::conflict_info & info_a) {
|
roots.get<tag_root> ().modify (existing_election, [difficulty](nano::conflict_info & info_a) {
|
||||||
info_a.difficulty = difficulty;
|
info_a.difficulty = difficulty;
|
||||||
info_a.election->blocks[block_a->hash ()] = block_a;
|
|
||||||
if (info_a.election->status.winner->hash () == block_a->hash ())
|
|
||||||
{
|
|
||||||
info_a.election->status.winner = block_a;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
existing_election->election->publish (block_a);
|
||||||
adjust_difficulty (block_a->hash ());
|
adjust_difficulty (block_a->hash ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,8 @@ bool nano::election::publish (std::shared_ptr<nano::block> block_a)
|
||||||
}
|
}
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
if (blocks.find (block_a->hash ()) == blocks.end ())
|
auto existing = blocks.find (block_a->hash ());
|
||||||
|
if (existing == blocks.end ())
|
||||||
{
|
{
|
||||||
blocks.emplace (std::make_pair (block_a->hash (), block_a));
|
blocks.emplace (std::make_pair (block_a->hash (), block_a));
|
||||||
insert_inactive_votes_cache (block_a->hash ());
|
insert_inactive_votes_cache (block_a->hash ());
|
||||||
|
|
@ -221,6 +222,11 @@ bool nano::election::publish (std::shared_ptr<nano::block> block_a)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
|
existing->second = block_a;
|
||||||
|
if (status.winner->hash () == block_a->hash ())
|
||||||
|
{
|
||||||
|
status.winner = block_a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue