Skip to content

Commit 4d884f1

Browse files
yxqvipwzw
yxq
authored andcommitted
fix: push to channel unblockedly
1 parent c00ce7d commit 4d884f1

File tree

1 file changed

+16
-3
lines changed
  • system/p2p/dht/protocol/p2pstore

1 file changed

+16
-3
lines changed

system/p2p/dht/protocol/p2pstore/query.go

+16-3
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,18 @@ func (p *Protocol) mustFetchChunk(req *types.ChunkInfoMsg) (*types.BlockBodys, p
463463
}
464464
for _, pid := range nearerPeers {
465465
if len(p.Host.Network().ConnsToPeer(pid)) != 0 {
466-
localPeers <- pid
466+
select {
467+
case localPeers <- pid:
468+
default:
469+
log.Info("mustFetchChunk localPeers channel full", "pid", pid)
470+
}
471+
467472
} else if len(p.Host.Peerstore().Addrs(pid)) != 0 {
468-
alternativePeers <- pid
473+
select {
474+
case alternativePeers <- pid:
475+
default:
476+
log.Info("mustFetchChunk alternativePeers channel full", "pid", pid)
477+
}
469478
}
470479
}
471480
default:
@@ -497,7 +506,11 @@ func (p *Protocol) mustFetchChunk(req *types.ChunkInfoMsg) (*types.BlockBodys, p
497506
}
498507
for _, pid := range nearerPeers {
499508
if len(p.Host.Peerstore().Addrs(pid)) != 0 {
500-
alternativePeers <- pid
509+
select {
510+
case alternativePeers <- pid:
511+
default:
512+
log.Info("mustFetchChunk alternativePeers channel full", "pid", pid)
513+
}
501514
}
502515
}
503516
default:

0 commit comments

Comments
 (0)