Commit a703f308 authored by acud's avatar acud Committed by GitHub

fix: dont communicate lightnodes (#1895)

parent 8d961da1
...@@ -744,7 +744,7 @@ func (n *notifiee) Pick(p p2p.Peer) bool { ...@@ -744,7 +744,7 @@ func (n *notifiee) Pick(p p2p.Peer) bool {
return n.pick return n.pick
} }
func (n *notifiee) Announce(context.Context, swarm.Address) error { func (n *notifiee) Announce(context.Context, swarm.Address, bool) error {
return nil return nil
} }
......
...@@ -336,7 +336,7 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay ...@@ -336,7 +336,7 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
if !i.FullNode { if !i.FullNode {
s.lightNodes.Connected(ctx, peer) s.lightNodes.Connected(ctx, peer)
//light node announces explicitly //light node announces explicitly
if err := s.notifier.Announce(ctx, peer.Address); err != nil { if err := s.notifier.Announce(ctx, peer.Address, i.FullNode); err != nil {
s.logger.Debugf("stream handler: notifier.Announce: %s: %v", peer.Address.String(), err) s.logger.Debugf("stream handler: notifier.Announce: %s: %v", peer.Address.String(), err)
} }
} else if err := s.notifier.Connected(ctx, peer); err != nil { // full node announces implicitly } else if err := s.notifier.Connected(ctx, peer); err != nil { // full node announces implicitly
......
...@@ -44,7 +44,7 @@ type PickyNotifier interface { ...@@ -44,7 +44,7 @@ type PickyNotifier interface {
type Notifier interface { type Notifier interface {
Connected(context.Context, Peer) error Connected(context.Context, Peer) error
Disconnected(Peer) Disconnected(Peer)
Announce(context.Context, swarm.Address) error Announce(context.Context, swarm.Address, bool) error
} }
// DebugService extends the Service with method used for debugging. // DebugService extends the Service with method used for debugging.
......
...@@ -690,12 +690,12 @@ func (k *Kad) connect(ctx context.Context, peer swarm.Address, ma ma.Multiaddr) ...@@ -690,12 +690,12 @@ func (k *Kad) connect(ctx context.Context, peer swarm.Address, ma ma.Multiaddr)
return errOverlayMismatch return errOverlayMismatch
} }
return k.Announce(ctx, peer) return k.Announce(ctx, peer, true)
} }
// Announce a newly connected peer to our connected peers, but also // Announce a newly connected peer to our connected peers, but also
// notify the peer about our already connected peers // notify the peer about our already connected peers
func (k *Kad) Announce(ctx context.Context, peer swarm.Address) error { func (k *Kad) Announce(ctx context.Context, peer swarm.Address, fullnode bool) error {
addrs := []swarm.Address{} addrs := []swarm.Address{}
for bin := uint8(0); bin < swarm.MaxBins; bin++ { for bin := uint8(0); bin < swarm.MaxBins; bin++ {
...@@ -712,6 +712,11 @@ func (k *Kad) Announce(ctx context.Context, peer swarm.Address) error { ...@@ -712,6 +712,11 @@ func (k *Kad) Announce(ctx context.Context, peer swarm.Address) error {
addrs = append(addrs, connectedPeer) addrs = append(addrs, connectedPeer)
if !fullnode {
// we continue here so we dont gossip
// about lightnodes to others.
continue
}
k.wg.Add(1) k.wg.Add(1)
go func(connectedPeer swarm.Address) { go func(connectedPeer swarm.Address) {
defer k.wg.Done() defer k.wg.Done()
...@@ -784,7 +789,7 @@ connected: ...@@ -784,7 +789,7 @@ connected:
} }
func (k *Kad) connected(ctx context.Context, addr swarm.Address) error { func (k *Kad) connected(ctx context.Context, addr swarm.Address) error {
if err := k.Announce(ctx, addr); err != nil { if err := k.Announce(ctx, addr, true); err != nil {
return err return err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment