paychmgr: erlier checks in completeAmount

This commit is contained in:
Łukasz Magiera 2022-02-14 21:11:31 +01:00
parent 36a1934845
commit da5ae1efe1

View File

@ -179,6 +179,11 @@ func (m *mergedFundsReq) completeAmount(avail types.BigInt, channelInfo *Channel
break
}
// don't try to fill inactive requests
if !r.isActive() {
continue
}
if r.amt.GreaterThan(types.BigSub(avail, used)) {
// requests are sorted by amount ascending, so if we hit this, there aren't any more requests we can fill
@ -198,11 +203,6 @@ func (m *mergedFundsReq) completeAmount(avail types.BigInt, channelInfo *Channel
break
}
// don't try to fill inactive requests
if !r.isActive() {
continue
}
used = types.BigAdd(used, r.amt)
r.onComplete(&paychFundsRes{channel: *channelInfo.Channel})
next = i + 1