From ecf00942dd8530bec5a445c96b8d3e9ab05daf1a Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Thu, 12 Sep 2019 14:24:25 +0200 Subject: [PATCH] network: revert back check for light nodes --- network/retrieval/retrieve.go | 7 ++++++- network/retrieval/retrieve_test.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/network/retrieval/retrieve.go b/network/retrieval/retrieve.go index 0f54101b42..f9819fa8d0 100644 --- a/network/retrieval/retrieve.go +++ b/network/retrieval/retrieve.go @@ -226,7 +226,12 @@ func (r *Retrieval) findPeer(ctx context.Context, req *storage.Request) (retPeer r.kad.EachConn(req.Addr[:], 255, func(p *network.Peer, po int) bool { id := p.ID() - if !p.HasCap("bzz-retrieve") { + if !p.HasCap(Spec.Name) { + return true + } + + // skip light nodes, even though they support `bzz-retrieve` protocol + if p.LightNode { return true } diff --git a/network/retrieval/retrieve_test.go b/network/retrieval/retrieve_test.go index 0db3480a97..26f812a175 100644 --- a/network/retrieval/retrieve_test.go +++ b/network/retrieval/retrieve_test.go @@ -233,7 +233,7 @@ func TestRequestFromPeers(t *testing.T) { addr := network.RandomAddr() to := network.NewKademlia(addr.OAddr, network.NewKadParams()) - protocolsPeer := protocols.NewPeer(p2p.NewPeer(dummyPeerID, "dummy", []p2p.Cap{p2p.Cap{Name: "bzz-retrieve", Version: 1}}), nil, nil) + protocolsPeer := protocols.NewPeer(p2p.NewPeer(dummyPeerID, "dummy", []p2p.Cap{{Name: "bzz-retrieve", Version: 1}}), nil, nil) peer := network.NewPeer(&network.BzzPeer{ BzzAddr: network.RandomAddr(), LightNode: false, @@ -262,7 +262,7 @@ func TestRequestFromPeersWithLightNode(t *testing.T) { addr := network.RandomAddr() to := network.NewKademlia(addr.OAddr, network.NewKadParams()) - protocolsPeer := protocols.NewPeer(p2p.NewPeer(dummyPeerID, "dummy", nil), nil, nil) + protocolsPeer := protocols.NewPeer(p2p.NewPeer(dummyPeerID, "dummy", []p2p.Cap{{Name: "bzz-retrieve", Version: 1}}), nil, nil) // setting up a lightnode peer := network.NewPeer(&network.BzzPeer{