Skip to content

Commit

Permalink
Remove elements from map outside of loop. (#4682)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmy authored Dec 2, 2022
1 parent 1e2708f commit ff0d8c6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"ghcr.io/devcontainers/features/docker-from-docker:1": {
"version": "latest"
}
}
},
"postCreateCommand": "DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install gdb -y"
}
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,25 @@
"postRunCommands": [
"process handle --pass true --stop false --notify true SIGILL"
]
},
{
"name": "Debug Raft Test Scenarios (gdb)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/raft_driver",
"args": ["${file}"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/tests/raft_scenarios/",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
7 changes: 6 additions & 1 deletion src/consensus/aft/test/logging_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,21 @@ namespace aft
{
auto configuration = consensus->get_latest_configuration_unsafe();
std::unordered_set<ccf::NodeId> retired_nodes;
std::list<Configuration::Nodes::const_iterator> itrs;

// Remove and track retired nodes
for (auto it = configuration.begin(); it != configuration.end(); ++it)
{
if (new_configuration.find(it->first) == new_configuration.end())
{
retired_nodes.emplace(it->first);
it = configuration.erase(it);
itrs.push_back(it);
}
}
for (auto it : itrs)
{
configuration.erase(it);
}

// Add new node to configuration
for (const auto& [node_id, _] : new_configuration)
Expand Down

0 comments on commit ff0d8c6

Please sign in to comment.