From ca6c5347593d4c23915d283452d97f4c3c2db9ce Mon Sep 17 00:00:00 2001 From: filipgolem <44880692+filipgolem@users.noreply.github.com> Date: Thu, 18 Mar 2021 09:15:05 +0100 Subject: [PATCH] Start accepting debit notes after the activity is created (#150) --- yajsapi/executor/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/yajsapi/executor/index.ts b/yajsapi/executor/index.ts index 76a25be9b..82620c62b 100755 --- a/yajsapi/executor/index.ts +++ b/yajsapi/executor/index.ts @@ -322,6 +322,7 @@ export class Executor implements ComputationHistory { let self = this; let agreements_to_pay: Set = new Set(); + let agreements_accepting_debit_notes: Set = new Set(); let invoices: Map = new Map(); let payment_closing: boolean = false; let secure = this._task_package.secure; @@ -346,6 +347,7 @@ export class Executor implements ComputationHistory { try { await invoice.accept(invoice.amount, allocation); agreements_to_pay.delete(invoice.agreementId); + agreements_accepting_debit_notes.delete(invoice.agreementId); emit( new events.PaymentAccepted({ agr_id: invoice.agreementId, @@ -397,7 +399,7 @@ export class Executor implements ComputationHistory { for await (let debit_note of self._payment_api.incoming_debit_notes( paymentCancellationToken )) { - if (agreements_to_pay.has(debit_note.agreementId)) { + if (agreements_accepting_debit_notes.has(debit_note.agreementId)) { emit(new events.DebitNoteReceived({ agr_id: debit_note.agreementId, note_id: debit_note.debitNodeId, @@ -581,7 +583,7 @@ export class Executor implements ComputationHistory { agr_id: agreement.id(), }) ); - + agreements_accepting_debit_notes.add(agreement.id()); let work_context = new WorkContext( `worker-${wid}`, storage_manager,