diff --git a/swarm/network/hive.go b/swarm/network/hive.go index 6c928416ff..6c6ef7f5e8 100644 --- a/swarm/network/hive.go +++ b/swarm/network/hive.go @@ -21,6 +21,7 @@ import ( "sync" "time" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/enode" @@ -247,7 +248,15 @@ func (h *Hive) savePeers() error { func (h *Hive) Healthy(addrs [][]byte) *Health { k := NewKademlia(h.BaseAddr(), NewKadParams()) for _, a := range addrs { - k.On(a) + p := &Peer{ + BzzPeer: &BzzPeer{ + BzzAddr: &BzzAddr{ + OAddr: a, + }, + }, + } + k.On(p) } - return pp.Healthy([]*Kademlia{k}) + pp := NewPeerPotMap([]*Kademlia{k}) + return pp[common.Bytes2Hex(h.BaseAddr())].Healthy() } diff --git a/swarm/network/simulations/discovery/discovery_test.go b/swarm/network/simulations/discovery/discovery_test.go index 3dde1028fa..0086178eb7 100644 --- a/swarm/network/simulations/discovery/discovery_test.go +++ b/swarm/network/simulations/discovery/discovery_test.go @@ -269,7 +269,7 @@ func discoverySimulation(nodes, conns int, adapter adapters.NodeAdapter) (*simul for _, a := range addrs { kads = append(kads, network.NewKademlia(a, network.NewKadParams())) } - ppmap := network.NewPeerPotMap(kads) + //ppmap := network.NewPeerPotMap(kads) check := func(ctx context.Context, id enode.ID) (bool, error) { select { case <-ctx.Done(): @@ -287,8 +287,9 @@ func discoverySimulation(nodes, conns int, adapter adapters.NodeAdapter) (*simul } healthy := &network.Health{} - pp := ppmap[id.String()] - if err := client.Call(&healthy, "hive_healthy", pp.BaseAddr(), pp); err != nil { + //pp := ppmap[id.String()] + //if err := client.Call(&healthy, "hive_healthy", pp.BaseAddr(), pp); err != nil { + if err := client.Call(&healthy, "hive_healthy", addrs); err != nil { return false, fmt.Errorf("error getting node health: %s", err) } log.Debug(fmt.Sprintf("node %4s healthy: got nearest neighbours: %v, know nearest neighbours: %v,\n\n%v", id, healthy.GotNN, healthy.KnowNN, healthy.Hive)) @@ -389,7 +390,7 @@ func discoveryPersistenceSimulation(nodes, conns int, adapter adapters.NodeAdapt for _, a := range addrs { kads = append(kads, network.NewKademlia(a, network.NewKadParams())) } - ppmap := network.NewPeerPotMap(kads) + //ppmap := network.NewPeerPotMap(kads) var restartTime time.Time @@ -411,9 +412,9 @@ func discoveryPersistenceSimulation(nodes, conns int, adapter adapters.NodeAdapt healthy := &network.Health{} addr := id.String() log.Error("before hive healthy call") - pp := ppmap[addr] + //pp := ppmap[addr] // if err := client.Call(&healthy, "hive_healthy", pp.BaseAddr(), pp); err != nil { - if err := client.Call(&healthy, "hive_healthy", pp.BaseAddr(), addrs); err != nil { + if err := client.Call(&healthy, "hive_healthy", addrs); err != nil { return fmt.Errorf("error getting node health: %s", err) } @@ -492,8 +493,9 @@ func discoveryPersistenceSimulation(nodes, conns int, adapter adapters.NodeAdapt return false, fmt.Errorf("error getting node client: %s", err) } healthy := &network.Health{} - pp := ppmap[id.String()] - if err := client.Call(&healthy, "hive_healthy", pp.BaseAddr(), pp); err != nil { + //pp := ppmap[id.String()] + //if err := client.Call(&healthy, "hive_healthy", pp.BaseAddr(), pp); err != nil { + if err := client.Call(&healthy, "hive_healthy", addrs); err != nil { return false, fmt.Errorf("error getting node health: %s", err) } log.Info(fmt.Sprintf("node %4s healthy: got nearest neighbours: %v, know nearest neighbours: %v", id, healthy.GotNN, healthy.KnowNN))