mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-27 14:05:18 +00:00
b5be83a02e
* fix: using relay without bcaster should consume and drop messages * update relay api usage * move subscription to broadcaster * move filter logic under subscription * Support more than 1 relay subscription for a pubSubTopic * modify relay Publish API to derive pubSubTopic based on autosharding * implement relay RPC methods for autosharding * remove relay msgChannel and relay on pubsub buffersize for subscription Co-authored-by: richΛrd <info@richardramos.me> * handle relay subscribe with noConsumer and address issue reported in code review * chore: reorg relay code --------- Co-authored-by: richΛrd <info@richardramos.me>
33 lines
697 B
Go
33 lines
697 B
Go
package rpc
|
|
|
|
import (
|
|
"github.com/waku-org/go-waku/waku/v2/protocol"
|
|
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
|
|
)
|
|
|
|
type Adder func(msg *protocol.Envelope)
|
|
|
|
type runnerService struct {
|
|
broadcaster relay.Broadcaster
|
|
sub *relay.Subscription
|
|
adder Adder
|
|
}
|
|
|
|
func newRunnerService(broadcaster relay.Broadcaster, adder Adder) *runnerService {
|
|
return &runnerService{
|
|
broadcaster: broadcaster,
|
|
adder: adder,
|
|
}
|
|
}
|
|
|
|
func (r *runnerService) Start() {
|
|
r.sub = r.broadcaster.RegisterForAll(relay.WithBufferSize(relay.DefaultRelaySubscriptionBufferSize))
|
|
for envelope := range r.sub.Ch {
|
|
r.adder(envelope)
|
|
}
|
|
}
|
|
|
|
func (r *runnerService) Stop() {
|
|
r.sub.Unsubscribe()
|
|
}
|