Page MenuHomePhabricator

[avalanche] Add dump and load functions to save/load the avalanche peers to/from a file
ClosedPublic

Authored by Fabien on Nov 21 2023, 13:42.

Details

Summary

This diff adds a couple function to save and load peers to/from a file. This will make it possible to dump during shutdown and load upon startup, similar to what is done for the mempool. This is a step toward a faster bootstrap time when starting an avalanche node, especially to make the staking reward decision faster upon restart.

Test Plan
ninja check-avalanche-peermanager_tests

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Nov 21 2023, 13:42
PiRK added inline comments.
src/avalanche/peermanager.cpp
1138 ↗(On Diff #43190)

What is the benefit of saving the peerid? I see that it is not used in the load function, and this is expected to be assigned automatically based on the order the peers are loaded in.

Fabien planned changes to this revision.Nov 21 2023, 14:40
Fabien added inline comments.
src/avalanche/peermanager.cpp
1138 ↗(On Diff #43190)

This is just a way to dump all the peer set. It can be read from another tool to compare with the debug log if needed.
On second thought it's not very useful, I will remove it.

Remove the unused peerid from the file

This revision is now accepted and ready to land.Nov 21 2023, 14:53