Skip to content

Commit

Permalink
Merge pull request #152 from golemfactory/debit-notes-fix-to-b0.3
Browse files Browse the repository at this point in the history
Start accepting debit notes after the activity is created (#150)
  • Loading branch information
shadeofblue authored Mar 18, 2021
2 parents 9161b68 + ca6c534 commit 91d6067
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions yajsapi/executor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export class Executor implements ComputationHistory {
let self = this;

let agreements_to_pay: Set<string> = new Set();
let agreements_accepting_debit_notes: Set<string> = new Set();
let invoices: Map<string, Invoice> = new Map();
let payment_closing: boolean = false;
let secure = this._task_package.secure;
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 91d6067

Please sign in to comment.