mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
swarm/pss: Minor cleanup
This commit is contained in:
parent
b13b05c297
commit
8b7918ba1c
3 changed files with 8 additions and 7 deletions
|
|
@ -432,7 +432,6 @@ func (k *Kademlia) eachAddr(base []byte, o int, f func(*BzzAddr, int, bool) bool
|
|||
// neighbourhoodDepth returns the proximity order that defines the distance of
|
||||
// the nearest neighbour set with cardinality >= MinProxBinSize
|
||||
// if there is altogether less than MinProxBinSize peers it returns 0
|
||||
// caller must hold the lock
|
||||
func (k *Kademlia) NeighbourhoodDepth() (depth int) {
|
||||
k.lock.RLock()
|
||||
defer k.lock.RUnlock()
|
||||
|
|
|
|||
|
|
@ -129,9 +129,8 @@ func testProtocol(t *testing.T) {
|
|||
case <-lmsgC:
|
||||
log.Debug("lnode ok")
|
||||
case cerr := <-lctx.Done():
|
||||
_ = cerr
|
||||
t.Fatalf("test message timed out: %v", cerr)
|
||||
return
|
||||
//t.Fatalf("test message timed out: %v", cerr)
|
||||
}
|
||||
select {
|
||||
case <-rmsgC:
|
||||
|
|
|
|||
|
|
@ -510,11 +510,11 @@ func (p *Pss) isSelfPossibleRecipient(msg *PssMsg, prox bool) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
minProx := p.Kademlia.NeighbourhoodDepth()
|
||||
depth, _ := p.Kademlia.Pof(p.Kademlia.BaseAddr(), msg.To, 0)
|
||||
log.Trace("selfpossible", "minprox", minProx, "depth", depth)
|
||||
depth := p.Kademlia.NeighbourhoodDepth()
|
||||
po, _ := p.Kademlia.Pof(p.Kademlia.BaseAddr(), msg.To, 0)
|
||||
log.Trace("selfpossible", "po", po, "depth", depth)
|
||||
|
||||
if minProx <= depth {
|
||||
if po <= depth {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
@ -770,6 +770,9 @@ func (p *Pss) SendRaw(address PssAddress, topic Topic, msg []byte) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// if we have a proxhandler on this topic
|
||||
// also deliver message to ourselves
|
||||
if p.isSelfPossibleRecipient(pssMsg, true) && p.topicHandlerCaps[topic].prox {
|
||||
return p.process(pssMsg, true, true)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue