aliasmgr

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// StartingAlias is the first alias ShortChannelID that will get
	// assigned by RequestAlias. The starting BlockHeight is chosen so that
	// legitimate SCIDs in integration tests aren't mistaken for an alias.
	StartingAlias = lnwire.ShortChannelID{
		BlockHeight: uint32(startingBlockHeight),
		TxIndex:     0,
		TxPosition:  0,
	}
)

Functions

func IsAlias

func IsAlias(scid lnwire.ShortChannelID) bool

IsAlias returns true if the passed SCID is an alias. The function determines this by looking at the BlockHeight. If the BlockHeight is greater than startingBlockHeight and less than endBlockHeight, then it is an alias assigned by RequestAlias. These bounds only apply to aliases we generate. Our peers are free to use any range they choose.

Types

type Manager

type Manager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Manager is a struct that handles aliases for LND. It has an underlying database that can allocate aliases for channels, stores the peer's last alias for use in our hop hints, and contains mappings that both the Switch and Gossiper use.

func NewManager

func NewManager(db kvdb.Backend) (*Manager, error)

NewManager initializes an alias Manager from the passed database backend.

func (*Manager) AddLocalAlias

func (m *Manager) AddLocalAlias(alias, baseScid lnwire.ShortChannelID,
	gossip bool) error

AddLocalAlias adds a database mapping from the passed alias to the passed base SCID. The gossip boolean marks whether or not to create a mapping that the gossiper will use. It is set to false for the upgrade path where the feature-bit is toggled on and there are existing channels.

func (*Manager) DeleteSixConfs

func (m *Manager) DeleteSixConfs(baseScid lnwire.ShortChannelID) error

DeleteSixConfs removes a mapping for the gossiper once six confirmations have been reached and the channel is public. At this point, only the confirmed SCID should be used.

func (*Manager) FindBaseSCID

func (m *Manager) FindBaseSCID(
	alias lnwire.ShortChannelID) (lnwire.ShortChannelID, error)

FindBaseSCID finds the base SCID for a given alias. This is used in the gossiper to find the correct SCID to lookup in the graph database.

func (*Manager) GetAliases

func (m *Manager) GetAliases(
	base lnwire.ShortChannelID) []lnwire.ShortChannelID

GetAliases fetches the set of aliases stored under a given base SCID from write-through caches.

func (*Manager) GetPeerAlias

func (m *Manager) GetPeerAlias(chanID lnwire.ChannelID) (lnwire.ShortChannelID,
	error)

GetPeerAlias retrieves a peer's alias SCID by the channel's ChanID.

func (*Manager) ListAliases

func (m *Manager) ListAliases() map[lnwire.ShortChannelID][]lnwire.ShortChannelID

ListAliases returns a carbon copy of baseToSet. This is used by the rpc layer.

func (*Manager) PutPeerAlias

func (m *Manager) PutPeerAlias(chanID lnwire.ChannelID,
	alias lnwire.ShortChannelID) error

PutPeerAlias stores the peer's alias SCID once we learn of it in the channel_ready message.

func (*Manager) RequestAlias

func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error)

RequestAlias returns a new ALIAS ShortChannelID to the caller by allocating the next un-allocated ShortChannelID. The starting ShortChannelID is 16000000:0:0 and the ending ShortChannelID is 16250000:16777215:65535. This gives roughly 2^58 possible ALIAS ShortChannelIDs which ensures this space won't get exhausted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL