mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
15b871de36
This introduces the a store for managing all things alias-related. There are two maps: * baseToSet: This stores the "base" short channel id as the key. The value is the set of all aliases issued for this channel. The "base" SCID is whatever is stored in the OpenChannel's ShortChannelID member. For everything other than zero-conf channels, this is the confirmed SCID. For zero-conf channels, this is the very first alias assigned. This is used mostly by the Switch to retrieve a set of aliases and determine if it is safe to forward. * aliasToBase: This stores the reverse mapping of baseToSet. Each key is an alias SCID and the value is the "base" SCID. This is exclusively used by the gossiper to determine if an alias in a ChannelUpdate our peer sends actually references a channel we know of. The functions make use of the above two maps: * AddLocalAlias: This persists the {alias, base} pair in the database. The baseToSet map is populated. The aliasToBase is optionally populated depending on where this function is called from. Upgrade cases, where the scid-alias feature bit is toggled and channels already exist, will not persist to the gossip map. This is mainly to simplify the tangle of logic that would otherwise occur. * GetAliases: This fetches the set of aliases by using the passed-in base SCID. This is used in the Switch and other places where the alias set is needed. * FindBaseSCID: This fetches the base given an alias. This is used in the gossiper to determine validity of a peer's ChannelUpdate that contains an alias. * DeleteSixConfs: This removes the aliasToBase map entry for the given "base". This is used when the gossiper mappings are no longer needed, i.e. when the channel has six confirmations and is public. * PutPeerAlias: Stores the peer's alias. * GetPeerAlias: Fetches the peer's alias. * RequestAlias: Generates an alias for us in the range 16000000:0:0 and 16250000:16777215:65535 |
||
---|---|---|
.. | ||
aliasmgr_test.go | ||
aliasmgr.go |