refactor: removing event emitter

This commit is contained in:
Richard Ramos 2021-10-06 11:19:08 -04:00
parent adc6883028
commit 91851dda63
No known key found for this signature in database
GPG Key ID: 80D4B01265FDFE8F
1 changed files with 0 additions and 8 deletions

View File

@ -14,7 +14,6 @@ import (
"github.com/libp2p/go-libp2p-core/crypto" "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/discovery" "github.com/libp2p/go-libp2p-core/discovery"
"github.com/libp2p/go-libp2p-core/event"
"github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
@ -507,8 +506,6 @@ func WithMaxMessageSize(maxMessageSize int) Option {
// processLoop handles all inputs arriving on the channels // processLoop handles all inputs arriving on the channels
func (p *PubSub) processLoop(ctx context.Context) { func (p *PubSub) processLoop(ctx context.Context) {
em, _ := p.host.EventBus().Emitter(new(event.EvtPeerConnectednessChanged))
defer func() { defer func() {
// Clean up go routines. // Clean up go routines.
for _, ch := range p.peers { for _, ch := range p.peers {
@ -516,7 +513,6 @@ func (p *PubSub) processLoop(ctx context.Context) {
} }
p.peers = nil p.peers = nil
p.topics = nil p.topics = nil
em.Close() // MUST call this after being done with the emitter
}() }()
for { for {
@ -537,8 +533,6 @@ func (p *PubSub) processLoop(ctx context.Context) {
go p.handleNewPeer(ctx, pid, messages) go p.handleNewPeer(ctx, pid, messages)
p.peers[pid] = messages p.peers[pid] = messages
em.Emit(event.EvtPeerConnectednessChanged{Peer: pid, Connectedness: network.Connected})
case s := <-p.newPeerStream: case s := <-p.newPeerStream:
pid := s.Conn().RemotePeer() pid := s.Conn().RemotePeer()
@ -560,7 +554,6 @@ func (p *PubSub) processLoop(ctx context.Context) {
case pid := <-p.newPeerError: case pid := <-p.newPeerError:
delete(p.peers, pid) delete(p.peers, pid)
em.Emit(event.EvtPeerConnectednessChanged{Peer: pid, Connectedness: network.NotConnected})
case pid := <-p.peerDead: case pid := <-p.peerDead:
ch, ok := p.peers[pid] ch, ok := p.peers[pid]
@ -590,7 +583,6 @@ func (p *PubSub) processLoop(ctx context.Context) {
} }
p.rt.RemovePeer(pid) p.rt.RemovePeer(pid)
em.Emit(event.EvtPeerConnectednessChanged{Peer: pid, Connectedness: network.NotConnected})
case treq := <-p.getTopics: case treq := <-p.getTopics:
var out []string var out []string