mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
autopilot: update the Node interface to return a raw bytes, not the key
In this commit, we modify the Node interface to return a set of raw bytes, rather than the full pubkey struct. We do this as within the package, commonly we only require the pubkey bytes for fingerprinting purposes. Before this commit, we were forced to _always_ decompress the pubkey which can be expensive done thousands of times a second.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package autopilot
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -344,11 +345,14 @@ func TestConstrainedPrefAttachmentSelectTwoVertexes(t *testing.T) {
|
||||
// The node attached to should be amongst the two edges
|
||||
// created above.
|
||||
for _, directive := range directives {
|
||||
edge1Pub := edge1.Peer.PubKey()
|
||||
edge2Pub := edge2.Peer.PubKey()
|
||||
|
||||
switch {
|
||||
case directive.PeerKey.IsEqual(edge1.Peer.PubKey()):
|
||||
case directive.PeerKey.IsEqual(edge2.Peer.PubKey()):
|
||||
case bytes.Equal(directive.PeerKey.SerializeCompressed(), edge1Pub[:]):
|
||||
case bytes.Equal(directive.PeerKey.SerializeCompressed(), edge2Pub[:]):
|
||||
default:
|
||||
t1.Fatalf("attache to unknown node: %x",
|
||||
t1.Fatalf("attached to unknown node: %x",
|
||||
directive.PeerKey.SerializeCompressed())
|
||||
}
|
||||
|
||||
@@ -472,8 +476,15 @@ func TestConstrainedPrefAttachmentSelectGreedyAllocation(t *testing.T) {
|
||||
if err != nil {
|
||||
t1.Fatalf("unable to create channel: %v", err)
|
||||
}
|
||||
peerPubBytes := edge1.Peer.PubKey()
|
||||
peerPub, err := btcec.ParsePubKey(
|
||||
peerPubBytes[:], btcec.S256(),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse pubkey: %v", err)
|
||||
}
|
||||
_, _, err = graph.addRandChannel(
|
||||
edge1.Peer.PubKey(), nil, chanCapacity,
|
||||
peerPub, nil, chanCapacity,
|
||||
)
|
||||
if err != nil {
|
||||
t1.Fatalf("unable to create channel: %v", err)
|
||||
|
Reference in New Issue
Block a user