models: create a helper to convert wire NodeAnn to models.LNNode type
And use it in the gossiper. This helps ensure that we do this conversion consistently.
This commit is contained in:
2 files changed
+20
-15
No files matched your search
+1
-15
@@ -1982,21 +1982,7 @@ func (d *AuthenticatedGossiper) addNode(msg *lnwire.NodeAnnouncement,
|
|||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp := time.Unix(int64(msg.Timestamp), 0)
|
return d.cfg.Graph.AddNode(models.NodeFromWireAnnouncement(msg), op...)
|
||||||
features := lnwire.NewFeatureVector(msg.Features, lnwire.Features)
|
|
||||||
node := &models.LightningNode{
|
|
||||||
HaveNodeAnnouncement: true,
|
|
||||||
LastUpdate: timestamp,
|
|
||||||
Addresses: msg.Addresses,
|
|
||||||
PubKeyBytes: msg.NodeID,
|
|
||||||
Alias: msg.Alias.String(),
|
|
||||||
AuthSigBytes: msg.Signature.ToSignatureBytes(),
|
|
||||||
Features: features,
|
|
||||||
Color: msg.RGBColor,
|
|
||||||
ExtraOpaqueData: msg.ExtraOpaqueData,
|
|
||||||
}
|
|
||||||
|
|
||||||
return d.cfg.Graph.AddNode(node, op...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// isPremature decides whether a given network message has a block height+delta
|
// isPremature decides whether a given network message has a block height+delta
|
||||||
|
|||||||
@@ -131,3 +131,22 @@ func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
|
|||||||
|
|
||||||
return nodeAnn, nil
|
return nodeAnn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NodeFromWireAnnouncement creates a LightningNode instance from an
|
||||||
|
// lnwire.NodeAnnouncement message.
|
||||||
|
func NodeFromWireAnnouncement(msg *lnwire.NodeAnnouncement) *LightningNode {
|
||||||
|
timestamp := time.Unix(int64(msg.Timestamp), 0)
|
||||||
|
features := lnwire.NewFeatureVector(msg.Features, lnwire.Features)
|
||||||
|
|
||||||
|
return &LightningNode{
|
||||||
|
HaveNodeAnnouncement: true,
|
||||||
|
LastUpdate: timestamp,
|
||||||
|
Addresses: msg.Addresses,
|
||||||
|
PubKeyBytes: msg.NodeID,
|
||||||
|
Alias: msg.Alias.String(),
|
||||||
|
AuthSigBytes: msg.Signature.ToSignatureBytes(),
|
||||||
|
Features: features,
|
||||||
|
Color: msg.RGBColor,
|
||||||
|
ExtraOpaqueData: msg.ExtraOpaqueData,
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user