Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 63f6611

Browse files
committed
Use array.find instead of for loop in checkAmount()
1 parent cb69e3f commit 63f6611

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/action/invoice.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,10 @@ class InvoiceAction {
8484
* @return {undefined}
8585
*/
8686
checkAmount({ satAmount }) {
87-
for (let i = 0; i < this._store.channels.length; i++) {
88-
const chan = this._store.channels[i];
89-
if (chan.remoteBalance >= satAmount) {
90-
return;
91-
}
87+
const { channels } = this._store;
88+
const hasInbound = channels.find(c => c.remoteBalance >= satAmount);
89+
if (hasInbound) {
90+
return;
9291
}
9392
this._notification.display({
9493
msg: "You don't have enough inbound capacity to receive this payment.",

0 commit comments

Comments
 (0)