From d5f97f7bdc8d947d3e6c8163edb8ecc9685bd8eb Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 4 Sep 2018 01:55:05 -0700 Subject: [PATCH] autopilot/multi: replace PubKey -> NodeKey on directive --- autopilot/agent_test.go | 10 +++++----- autopilot/interface.go | 4 ++-- autopilot/prefattach.go | 2 +- autopilot/prefattach_test.go | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/autopilot/agent_test.go b/autopilot/agent_test.go index 61f0ded8..16099eeb 100644 --- a/autopilot/agent_test.go +++ b/autopilot/agent_test.go @@ -321,7 +321,7 @@ func TestAgentChannelFailureSignal(t *testing.T) { // request attachment directives, return a fake so the agent will // attempt to open a channel. var fakeDirective = AttachmentDirective{ - PeerKey: self, + NodeKey: self, NodeID: NewNodeID(self), ChanAmt: btcutil.SatoshiPerBitcoin, Addrs: []net.Addr{ @@ -659,7 +659,7 @@ func TestAgentImmediateAttach(t *testing.T) { } nodeID := NewNodeID(pub) directives[i] = AttachmentDirective{ - PeerKey: pub, + NodeKey: pub, NodeID: nodeID, ChanAmt: btcutil.SatoshiPerBitcoin, Addrs: []net.Addr{ @@ -790,7 +790,7 @@ func TestAgentPrivateChannels(t *testing.T) { t.Fatalf("unable to generate key: %v", err) } directives[i] = AttachmentDirective{ - PeerKey: pub, + NodeKey: pub, NodeID: NewNodeID(pub), ChanAmt: btcutil.SatoshiPerBitcoin, Addrs: []net.Addr{ @@ -911,7 +911,7 @@ func TestAgentPendingChannelState(t *testing.T) { } nodeID := NewNodeID(nodeKey) nodeDirective := AttachmentDirective{ - PeerKey: nodeKey, + NodeKey: nodeKey, NodeID: nodeID, ChanAmt: 0.5 * btcutil.SatoshiPerBitcoin, Addrs: []net.Addr{ @@ -1273,7 +1273,7 @@ func TestAgentSkipPendingConns(t *testing.T) { t.Fatalf("unable to generate key: %v", err) } nodeDirective := AttachmentDirective{ - PeerKey: nodeKey, + NodeKey: nodeKey, NodeID: NewNodeID(nodeKey), ChanAmt: 0.5 * btcutil.SatoshiPerBitcoin, Addrs: []net.Addr{ diff --git a/autopilot/interface.go b/autopilot/interface.go index 2b7155fe..efa99298 100644 --- a/autopilot/interface.go +++ b/autopilot/interface.go @@ -85,10 +85,10 @@ type ChannelGraph interface { // AttachmentHeuristic. It details to which node a channel should be created // to, and also the parameters which should be used in the channel creation. type AttachmentDirective struct { - // PeerKey is the target node for this attachment directive. It can be + // NodeKey is the target node for this attachment directive. It can be // identified by its public key, and therefore can be used along with // a ChannelOpener implementation to execute the directive. - PeerKey *btcec.PublicKey + NodeKey *btcec.PublicKey // NodeID is the serialized compressed pubkey of the target node. NodeID NodeID diff --git a/autopilot/prefattach.go b/autopilot/prefattach.go index 4bf00c25..22362b7a 100644 --- a/autopilot/prefattach.go +++ b/autopilot/prefattach.go @@ -245,7 +245,7 @@ func (p *ConstrainedPrefAttachment) Select(self *btcec.PublicKey, g ChannelGraph } directives = append(directives, AttachmentDirective{ // TODO(roasbeef): need curve? - PeerKey: &btcec.PublicKey{ + NodeKey: &btcec.PublicKey{ X: pub.X, Y: pub.Y, }, diff --git a/autopilot/prefattach_test.go b/autopilot/prefattach_test.go index b05bdd52..d3440277 100644 --- a/autopilot/prefattach_test.go +++ b/autopilot/prefattach_test.go @@ -349,11 +349,11 @@ func TestConstrainedPrefAttachmentSelectTwoVertexes(t *testing.T) { edge2Pub := edge2.Peer.PubKey() switch { - case bytes.Equal(directive.PeerKey.SerializeCompressed(), edge1Pub[:]): - case bytes.Equal(directive.PeerKey.SerializeCompressed(), edge2Pub[:]): + case bytes.Equal(directive.NodeKey.SerializeCompressed(), edge1Pub[:]): + case bytes.Equal(directive.NodeKey.SerializeCompressed(), edge2Pub[:]): default: t1.Fatalf("attached to unknown node: %x", - directive.PeerKey.SerializeCompressed()) + directive.NodeKey.SerializeCompressed()) } // As the number of funds available exceed the @@ -634,8 +634,8 @@ func TestConstrainedPrefAttachmentSelectSkipNodes(t *testing.T) { // We'll simulate a channel update by adding the nodes // we just establish channel with the to set of nodes // to be skipped. - skipNodes[NewNodeID(directives[0].PeerKey)] = struct{}{} - skipNodes[NewNodeID(directives[1].PeerKey)] = struct{}{} + skipNodes[NewNodeID(directives[0].NodeKey)] = struct{}{} + skipNodes[NewNodeID(directives[1].NodeKey)] = struct{}{} // If we attempt to make a call to the Select function, // without providing any new information, then we