Skip to content

Commit

Permalink
Optimize reward txHashes lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidTranDucVL committed Nov 4, 2020
1 parent 4269ab9 commit dc0eea3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/frontend/components/pages/txHistory/transactionHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ interface Props {
}

const ExportCSV = ({transactionHistory, stakingHistory}) => {
const withdrawalHistoryTxHashes = stakingHistory
.filter((item) => item.type === StakingHistoryItemType.RewardWithdrawal)
.map((withdrawal) => withdrawal.txHash)
const withdrawalHistoryTxHashes = new Set(
stakingHistory
.filter((item) => item.type === StakingHistoryItemType.RewardWithdrawal)
.map((withdrawal) => withdrawal.txHash)
)

const stakingRewards = stakingHistory.filter(
(item) => item.type === StakingHistoryItemType.StakingReward
Expand Down Expand Up @@ -114,7 +116,7 @@ const ExportCSV = ({transactionHistory, stakingHistory}) => {
dateTime: moment.utc(new Date(transaction.ctbTimeIssued * 1000)),
}

if (withdrawalHistoryTxHashes.includes(transaction.ctbId)) {
if (withdrawalHistoryTxHashes.has(transaction.ctbId)) {
return {
...common,
type: transactionTypes.rewardWithdrawal,
Expand Down

0 comments on commit dc0eea3

Please sign in to comment.