Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

feat: bring back FETCHED_UNCONFIRMED_TRANSACTION #340

Draft
wants to merge 7 commits into
base: v0.22-dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions src/types/Storage/methods/importTransaction.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { Transaction } = require('@dashevo/dashcore-lib');
const { Output } = Transaction;
const { InvalidDashcoreTransaction } = require('../../../errors');
const { FETCHED_CONFIRMED_TRANSACTION } = require('../../../EVENTS');
const { FETCHED_UNCONFIRMED_TRANSACTION, FETCHED_CONFIRMED_TRANSACTION } = require('../../../EVENTS');

const parseStringifiedTransaction = (stringified) => new Transaction(stringified);
/**
Expand Down Expand Up @@ -51,6 +51,7 @@ const importTransaction = function importTransaction(transaction, transactionMet

if (findIndex >= 0) {
mappedTransactionsHeight[height][findIndex] = mappedTransactionObject;
hasUpdateStorage = true;
} else {
mappedTransactionsHeight[height].push(mappedTransactionObject);
}
Expand Down Expand Up @@ -114,10 +115,15 @@ const importTransaction = function importTransaction(transaction, transactionMet
addressObject.transactions.push(transaction.hash);
});

// Announce only confirmed transaction imported that are our.
if (hasUpdateStorage) {
this.lastModified = +new Date();
// Announce only confirmed transaction imported that are our.
this.announce(FETCHED_CONFIRMED_TRANSACTION, { transaction });

if (!transaction.isChainLocked && !transaction.isInstantLocked) {
this.announce(FETCHED_UNCONFIRMED_TRANSACTION, { transaction });
} else {
this.announce(FETCHED_CONFIRMED_TRANSACTION, { transaction });
}
}
};
module.exports = importTransaction;