mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-27 23:38:08 +00:00
The two functions were near duplicates: walk to the key, then look for the nearest leaf on one side. Only the scan direction, the comparison deciding a leaf qualifies, and whether to take the first or last leaf below the subtree differed, exactly the distinction `BelowDirection` already draws for `belowHelper`, so the pair collapse into one parameterized walk. Also drops the stale `// TODO: what to return here?` above `lowerBound`'s `return end()`: no predecessor is the correct answer for the smallest key, and the tests pin it. Adds the two map shapes the existing tests never built. Every test map held at least three items, so the root was always an inner node with a populated branch on either side of a probe. An empty map exercises the childless root, where the scan finds nothing on any branch and the walk falls through to `end()`. A single-item map exercises a leaf directly under the root, where that one leaf decides the outcome. The single-item test's comment records why `root_` is an inner node even there: a map built through `addItem` keeps the root it was constructed with, and only a single-item map synced from a peer (`addRootNode`) replaces `root_` with a leaf directly. The comment also notes that the leaf entry settles a probe only when the leaf qualifies against it; for every other probe the leaf is popped and `root_`'s own inner-node scan is what reaches `end()`.