From ea57a94c2e3ca703c3326a8c6be59081599cf314 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 16 Jun 2017 23:32:41 +0200 Subject: [PATCH] htlcswitch: add a ShortChanID method to the ChannelLink interface --- htlcswitch/interfaces.go | 23 ++++++++++++++--------- htlcswitch/link.go | 12 +++++++++++- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/htlcswitch/interfaces.go b/htlcswitch/interfaces.go index 57328d03..b32291d4 100644 --- a/htlcswitch/interfaces.go +++ b/htlcswitch/interfaces.go @@ -17,13 +17,13 @@ type InvoiceDatabase interface { // byte payment hash. LookupInvoice(chainhash.Hash) (*channeldb.Invoice, error) - // SettleInvoice attempts to mark an invoice corresponding to the passed - // payment hash as fully settled. + // SettleInvoice attempts to mark an invoice corresponding to the + // passed payment hash as fully settled. SettleInvoice(chainhash.Hash) error } -// ChannelLink is an interface which represents the subsystem for managing -// the incoming htlc requests, applying the changes to the channel, and also +// ChannelLink is an interface which represents the subsystem for managing the +// incoming htlc requests, applying the changes to the channel, and also // propagating/forwarding it to htlc switch. // // abstraction level @@ -51,9 +51,14 @@ type ChannelLink interface { // which sent to us from remote peer we have a channel with. HandleChannelUpdate(lnwire.Message) - // ChanID returns the unique identifier of the channel link. + // ChanID returns the channel ID for the channel link. The channel ID + // is a more compact representation of a channel's full outpoint. ChanID() lnwire.ChannelID + // ShortChanID returns the short channel ID for the channel link. The + // short channel ID encodes the exact location in the main chain that + // the original funding output can be found. + ShortChanID() lnwire.ShortChannelID // Bandwidth returns the amount of satoshis which current link might // pass through channel link. Bandwidth() btcutil.Amount @@ -62,12 +67,12 @@ type ChannelLink interface { // total sent/received satoshis. Stats() (uint64, btcutil.Amount, btcutil.Amount) - // Peer returns the representation of remote peer with which we - // have the channel link opened. + // Peer returns the representation of remote peer with which we have + // the channel link opened. Peer() Peer - // Start/Stop are used to initiate the start/stop of the the channel - // link functioning. + // Start/Stop are used to initiate the start/stop of the channel link + // functioning. Start() error Stop() } diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 2287914d..4e0117a7 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -666,7 +666,17 @@ func (l *channelLink) Peer() Peer { return l.cfg.Peer } -// ChannelPoint returns the unique identificator of the channel link. +// ShortChanID returns the short channel ID for the channel link. The short +// channel ID encodes the exact location in the main chain that the original +// funding output can be found. +// +// NOTE: Part of the ChannelLink interface. +func (l *channelLink) ShortChanID() lnwire.ShortChannelID { + return l.channel.ShortChanID() +} + +// ChanID returns the channel ID for the channel link. The channel ID is a more +// compact representation of a channel's full outpoint. // // NOTE: Part of the ChannelLink interface. func (l *channelLink) ChanID() lnwire.ChannelID {