autopilot/interface+agent: remove NodeKey from AttachmentDirective

Instead parse the pubkey bytes only when needed.
This commit is contained in:
Johan T. Halseth committed 2018-12-06 14:26:05 +01:00
1 parent 89c3c5319f
commit 5ecc209c41
5 files changed
+18 -28

No files matched your search

+3 -11
View File
@@ -197,23 +197,15 @@ func (p *ConstrainedPrefAttachment) Select(self *btcec.PublicKey, g ChannelGraph
// With the node selected, we'll add this (node, amount) tuple
// to out set of recommended directives.
pubBytes := selectedNode.PubKey()
pub, err := btcec.ParsePubKey(pubBytes[:], btcec.S256())
if err != nil {
return nil, err
}
nID := NodeID(pubBytes)
directives = append(directives, AttachmentDirective{
// TODO(roasbeef): need curve?
NodeKey: &btcec.PublicKey{
X: pub.X,
Y: pub.Y,
},
NodeID: NewNodeID(pub),
NodeID: nID,
Addrs: selectedNode.Addrs(),
})
// With the node selected, we'll add it to the set of visited
// nodes to avoid attaching to it again.
visited[NodeID(pubBytes)] = struct{}{}
visited[nID] = struct{}{}
}
numSelectedNodes := int64(len(directives))