graph/db: add v2 fields to ChannelEdgePolicy model
Extend ChannelEdgePolicy to support v2 channel updates by adding: - Version field to track gossip protocol version (v1 or v2). - LastBlockHeight for v2's block-height-based timestamps. - SecondPeer flag to indicate which peer announced the policy in v2. - DisableFlags for v2-specific channel disable signaling. - ExtraSignedFields map for v2 extra signed TLV data. Add version-aware methods: - IsNode1() determines if the policy was announced by node_1, handling both v1 (via ChannelFlags direction bit) and v2 (via SecondPeer). - IsDisabled() checks disable status using ChannelFlags for v1 and DisableFlags for v2. - String() provides version-appropriate string representations. The new fields use zero values for v1 compatibility (Version defaults to GossipVersion1, LastBlockHeight to 0, SecondPeer to false). This lays the groundwork for v2 policy support; a subsequent commit will handle reading and writing these fields from/to the database.
This commit is contained in:
15 files changed
+105
-6
No files matched your search
@@ -2751,6 +2751,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
// We must add the edge policy to be able to use the edge for route
|
||||
// finding.
|
||||
edgePolicy := &models.ChannelEdgePolicy{
|
||||
Version: lnwire.GossipVersion1,
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: testTime,
|
||||
@@ -2766,6 +2767,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
|
||||
// Create edge in the other direction as well.
|
||||
edgePolicy = &models.ChannelEdgePolicy{
|
||||
Version: lnwire.GossipVersion1,
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: testTime,
|
||||
@@ -2832,6 +2834,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
require.NoError(t, ctx.graph.AddChannelEdge(ctxb, edge))
|
||||
|
||||
edgePolicy = &models.ChannelEdgePolicy{
|
||||
Version: lnwire.GossipVersion1,
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: testTime,
|
||||
@@ -2846,6 +2849,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
require.NoError(t, ctx.graph.UpdateEdgePolicy(ctxb, edgePolicy))
|
||||
|
||||
edgePolicy = &models.ChannelEdgePolicy{
|
||||
Version: lnwire.GossipVersion1,
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: testTime,
|
||||
@@ -2965,6 +2969,7 @@ func (m *mockGraphBuilder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
|
||||
}
|
||||
|
||||
err := m.updateEdge(&models.ChannelEdgePolicy{
|
||||
Version: msg.GossipVersion(),
|
||||
SigBytes: msg.Signature.ToSignatureBytes(),
|
||||
ChannelID: msg.ShortChannelID.ToUint64(),
|
||||
LastUpdate: time.Unix(int64(msg.Timestamp), 0),
|
||||
|
||||
Reference in new issue
Block a user