-
Notifications
You must be signed in to change notification settings - Fork 720
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
In query tip command, make epoch number available on Byron #2688
Conversation
dd1bd88
to
09cbf3d
Compare
Resolves #2568 |
On
|
On testnet:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! This was a lot simpler than I thought it would be. A few comments below.
cardano-api/src/Cardano/Api/Query.hs
Outdated
-> History.Interpreter xs | ||
-> EraHistory mode | ||
|
||
slotToEpoch :: SlotNo -> EraHistory mode -> Either Qry.PastHorizonException (EpochNo, Word64, Word64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the two Word64
s? A comment here would help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added type aliases to help with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are the type aliases? Would it not be better the be a newtype
?
@@ -201,6 +214,13 @@ runQueryTip (AnyConsensusModeParams cModeParams) network mOutFile = do | |||
Aeson.Object $ obj <> HMS.fromList [name .= Aeson.Null] | |||
toObject _ _ _ = Aeson.Null | |||
|
|||
toJsonPastHorizonException :: Qry.PastHorizonException -> Aeson.Value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should propagate this through the existing error type ShelleyQueryCmdError
. I think it would be strange to render some errors via ShelleyQueryCmdError
and some via JSON output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends. If we go via ShelleyQueryCmdError
if something wrong happens we get no values even if some queries succeed. If we do this instead, we will get partial data even when some queries fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've taken the approach where if the epoch query fails, the JSON will be printed without the epoch and an error is logged to stdout
.
09cbf3d
to
b9dad15
Compare
5532d6d
to
275f366
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! One minor comment
ShelleyQueryCmdUnsupportedMode mode -> "Unsupported mode: " <> renderMode mode | ||
ShelleyQueryCmdPastHorizon e -> "Past horizon: " <> show e | ||
|
||
renderMode :: AnyConsensusMode -> Text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function already exists in: Cardano.CLI.Shelley.Run.Transaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the function to a common module.
275f366
to
c3a7bf8
Compare
c3a7bf8
to
b550bdd
Compare
bors merge |
Build succeeded: |
This is done by using the history interpreter to convert slot number to epoch number.