Merge pull request #3858 from bhandras/betweenness_centrality

autopilot: fix memChannelGraph channel edge addition
This commit is contained in:
Conner Fromknecht 2019-12-19 22:52:40 -08:00 committed by GitHub
commit f6172fb83a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -307,7 +307,7 @@ func (d *databaseChannelGraph) addRandNode() (*btcec.PublicKey, error) {
// memChannelGraph is an implementation of the autopilot.ChannelGraph backed by // memChannelGraph is an implementation of the autopilot.ChannelGraph backed by
// an in-memory graph. // an in-memory graph.
type memChannelGraph struct { type memChannelGraph struct {
graph map[NodeID]memNode graph map[NodeID]*memNode
} }
// A compile time assertion to ensure memChannelGraph meets the // A compile time assertion to ensure memChannelGraph meets the
@ -318,7 +318,7 @@ var _ ChannelGraph = (*memChannelGraph)(nil)
// implementation. // implementation.
func newMemChannelGraph() *memChannelGraph { func newMemChannelGraph() *memChannelGraph {
return &memChannelGraph{ return &memChannelGraph{
graph: make(map[NodeID]memNode), graph: make(map[NodeID]*memNode),
} }
} }
@ -360,14 +360,14 @@ func (m *memChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,
capacity btcutil.Amount) (*ChannelEdge, *ChannelEdge, error) { capacity btcutil.Amount) (*ChannelEdge, *ChannelEdge, error) {
var ( var (
vertex1, vertex2 memNode vertex1, vertex2 *memNode
ok bool ok bool
) )
if node1 != nil { if node1 != nil {
vertex1, ok = m.graph[NewNodeID(node1)] vertex1, ok = m.graph[NewNodeID(node1)]
if !ok { if !ok {
vertex1 = memNode{ vertex1 = &memNode{
pub: node1, pub: node1,
addrs: []net.Addr{ addrs: []net.Addr{
&net.TCPAddr{ &net.TCPAddr{
@ -381,7 +381,7 @@ func (m *memChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
vertex1 = memNode{ vertex1 = &memNode{
pub: newPub, pub: newPub,
addrs: []net.Addr{ addrs: []net.Addr{
&net.TCPAddr{ &net.TCPAddr{
@ -394,7 +394,7 @@ func (m *memChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,
if node2 != nil { if node2 != nil {
vertex2, ok = m.graph[NewNodeID(node2)] vertex2, ok = m.graph[NewNodeID(node2)]
if !ok { if !ok {
vertex2 = memNode{ vertex2 = &memNode{
pub: node2, pub: node2,
addrs: []net.Addr{ addrs: []net.Addr{
&net.TCPAddr{ &net.TCPAddr{
@ -408,7 +408,7 @@ func (m *memChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
vertex2 = memNode{ vertex2 = &memNode{
pub: newPub, pub: newPub,
addrs: []net.Addr{ addrs: []net.Addr{
&net.TCPAddr{ &net.TCPAddr{
@ -446,7 +446,7 @@ func (m *memChannelGraph) addRandNode() (*btcec.PublicKey, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
vertex := memNode{ vertex := &memNode{
pub: newPub, pub: newPub,
addrs: []net.Addr{ addrs: []net.Addr{
&net.TCPAddr{ &net.TCPAddr{