The seeded software is doing statistics on tested nodes before any node get tested.
This diff addresses the issue by ensuring that the list of tested node is not empty before statistics are built on top.
Implementation details:
This bug has been revealed by running the seeder on OSX.
The CAddrDb::GetStats() method can access internal dequeue and map
members by index despite their size is zero, causing a segfault.
This diff fixes it by:
- Testing the size of the list of tested nodes to be > 0 before accessing, ensuring data exists before building the stats.
- Using at() for accessing instead of []. This function checks for out-of-bounds accesses and will throw an exception instead of a segfault, making the debugging much easier. It also avoids adding inadvertently an entry in the map (this is also enforced by making the method const).