mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
swarm/pss: variables renamed, comment added
This commit is contained in:
parent
8805f561c5
commit
f48a3f3e2f
1 changed files with 8 additions and 4 deletions
|
|
@ -931,6 +931,9 @@ func (p *Pss) forward(msg *PssMsg) error {
|
||||||
to := make([]byte, addressLength)
|
to := make([]byte, addressLength)
|
||||||
copy(to[:len(msg.To)], msg.To)
|
copy(to[:len(msg.To)], msg.To)
|
||||||
neighbourhoodDepth := p.Kademlia.NeighbourhoodDepth()
|
neighbourhoodDepth := p.Kademlia.NeighbourhoodDepth()
|
||||||
|
|
||||||
|
// luminosity is the opposite of darkness. the more bytes are removed from the address, the higher is darkness,
|
||||||
|
// but the luminosity is less. here luminosity equals the number of bits present in the destination address.
|
||||||
luminousRadius := len(msg.To) * 8
|
luminousRadius := len(msg.To) * 8
|
||||||
if luminousRadius >= neighbourhoodDepth {
|
if luminousRadius >= neighbourhoodDepth {
|
||||||
pof := pot.DefaultPof(neighbourhoodDepth)
|
pof := pot.DefaultPof(neighbourhoodDepth)
|
||||||
|
|
@ -939,13 +942,14 @@ func (p *Pss) forward(msg *PssMsg) error {
|
||||||
|
|
||||||
if isDstInProxBin {
|
if isDstInProxBin {
|
||||||
// forward to all the nearest neighbours of the forwarding node
|
// forward to all the nearest neighbours of the forwarding node
|
||||||
p.Kademlia.EachConn(p.BaseAddr(), addressLength*8, func(sp *network.Peer, _ int, isproxbin bool) bool {
|
p.Kademlia.EachConn(nil, addressLength*8, func(sp *network.Peer, po int, _ bool) bool {
|
||||||
if isproxbin {
|
isPeerInProxBin := (po >= neighbourhoodDepth)
|
||||||
|
if isPeerInProxBin {
|
||||||
if p.trySend(sp, msg) {
|
if p.trySend(sp, msg) {
|
||||||
sent++
|
sent++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mustContinue := isproxbin
|
mustContinue := isPeerInProxBin
|
||||||
return mustContinue
|
return mustContinue
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -955,7 +959,7 @@ func (p *Pss) forward(msg *PssMsg) error {
|
||||||
// address, if there are any; otherwise only to one peer, closest to the recipient address.
|
// address, if there are any; otherwise only to one peer, closest to the recipient address.
|
||||||
// in any case, msg must be sent to at least one peer.
|
// in any case, msg must be sent to at least one peer.
|
||||||
p.Kademlia.EachConn(to, addressLength*8, func(sp *network.Peer, po int, _ bool) bool {
|
p.Kademlia.EachConn(to, addressLength*8, func(sp *network.Peer, po int, _ bool) bool {
|
||||||
isAddrMatch := (po == luminousRadius)
|
isAddrMatch := (po >= luminousRadius)
|
||||||
if isAddrMatch || sent == 0 {
|
if isAddrMatch || sent == 0 {
|
||||||
if p.trySend(sp, msg) {
|
if p.trySend(sp, msg) {
|
||||||
sent++
|
sent++
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue