Skip to content

Commit

Permalink
slight code simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienGllmt committed Apr 7, 2021
1 parent 5affb7b commit b2a03a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,6 @@ async function updateTransactionBatch(
...DbBlock,
|}> = [];
const modifiedTxIds = new Set<number>();
const modifiedToSuccessful: Array<CardanoByronTxIO | CardanoShelleyTxIO> = [];
for (const txFromNetwork of request.txsFromNetwork) {
const matchInDb = matchesInDb.get(txFromNetwork.hash);
if (matchInDb == null) {
Expand Down Expand Up @@ -1492,10 +1491,11 @@ async function updateTransactionBatch(
continue;
}
if (result.block !== null) {
modifiedToSuccessful.push({
txsAddedToBlock.push({
...(matchInDb: (CardanoByronTxIO | CardanoShelleyTxIO)),
// override with updated
transaction: result.transaction,
block: result.block,
});
}
}
Expand Down Expand Up @@ -1583,11 +1583,7 @@ async function updateTransactionBatch(
GetTransaction: deps.GetTransaction,
},
{
inputTxIds: [
...newTxIds,
// txs we've seen before may have changed status to success, so we need to update them
...modifiedToSuccessful.map(value => value.transaction.TransactionId),
],
inputTxIds: newTxIds,
allTxIds: [
...request.txIds,
...newTxIds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,6 @@ async function updateTransactionBatch(
...DbBlock,
|}> = [];
const modifiedTxIds = new Set<number>();
const modifiedToSuccessful: Array<ErgoTxIO> = [];
for (const txFromNetwork of request.txsFromNetwork) {
const matchInDb = matchesInDb.get(txFromNetwork.hash);
if (matchInDb == null) {
Expand Down Expand Up @@ -1243,10 +1242,11 @@ async function updateTransactionBatch(
continue;
}
if (result.block !== null) {
modifiedToSuccessful.push({
txsAddedToBlock.push({
...(matchInDb: (ErgoTxIO)),
// override with updated
transaction: result.transaction,
block: result.block,
});
}
}
Expand Down Expand Up @@ -1312,11 +1312,7 @@ async function updateTransactionBatch(
GetTransaction: deps.GetTransaction,
},
{
inputTxIds: [
...newTxIds,
// txs we've seen before may have changed status to success, so we need to update them
...modifiedToSuccessful.map(value => value.transaction.TransactionId),
],
inputTxIds: newTxIds,
allTxIds: [
...request.txIds,
...newTxIds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,6 @@ async function updateTransactionBatch(
...DbBlock,
|}> = [];
const modifiedTxIds = new Set<number>();
const modifiedToSuccessful: Array<JormungandrTxIO> = [];
for (const txFromNetwork of request.txsFromNetwork) {
const matchInDb = matchesInDb.get(txFromNetwork.hash);
if (matchInDb == null) {
Expand Down Expand Up @@ -1329,10 +1328,11 @@ async function updateTransactionBatch(
continue;
}
if (result.block !== null) {
modifiedToSuccessful.push({
txsAddedToBlock.push({
...matchInDb,
// override with updated
transaction: result.transaction,
block: result.block,
});
}
}
Expand Down Expand Up @@ -1402,11 +1402,7 @@ async function updateTransactionBatch(
GetTransaction: deps.GetTransaction,
},
{
inputTxIds: [
...newTxIds,
// txs we've seen before may have changed status to success, so we need to update them
...modifiedToSuccessful.map(value => value.transaction.TransactionId),
],
inputTxIds: newTxIds,
allTxIds: [
...request.txIds,
...newTxIds,
Expand Down

0 comments on commit b2a03a4

Please sign in to comment.