htlcswitch: add a ShortChanID method to the ChannelLink interface

This commit is contained in:
Olaoluwa Osuntokun 2017-06-16 23:32:41 +02:00
parent 058e641d7e
commit ea57a94c2e
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 25 additions and 10 deletions

View File

@ -17,13 +17,13 @@ type InvoiceDatabase interface {
// byte payment hash. // byte payment hash.
LookupInvoice(chainhash.Hash) (*channeldb.Invoice, error) LookupInvoice(chainhash.Hash) (*channeldb.Invoice, error)
// SettleInvoice attempts to mark an invoice corresponding to the passed // SettleInvoice attempts to mark an invoice corresponding to the
// payment hash as fully settled. // passed payment hash as fully settled.
SettleInvoice(chainhash.Hash) error SettleInvoice(chainhash.Hash) error
} }
// ChannelLink is an interface which represents the subsystem for managing // ChannelLink is an interface which represents the subsystem for managing the
// the incoming htlc requests, applying the changes to the channel, and also // incoming htlc requests, applying the changes to the channel, and also
// propagating/forwarding it to htlc switch. // propagating/forwarding it to htlc switch.
// //
// abstraction level // abstraction level
@ -51,9 +51,14 @@ type ChannelLink interface {
// which sent to us from remote peer we have a channel with. // which sent to us from remote peer we have a channel with.
HandleChannelUpdate(lnwire.Message) 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 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 // Bandwidth returns the amount of satoshis which current link might
// pass through channel link. // pass through channel link.
Bandwidth() btcutil.Amount Bandwidth() btcutil.Amount
@ -62,12 +67,12 @@ type ChannelLink interface {
// total sent/received satoshis. // total sent/received satoshis.
Stats() (uint64, btcutil.Amount, btcutil.Amount) Stats() (uint64, btcutil.Amount, btcutil.Amount)
// Peer returns the representation of remote peer with which we // Peer returns the representation of remote peer with which we have
// have the channel link opened. // the channel link opened.
Peer() Peer Peer() Peer
// Start/Stop are used to initiate the start/stop of the the channel // Start/Stop are used to initiate the start/stop of the channel link
// link functioning. // functioning.
Start() error Start() error
Stop() Stop()
} }

View File

@ -666,7 +666,17 @@ func (l *channelLink) Peer() Peer {
return l.cfg.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. // NOTE: Part of the ChannelLink interface.
func (l *channelLink) ChanID() lnwire.ChannelID { func (l *channelLink) ChanID() lnwire.ChannelID {