Skip to content

Commit

Permalink
check balance if len of valid addres > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5459 committed Dec 8, 2023
1 parent e91e641 commit 675ed89
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions damocles-manager/modules/impl/sectors/sender_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ func (s *SenderSelector) selectInner(ctx context.Context, mid abi.ActorID, sende
return address.Undef, fmt.Errorf("no valid sender found")
}

sort.Slice(validAddrs, func(i, j int) bool {
balanceI := s.getBalance(ctx, validAddrs[i], big.Zero())
balanceJ := s.getBalance(ctx, validAddrs[j], big.Zero())
return balanceI.GreaterThan(balanceJ)
})

if len(validAddrs) > 1 {
sort.Slice(validAddrs, func(i, j int) bool {
balanceI := s.getBalance(ctx, validAddrs[i], big.Zero())
balanceJ := s.getBalance(ctx, validAddrs[j], big.Zero())
return balanceI.GreaterThan(balanceJ)
})
}
return validAddrs[0], nil
}

Expand Down

0 comments on commit 675ed89

Please sign in to comment.