discovery: update initial graph synchronization to recent API changes

This commit is contained in:
Olaoluwa Osuntokun 2017-08-21 23:41:19 -07:00
parent 812c2f1ce6
commit 862af6f2d4
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -720,13 +720,22 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(nMsg *networkMsg) []l
// With the proof validate (if necessary), we can now store it // With the proof validate (if necessary), we can now store it
// within the database for our path finding and syncing needs. // within the database for our path finding and syncing needs.
var featureBuf bytes.Buffer
if err := msg.Features.Encode(&featureBuf); err != nil {
log.Error("unable to encode features: %v", err)
nMsg.err <- err
return nil
}
edge := &channeldb.ChannelEdgeInfo{ edge := &channeldb.ChannelEdgeInfo{
ChannelID: msg.ShortChannelID.ToUint64(), ChannelID: msg.ShortChannelID.ToUint64(),
ChainHash: msg.ChainHash,
NodeKey1: msg.NodeID1, NodeKey1: msg.NodeID1,
NodeKey2: msg.NodeID2, NodeKey2: msg.NodeID2,
BitcoinKey1: msg.BitcoinKey1, BitcoinKey1: msg.BitcoinKey1,
BitcoinKey2: msg.BitcoinKey2, BitcoinKey2: msg.BitcoinKey2,
AuthProof: proof, AuthProof: proof,
Features: featureBuf.Bytes(),
} }
// We will add the edge to the channel router. If the nodes // We will add the edge to the channel router. If the nodes
@ -1131,12 +1140,17 @@ func (d *AuthenticatedGossiper) synchronizeWithNode(syncReq *syncRequest) error
if !node.HaveNodeAnnouncement { if !node.HaveNodeAnnouncement {
return nil return nil
} }
alias, err := lnwire.NewNodeAlias(node.Alias)
if err != nil {
return err
}
ann := &lnwire.NodeAnnouncement{ ann := &lnwire.NodeAnnouncement{
Signature: node.AuthSig, Signature: node.AuthSig,
Timestamp: uint32(node.LastUpdate.Unix()), Timestamp: uint32(node.LastUpdate.Unix()),
Addresses: node.Addresses, Addresses: node.Addresses,
NodeID: node.PubKey, NodeID: node.PubKey,
Alias: lnwire.NewAlias(node.Alias), Alias: alias,
Features: node.Features, Features: node.Features,
} }
announceMessages = append(announceMessages, ann) announceMessages = append(announceMessages, ann)