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

Add 'Initial' message-decoder with config parameters #266

Merged
merged 6 commits into from
May 16, 2019

Conversation

Anviking
Copy link
Member

Issue Number

#218

Overview

  • Added Initial message, ConfigParam and some child types
  • Replaced test vector with the new format
  • Added a unit test

Comments

@Anviking Anviking self-assigned this May 15, 2019
\5e05f5f8e53b87e7ea452f000000000000000e"
genesisHeader

it "should decode a genesis block" $ do
Copy link
Member Author

Choose a reason for hiding this comment

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

should decode a genesis block header is now redundant, but I didn't mind the duplication since we would get more information from the test output without looking at the details. Happy to change though.

-- Seconds elapsed since 1-Jan-1970 (unix time)
= Block0Date Word64
| ConfigDiscrimination Discrimination
| ConsensusVersion Word16 -- ?
Copy link
Member Author

Choose a reason for hiding this comment

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

Types here are obviously not that polished

-- 12 most-significant bits: tag
taglen <- getWord16be
let tag = taglen `shift` (-6)
let len = fromIntegral $ taglen .&. (63) -- 0b111111
Copy link
Member Author

Choose a reason for hiding this comment

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

Had this bit-wise logic separate at first, but

  • TagLen would be completely uninteresting to the rest of the code
  • Testing it indirectly through getConfigParam . putConfigParam roundtrip should be fine…? 🤔 or we will miss potential edge-cases?

@Anviking Anviking requested a review from KtorZ May 15, 2019 15:25
a -> fail $ "Invalid config param with tag " ++ show a

data Discrimination = Production | Test
deriving (Eq, Show)
Copy link
Member

Choose a reason for hiding this comment

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

That should basically match the Cardano.Wallet.Environment.Jormungandr. There's no more protocol magic with Jormungandr but instead, only two levels of discrimination.

Copy link
Member

@KtorZ KtorZ left a comment

Choose a reason for hiding this comment

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

LGTM

@KtorZ KtorZ merged commit e4a267a into master May 16, 2019
@KtorZ KtorZ deleted the anviking/218/jörmungandr-config branch May 16, 2019 09:54
@KtorZ KtorZ mentioned this pull request May 16, 2019
5 tasks
Copy link
Contributor

@akegalj akegalj left a comment

Choose a reason for hiding this comment

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

lgtm

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