mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-31 08:02:25 +02:00
refactor+multi: use *lnwire.FeatureVector for ChannelEdgeInfo features
In this commit, we move the serialisation details of a channel's features to the DB layer and change the `models` field to instead use a more useful `*lnwire.FeatureVector` type. This makes the features easier to work with and moves the serialisation to where it is actually used.
This commit is contained in:
@@ -305,13 +305,6 @@ func (r *Manager) createEdge(channel *channeldb.OpenChannel,
|
||||
channelFlags = 1
|
||||
}
|
||||
|
||||
var featureBuf bytes.Buffer
|
||||
err := lnwire.NewRawFeatureVector().Encode(&featureBuf)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("unable to encode features: %w",
|
||||
err)
|
||||
}
|
||||
|
||||
// We need to make sure we use the real scid for public confirmed
|
||||
// zero-conf channels.
|
||||
shortChanID := channel.ShortChanID()
|
||||
@@ -323,7 +316,7 @@ func (r *Manager) createEdge(channel *channeldb.OpenChannel,
|
||||
info := &models.ChannelEdgeInfo{
|
||||
ChannelID: shortChanID.ToUint64(),
|
||||
ChainHash: channel.ChainHash,
|
||||
Features: featureBuf.Bytes(),
|
||||
Features: lnwire.EmptyFeatureVector(),
|
||||
Capacity: channel.Capacity,
|
||||
ChannelPoint: channel.FundingOutpoint,
|
||||
}
|
||||
|
@@ -387,7 +387,7 @@ func TestCreateEdgeLower(t *testing.T) {
|
||||
expectedInfo := &models.ChannelEdgeInfo{
|
||||
ChannelID: 8,
|
||||
ChainHash: channel.ChainHash,
|
||||
Features: []byte{0, 0},
|
||||
Features: lnwire.EmptyFeatureVector(),
|
||||
Capacity: 9,
|
||||
ChannelPoint: channel.FundingOutpoint,
|
||||
NodeKey1Bytes: sp,
|
||||
@@ -475,7 +475,7 @@ func TestCreateEdgeHigher(t *testing.T) {
|
||||
expectedInfo := &models.ChannelEdgeInfo{
|
||||
ChannelID: 8,
|
||||
ChainHash: channel.ChainHash,
|
||||
Features: []byte{0, 0},
|
||||
Features: lnwire.EmptyFeatureVector(),
|
||||
Capacity: 9,
|
||||
ChannelPoint: channel.FundingOutpoint,
|
||||
NodeKey1Bytes: rp,
|
||||
|
Reference in New Issue
Block a user