Skip to content

Commit

Permalink
Fix filtering of transactions for RewardAccount
Browse files Browse the repository at this point in the history
`bfGetAccountWithdrawals` fetches all transactions, but we only want those that are within the range set by `bhFrom` and `bhTo`.
  • Loading branch information
HeinrichApfelmus committed Jul 20, 2022
1 parent 47cd59c commit b306c6d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/shelley/src/Cardano/Wallet/Shelley/Network/Blockfrost.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ import Cardano.Wallet.Primitive.Types
, TokenBundleMaxSize (..)
, TxParameters (..)
, WithOrigin (At)
, chainPointFromBlockHeader
, emptyEraInfo
, executionMemory
, executionSteps
, fromFederationPercentage
, genesisParameters
, getGenesisBlockDate
, header
, toSlot
)
import Cardano.Wallet.Primitive.Types.Address
( Address )
Expand Down Expand Up @@ -580,7 +582,7 @@ blockfrostLightSyncSource
<$> zip [0 ..] dcerts
)
ws <- bfGetAccountWithdrawals address
blockEventsWithdraw <-
blockEventsWithdrawUnfiltered <-
for ws \BF.AccountWithdrawal{..} -> do
(bftx@BF.Transaction{_transactionIndex}, tx) <-
fetchTransaction
Expand All @@ -594,8 +596,17 @@ blockfrostLightSyncSource
bftx
(unsafeMkSublist [((txIndex, 0), tx)])
(unsafeMkSublist [])
let inRange x = slotFrom <= slot x && slot x <= slotTo
blockEventsWithdraw =
filter inRange blockEventsWithdrawUnfiltered
pure $ blockEventsRegDeleg <> blockEventsWithdraw
where
slotFromBlockHeader = toSlot . chainPointFromBlockHeader
(slotFrom, slotTo) =
( slotFromBlockHeader bhFrom
, slotFromBlockHeader bhTo
)

txBlockEvents ::
BF.Transaction ->
Sublist Tx ->
Expand Down

0 comments on commit b306c6d

Please sign in to comment.