fix: scheduler success event
@@ -175,7 +175,11 @@ func (e peerDownloadPieceSuccessEvent) apply(s *state) {
var candidates []*supervisor.Peer
parentPeer, ok := s.peerManager.Get(e.pr.DstPid)
- if ok {
+ if !ok {
+ e.peer.Log().Warnf("parent peer %s not found", e.pr.DstPid)
+ return
+ }
+
if parentPeer.IsLeave() {
e.peer.Log().Warnf("peerDownloadPieceSuccessEvent: need reschedule parent for peer because it's parent is already left")
e.peer.ReplaceParent(nil)
@@ -194,9 +198,6 @@ func (e peerDownloadPieceSuccessEvent) apply(s *state) {
e.pr.DstPid)
e.peer.ReplaceParent(parentPeer)
}
- } else {
- e.peer.Log().Warnf("parent peer %s not found", e.pr.DstPid)
- }
parentPeer.Touch()
if parentPeer.ID == e.pr.DstPid {
