Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CDEC-509] Remove HasGeneratedSecrets #3437

Merged
merged 1 commit into from
Aug 24, 2018
Merged

Conversation

ruhatch
Copy link
Contributor

@ruhatch ruhatch commented Aug 18, 2018

Description

Remove the HasGeneratedSecrets constraint and replace it with explicit parameter passing of GeneratedSecrets

Linked issue

CDEC-509

Type of change

  • [~] 🐞 Bug fix (non-breaking change which fixes an issue)
  • [~] 🛠 New feature (non-breaking change which adds functionality)
  • [~] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • [~] 🔨 New or improved tests for existing code
  • [~] ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • [~] CHANGELOG entry has been added and is linked to the correct PR on GitHub.

Testing checklist

  • [~] I have added tests to cover my changes.
  • All new and existing tests passed.

QA Steps

Screenshots (if available)

@ruhatch ruhatch force-pushed the ruhatch/CDEC-509 branch 6 times, most recently from 6dc8c08 to 8d858b2 Compare August 20, 2018 17:37
Copy link
Member

@erikd erikd left a comment

Choose a reason for hiding this comment

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

LGTM!

auxx/Main.hs Outdated
printAction "Mode: with-config"
CLI.printInfoOnStart aoCommonNodeArgs ntpConfig txpConfig
let generatedSecrets = fromMaybe
(error "Main.action: GeneratedSecrets missing from config")
(configGeneratedSecrets coreConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put a bang on this? I'd rather this blow up ASAP than let it propagate the _|_ all the way down until the parameter is eventually evaluated.

Alternatively, do it in IO:

generatedSecrets <- maybe (throwIO (userError ...)) return (configGeneratedSecrets coreConfig)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good point!

I think I'll extract this into a getGeneratedSecretsThrow :: Core.Config -> IO GeneratedSecrets. What's the best way to add location information to that?

Copy link
Contributor

Choose a reason for hiding this comment

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

foo :: HasCallStack => Core.Config -> IO GeneratedSecrets

though I usually find HasCallStack to be less useful than you want (if the constraint isn't carried in the call tree then it's dropped)

forM_ is $ \i -> do
key <- evaluateNF $ secrets !! i
key <- evaluateNF $ secretKeys !! i
Copy link
Contributor

Choose a reason for hiding this comment

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

oof, i know this is just a refactor, but it'd be real nice to have a non partial index here

Copy link
Member

@erikd erikd Aug 22, 2018

Choose a reason for hiding this comment

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

Wow, not looking at the rest of the code, but is that not just:

forM_ secretKeys $ \k -> do
    key <- evaluateNF k

was that written by a C/C++/Java programmer?

--command "stack ghci cardano-sl-chain:lib cardano-sl-chain:test:test --ghci-options=-fobject-code" \
--test "Main.main"

.PHONY: ghcid ghcid-test help
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@ruhatch ruhatch force-pushed the ruhatch/CDEC-509 branch 3 times, most recently from 6c47f85 to 897a65f Compare August 24, 2018 20:20
@disassembler disassembler merged commit cf4c65e into develop Aug 24, 2018
@disassembler disassembler deleted the ruhatch/CDEC-509 branch August 24, 2018 20:36
@ruhatch ruhatch restored the ruhatch/CDEC-509 branch August 24, 2018 20:39
KtorZ pushed a commit that referenced this pull request Nov 9, 2018
[CDEC-509] Remove HasGeneratedSecrets
KtorZ pushed a commit to input-output-hk/cardano-wallet-legacy that referenced this pull request Nov 9, 2018
…hk/ruhatch/CDEC-509

[CDEC-509] Remove HasGeneratedSecrets
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants