aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/pss/api.go
diff options
context:
space:
mode:
authorlash <nolash@users.noreply.github.com>2018-11-26 20:52:04 +0800
committerAnton Evangelatov <anton.evangelatov@gmail.com>2018-11-26 20:52:04 +0800
commit197d609b9a3a9b5436a9902dcc8db38bb3e7543b (patch)
tree5a5e6650aed71fbff63cffd62f84e2bb2de0e8cc /swarm/pss/api.go
parentca228569e4aedd5ebbe853ec61761561d86579a6 (diff)
downloadgo-tangerine-197d609b9a3a9b5436a9902dcc8db38bb3e7543b.tar
go-tangerine-197d609b9a3a9b5436a9902dcc8db38bb3e7543b.tar.gz
go-tangerine-197d609b9a3a9b5436a9902dcc8db38bb3e7543b.tar.bz2
go-tangerine-197d609b9a3a9b5436a9902dcc8db38bb3e7543b.tar.lz
go-tangerine-197d609b9a3a9b5436a9902dcc8db38bb3e7543b.tar.xz
go-tangerine-197d609b9a3a9b5436a9902dcc8db38bb3e7543b.tar.zst
go-tangerine-197d609b9a3a9b5436a9902dcc8db38bb3e7543b.zip
swarm/pss: Message handler refactor (#18169)
Diffstat (limited to 'swarm/pss/api.go')
-rw-r--r--swarm/pss/api.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/swarm/pss/api.go b/swarm/pss/api.go
index eba7bb722..dd55b2a70 100644
--- a/swarm/pss/api.go
+++ b/swarm/pss/api.go
@@ -51,7 +51,7 @@ func NewAPI(ps *Pss) *API {
//
// All incoming messages to the node matching this topic will be encapsulated in the APIMsg
// struct and sent to the subscriber
-func (pssapi *API) Receive(ctx context.Context, topic Topic) (*rpc.Subscription, error) {
+func (pssapi *API) Receive(ctx context.Context, topic Topic, raw bool, prox bool) (*rpc.Subscription, error) {
notifier, supported := rpc.NotifierFromContext(ctx)
if !supported {
return nil, fmt.Errorf("Subscribe not supported")
@@ -59,7 +59,7 @@ func (pssapi *API) Receive(ctx context.Context, topic Topic) (*rpc.Subscription,
psssub := notifier.CreateSubscription()
- handler := func(msg []byte, p *p2p.Peer, asymmetric bool, keyid string) error {
+ hndlr := NewHandler(func(msg []byte, p *p2p.Peer, asymmetric bool, keyid string) error {
apimsg := &APIMsg{
Msg: hexutil.Bytes(msg),
Asymmetric: asymmetric,
@@ -69,9 +69,15 @@ func (pssapi *API) Receive(ctx context.Context, topic Topic) (*rpc.Subscription,
log.Warn(fmt.Sprintf("notification on pss sub topic rpc (sub %v) msg %v failed!", psssub.ID, msg))
}
return nil
+ })
+ if raw {
+ hndlr.caps.raw = true
+ }
+ if prox {
+ hndlr.caps.prox = true
}
- deregf := pssapi.Register(&topic, handler)
+ deregf := pssapi.Register(&topic, hndlr)
go func() {
defer deregf()
select {