func (sub *Subscriber) StartListening() {
	go func() {
		for {
			payload, err := sub.sock.Recv()
			log.With().Debug("got message", log.Binary("payload", payload))
			if err != nil {
				if err.Error() == "connection closed" {
					log.Warning("connection closed on pubsub reader")
				} else {
					log.Error("error on recv: %v", err)
				}
				return
			}
			sub.route(payload)
		}
	}()
}
StartListening runs in a go routine and listens to all channels this subscriber is registered to. it then passes the
messages received to the appropriate reader channel.
package events
import (
	"fmt"
	"sync"
	"time"
	"nanomsg.org/go-mangos"
	"nanomsg.org/go-mangos/protocol/pub"
	"nanomsg.org/go-mangos/protocol/sub"
	"nanomsg.org/go-mangos/transport/ipc"
	"nanomsg.org/go-mangos/transport/tcp"
	"github.com/spacemeshos/go-spacemesh/log"
)
const channelBuffer = 100
type ChannelID byte
type Subscriber struct {
	sock   mangos.Socket
	closer chan struct{}
	chanLock  sync.RWMutex
	output    map[ChannelID]chan []byte
	allOutput chan []byte
}
func NewSubscriber(url string) (*Subscriber, error) {
	socket, err := sub.NewSocket()
	if err != nil {
		return nil, fmt.Errorf("create socket: %w", err)
	}
	socket.AddTransport(ipc.NewTransport())
	socket.AddTransport(tcp.NewTransport())
	socket.SetOption(mangos.OptionBestEffort, false)
	socket.SetOption(mangos.OptionReadQLen, 10000)
	err = socket.Dial(url)
	if err != nil {
		return nil, fmt.Errorf("dial socket: %w", err)
	}
	return &Subscriber{
		sock:   socket,
		output: make(map[ChannelID]chan []byte, 100),
		closer: make(chan struct{}),
	}, nil
}