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
|
// neighbourhoodDepth returns the proximity order that defines the distance of
|
||||||
// the nearest neighbour set with cardinality >= MinProxBinSize
|
// the nearest neighbour set with cardinality >= MinProxBinSize
|
||||||
// if there is altogether less than MinProxBinSize peers it returns 0
|
// if there is altogether less than MinProxBinSize peers it returns 0
|
||||||
// caller must hold the lock
|
|
||||||
func (k *Kademlia) NeighbourhoodDepth() (depth int) {
|
func (k *Kademlia) NeighbourhoodDepth() (depth int) {
|
||||||
k.lock.RLock()
|
k.lock.RLock()
|
||||||
defer k.lock.RUnlock()
|
defer k.lock.RUnlock()
|
||||||
|
|
|
||||||
|
|
@ -129,9 +129,8 @@ func testProtocol(t *testing.T) {
|
||||||
case <-lmsgC:
|
case <-lmsgC:
|
||||||
log.Debug("lnode ok")
|
log.Debug("lnode ok")
|
||||||
case cerr := <-lctx.Done():
|
case cerr := <-lctx.Done():
|
||||||
_ = cerr
|
t.Fatalf("test message timed out: %v", cerr)
|
||||||
return
|
return
|
||||||
//t.Fatalf("test message timed out: %v", cerr)
|
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-rmsgC:
|
case <-rmsgC:
|
||||||
|
|
|
||||||
|
|
@ -510,11 +510,11 @@ func (p *Pss) isSelfPossibleRecipient(msg *PssMsg, prox bool) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
minProx := p.Kademlia.NeighbourhoodDepth()
|
depth := p.Kademlia.NeighbourhoodDepth()
|
||||||
depth, _ := p.Kademlia.Pof(p.Kademlia.BaseAddr(), msg.To, 0)
|
po, _ := p.Kademlia.Pof(p.Kademlia.BaseAddr(), msg.To, 0)
|
||||||
log.Trace("selfpossible", "minprox", minProx, "depth", depth)
|
log.Trace("selfpossible", "po", po, "depth", depth)
|
||||||
|
|
||||||
if minProx <= depth {
|
if po <= depth {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
@ -770,6 +770,9 @@ func (p *Pss) SendRaw(address PssAddress, topic Topic, msg []byte) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we have a proxhandler on this topic
|
||||||
|
// also deliver message to ourselves
|
||||||
if p.isSelfPossibleRecipient(pssMsg, true) && p.topicHandlerCaps[topic].prox {
|
if p.isSelfPossibleRecipient(pssMsg, true) && p.topicHandlerCaps[topic].prox {
|
||||||
return p.process(pssMsg, true, true)
|
return p.process(pssMsg, true, true)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue