Drop the `dist` `HashMap` in routing, replacing it with a `Vec`.
authorMatt Corallo <git@bluematt.me>
Thu, 7 Dec 2023 20:59:02 +0000 (20:59 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 10 Dec 2023 03:31:44 +0000 (03:31 +0000)
commitdf45cd5165630731ace4bb887fc92814da5766b3
tree56aff903ca0b55e8229a02cff5ee807f7bdbe1c7
parent27fd46c940b9046273d98d7f47f9e705e2ab5c08
Drop the `dist` `HashMap` in routing, replacing it with a `Vec`.

Now that we have unique, dense, 32-bit identifiers for all the
nodes in our network graph, we can store the per-node information
when routing in a simple `Vec` rather than a `HashMap`. This avoids
the overhead of hashing and table scanning entirely, for a nice
"simple" optimization win.

Because we must ensure we have a 1-to-1 mapping from node ids to
`node_counter`s, even across first-hop and last-hop hints, we have
to be careful to check the network graph first, then a new
`private_node_id_to_node_counter` map to ensure we only ever end up
with one counter per node id.
lightning/src/routing/gossip.rs
lightning/src/routing/router.rs
lightning/src/util/test_utils.rs