mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-29 18:10:48 +02:00
watchtower: make better use of getChanSummary
Small refactor just to make the upcoming commit easier to parse. In this commit, we make better use of the getChanSummary helper function.
This commit is contained in:
@ -893,13 +893,12 @@ func (c *ClientDB) FetchChanSummaries() (ChannelSummaries, error) {
|
|||||||
var chanID lnwire.ChannelID
|
var chanID lnwire.ChannelID
|
||||||
copy(chanID[:], k)
|
copy(chanID[:], k)
|
||||||
|
|
||||||
var summary ClientChanSummary
|
summary, err := getChanSummary(chanSummaries, chanID)
|
||||||
err := summary.Decode(bytes.NewReader(v))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
summaries[chanID] = summary
|
summaries[chanID] = *summary
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -927,19 +926,10 @@ func (c *ClientDB) RegisterChannel(chanID lnwire.ChannelID,
|
|||||||
return ErrUninitializedDB
|
return ErrUninitializedDB
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := getChanSummary(chanSummaries, chanID)
|
chanSummaryBytes := chanSummaries.Get(chanID[:])
|
||||||
switch {
|
if chanSummaryBytes != nil {
|
||||||
|
// Channel is already registered.
|
||||||
// Summary already exists.
|
|
||||||
case err == nil:
|
|
||||||
return ErrChannelAlreadyRegistered
|
return ErrChannelAlreadyRegistered
|
||||||
|
|
||||||
// Channel is not registered, proceed with registration.
|
|
||||||
case err == ErrChannelNotRegistered:
|
|
||||||
|
|
||||||
// Unexpected error.
|
|
||||||
default:
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
summary := ClientChanSummary{
|
summary := ClientChanSummary{
|
||||||
|
Reference in New Issue
Block a user