From da5ae1efe178717f1c97401f67e3fd298cb74f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 14 Feb 2022 21:11:31 +0100 Subject: [PATCH] paychmgr: erlier checks in completeAmount --- paychmgr/simple.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/paychmgr/simple.go b/paychmgr/simple.go index 0eb1316af..5a23c7f2c 100644 --- a/paychmgr/simple.go +++ b/paychmgr/simple.go @@ -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