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>
Thu, 21 Dec 2023 05:50:49 +0000 (05:50 +0000)
commit7da08a77ba5b6d4bfb3c09b885703518966c00de
treea5a383d9009d963a95ede673b15b5e80185206dc
parent87170e9f452774a297ee82d1ff3334af22bfefd8
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