Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize filtering in listTransactions by converting Range UTCTime to Range SlotId #595

Merged
merged 8 commits into from
Aug 2, 2019

Conversation

Anviking
Copy link
Member

@Anviking Anviking commented Jul 31, 2019

Issue Number

#466

Overview

Previous PR #588 added filtering-support to DB.readTxHistory using Range SlotId. Here we do the final connecting to allow WalletLayer.listTransactions filtering by Range UTCTime.

  • I have added a slotAtTime mirroring slotStartTime. I've added an unfinished roundtrip test for this. ⚠️ I'm not sure this is exactly how we want it. There might be subtleties regarding to which slot the boundary belongs to etc.
  • TODO: Convert Range UTCTime to Range SlotId argument listTransactions (Maybe Range could be functor or something?)

Comments

  • I've tried to separate into confined commits
  • Doing the UTCTime -> SlotId conversion might not be needed in the future, depending on how we deal with proper slotting and changing epoch/slot-lengths.

@Anviking Anviking force-pushed the anviking/466/convert-time-to-slot branch from f2a06d7 to d45dc35 Compare July 31, 2019 18:34
@Anviking Anviking force-pushed the anviking/466/add-filtering-to-db branch 2 times, most recently from 4aa664c to e23c506 Compare July 31, 2019 19:01
@Anviking Anviking changed the title Finalize filtering in listTransactions by converting UTCTime to SlotId Finalize filtering in listTransactions by converting Range UTCTime to Range SlotId Jul 31, 2019
@Anviking Anviking force-pushed the anviking/466/convert-time-to-slot branch from d45dc35 to b6c727b Compare July 31, 2019 23:44
@@ -759,10 +759,11 @@ newWalletLayer tracer bp db nw tl = do
ErrListTransactionsStartTimeLaterThanEndTime $
ErrStartTimeLaterThanEndTime start end
_ -> pure ()
let slotIdRange = (error "TODO :: UTCTime -> SlotId") timeRange
Copy link
Member Author

@Anviking Anviking Jul 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re

case (mStart, mEnd) of
            (Just start, Just end) -> when (start > end) $ throwE $
	                ErrListTransactionsStartTimeLaterThanEndTime $
	                    ErrStartTimeLaterThanEndTime start end
	            _ -> pure ()

I considered moving this logic to Primitive.Types as isValid :: Range a -> Bool, but then there is no nice way of constructing ErrStartTimeLaterThanEndTime with pure UTCTimes.

@jonathanknowles jonathanknowles force-pushed the anviking/466/add-filtering-to-db branch 2 times, most recently from a99a8c9 to 820b63f Compare August 1, 2019 08:24
@KtorZ KtorZ changed the base branch from anviking/466/add-filtering-to-db to master August 2, 2019 12:38
@KtorZ KtorZ force-pushed the anviking/466/convert-time-to-slot branch from b6c727b to ff73e0a Compare August 2, 2019 13:02
Anviking and others added 8 commits August 2, 2019 16:23
We represent slot number in 'SlotId' as 'Word16', so it doesn't make much sense to allow the 'EpochLength' to go
far beyond that bound. This might bite us later in rounding and overflowing. So, better keep the epoch length the same
size as the slot number
We cannot generate 'SlotId' and 'EpochLength' independently, as this may generate invalid data..
Make sure the guard is triggered before we actually go fetch the wallet in the database.
@KtorZ KtorZ force-pushed the anviking/466/convert-time-to-slot branch from ff73e0a to d0b97b4 Compare August 2, 2019 14:26
@KtorZ KtorZ self-assigned this Aug 2, 2019
@KtorZ KtorZ requested a review from paweljakubas August 2, 2019 14:26
@KtorZ KtorZ marked this pull request as ready for review August 2, 2019 14:26
{ startTime :: UTCTime
, endTime :: UTCTime
{ errStartTime :: UTCTime
, errEndTime :: UTCTime
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to avoid name clash.

(SlotLength slotLength)
slotsPerEpoch
slotLength
epochLength
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed for consistency in naming with the Primitive.Types module.

@@ -753,17 +756,26 @@ newWalletLayer tracer bp db nw tl = do
-> SortOrder
-> ExceptT ErrListTransactions IO [TransactionInfo]
_listTransactions wid mStart mEnd order = do
guardRange (mStart, mEnd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

factored out for readability.

@KtorZ
Copy link
Member

KtorZ commented Aug 2, 2019

@paweljakubas I've picked this over @Anviking and finalized what he started. I think that is now ready to be reviewed and merged.

Will remain: adding the Content-Range header to the response to convey some metadata and.. probably some integration tests scenarios.

Copy link
Contributor

@paweljakubas paweljakubas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@paweljakubas paweljakubas merged commit 8cb070e into master Aug 2, 2019
@paweljakubas paweljakubas deleted the anviking/466/convert-time-to-slot branch August 2, 2019 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants