diff --git a/announcements/announcements.go b/announcements/announcements.go index d9af1e5..976f13f 100644 --- a/announcements/announcements.go +++ b/announcements/announcements.go @@ -17,6 +17,7 @@ import ( pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-libp2p/core/peerstore" ) var ( @@ -126,14 +127,15 @@ func (an *FxAnnouncements) HandleAnnouncements(ctx context.Context) { log.Errorw("failed to decode announcement data", "err", err) continue } - /* - addrs, err := a.GetAddrs() - if err != nil { - log.Errorw("failed to decode announcement addrs", "err", err) - continue - } - an.h.Peerstore().AddAddrs(from, addrs, peerstore.ConnectedAddrTTL) - */ + + //TODO: We do not need to add peers that announce to peerstore + addrs, err := a.GetAddrs() + if err != nil { + log.Errorw("failed to decode announcement addrs", "err", err) + continue + } + an.h.Peerstore().AddAddrs(from, addrs, peerstore.ConnectedAddrTTL) + log.Infow("received announcement", "from", from, "self", an.h.ID(), "announcement", a) err = an.processAnnouncement(ctx, from, a.Type) if err != nil {