Closed mvandeberg closed 3 years ago
The algorithm implemented in this PR only deletes blocks of height lower than LIB.
The architectural intent is that TopologyCache
holds unverified claims of peers' topology, while MyTopologyCache
holds the topology that has been accepted by the local node.
By definition the local node cannot accept orphaned forks, that is, blocks whose history branched at any point older than LIB. When advancing the topology cache, MyTopologyCache
should prune all blocks on an orphaned fork.
For an example of this situation, suppose our head is 100, our LIB is 90, and there were two forked blocks 91, let us call them 91a and 91b. We have five blocks on the b fork, 91b...95b, as well as 91a...100a on the main fork. Then we receive block 101a, which advances LIB to 92a. The current code discards only 90, 91a and 91b. That is, the code implements only the first of these three rules:
Closes #115