From 92bafbf4a0920946c6d0e52d99ffe1bc1194d22b Mon Sep 17 00:00:00 2001 From: lash Date: Tue, 23 Oct 2018 10:49:58 +0200 Subject: [PATCH] swarm/pss: WIP amend PR comments by @zelig --- swarm/network/kademlia.go | 18 +++++++++--------- swarm/pss/api.go | 5 ++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/swarm/network/kademlia.go b/swarm/network/kademlia.go index d9116ff3e9..45b569c98d 100644 --- a/swarm/network/kademlia.go +++ b/swarm/network/kademlia.go @@ -91,15 +91,15 @@ func NewKadParams() *KadParams { // Kademlia is a table of live peers and a db of known peers (node records) type Kademlia struct { lock sync.RWMutex - *KadParams // Kademlia configuration parameters - base []byte // immutable baseaddress of the table - addrs *pot.Pot // pots container for known peer addresses - conns *pot.Pot // pots container for live peer connections - depth uint8 // stores the last current depth of saturation - nDepth int // stores the last neighbourhood depth - nDepthC chan int // returned by DepthC function to signal neighbourhood depth change - addrCountC chan int // returned by AddrCountC function to signal peer count change - Pof func(pot.Val, pot.Val, int) (int, bool) + *KadParams // Kademlia configuration parameters + base []byte // immutable baseaddress of the table + addrs *pot.Pot // pots container for known peer addresses + conns *pot.Pot // pots container for live peer connections + depth uint8 // stores the last current depth of saturation + nDepth int // stores the last neighbourhood depth + nDepthC chan int // returned by DepthC function to signal neighbourhood depth change + addrCountC chan int // returned by AddrCountC function to signal peer count change + Pof func(pot.Val, pot.Val, int) (int, bool) // function for calculating kademlia routing distance between two addresses } // NewKademlia creates a Kademlia table for base address addr diff --git a/swarm/pss/api.go b/swarm/pss/api.go index 31a0fa0ac0..44f3b040ba 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, raw bool) (*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") @@ -75,6 +75,9 @@ func (pssapi *API) Receive(ctx context.Context, topic Topic, raw bool) (*rpc.Sub if raw { hndlr.caps |= handlerCapRaw } + if prox { + hndlr.caps |= handlerCapProx + } deregf := pssapi.Register(&topic, hndlr) go func() {