mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 17:47:01 +02:00
watchtower: start using the new channel max heights
This commit also adds tests for the DB changes made in the previous commit since we can now read the new field with the FetchChanInfos method. The commit following this one does the backfill migration.
This commit is contained in:
@@ -3,11 +3,29 @@ package wtdb
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
// ChannelSummaries is a map for a given channel id to it's ClientChanSummary.
|
||||
type ChannelSummaries map[lnwire.ChannelID]ClientChanSummary
|
||||
// ChannelInfos is a map for a given channel id to it's ChannelInfo.
|
||||
type ChannelInfos map[lnwire.ChannelID]*ChannelInfo
|
||||
|
||||
// ChannelInfo contains various useful things about a registered channel.
|
||||
//
|
||||
// NOTE: the reason for adding this struct which wraps ClientChanSummary
|
||||
// instead of extending ClientChanSummary is for faster look-up of added fields.
|
||||
// If we were to extend ClientChanSummary instead then we would need to decode
|
||||
// the entire struct each time we want to read the new fields and then re-encode
|
||||
// the struct each time we want to write to a new field.
|
||||
type ChannelInfo struct {
|
||||
ClientChanSummary
|
||||
|
||||
// MaxHeight is the highest commitment height that the tower has been
|
||||
// handed for this channel. An Option type is used to store this since
|
||||
// a commitment height of zero is valid, and we need a way of knowing if
|
||||
// we have seen a new height yet or not.
|
||||
MaxHeight fn.Option[uint64]
|
||||
}
|
||||
|
||||
// ClientChanSummary tracks channel-specific information. A new
|
||||
// ClientChanSummary is inserted in the database the first time the client
|
||||
|
Reference in New Issue
Block a user