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 Jörmungandr Servant Api Type #310

Merged
merged 1 commit into from
May 27, 2019
Merged

Conversation

Anviking
Copy link
Collaborator

@Anviking Anviking commented May 23, 2019

Issue Number

#219

Overview

  • I added a FromBinary class in Cardano.Wallet.Binary.Jörmungandr
  • I added Cardano.Wallet.Network.Jörmungandr.Api where the OctetStream content type relies on the FromBinary class.

Comments

  • I am not sure about the organisation of logic here, e.g FromBinary, orphans, etc

@Anviking Anviking self-assigned this May 23, 2019
@KtorZ
Copy link
Member

KtorZ commented May 23, 2019

@Anviking Think about spreading the work over multiple PRs here. You don't have to implement all the endpoint at once. Start with one, and go incrementally 🙏

@Anviking Anviking force-pushed the anviking/219/jörmungandr-network branch 2 times, most recently from 15c4cac to 8f89736 Compare May 23, 2019 23:53
@Anviking Anviking changed the title Add a Jörmungandr NetworkLayer Add Jörmungandr Servant Api Type May 24, 2019
@Anviking Anviking marked this pull request as ready for review May 24, 2019 00:09
@Anviking Anviking force-pushed the anviking/219/jörmungandr-network branch 4 times, most recently from 0472d86 to b65b5f4 Compare May 24, 2019 11:54
data BlockHeader = BlockHeader
{ version :: Word16
, contentSize :: Word32
, slot :: SlotId
, chainLength :: Word32
, contentHash :: Hash "content"
, parentHeaderHash :: Hash "parentHeader"
, parentHeaderHash :: Hash "BlockHeader"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To match with the one in Cardano.Primitive.Types (BlockHeader)

instance FromBinary Block where
get = getBlock

instance FromBinary W.Block where
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The Block type in this module contain more information than the one in Cardano.Wallet.Primitive.Types (W.Block).

-- TODO: Replace SignedTx with something real
data SignedTx

newtype BlockId = BlockId (Hash "block")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could also have ApiT, but the jörmungandr api use the term "BlockId" which this newtype can capture.

@Anviking Anviking requested review from KtorZ and akegalj May 24, 2019 12:09
@Anviking Anviking force-pushed the anviking/219/jörmungandr-network branch from b65b5f4 to e92b8e8 Compare May 24, 2019 12:13
:> "block"
:> Capture "blockId" BlockId
:> QueryParam "count" Int
:> Get '[OctetStream] [BlockId]
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure OctetStream is the best fit here. We actually know the format of the API we're talking to. So it's not just plain bytes. I'd suggest to define some custom format like Jormungandr or BetterCBOR or any name that fits to describe the format, and makes it clear that we're still expecting things in a particular format (whereas OctetStream conveys the idea of a stream of bytes without any particular structure).

This will also prevent the orphan 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍

@Anviking Anviking force-pushed the anviking/219/jörmungandr-network branch 4 times, most recently from c78975a to 5793f43 Compare May 24, 2019 17:53
@Anviking Anviking requested a review from KtorZ May 24, 2019 18:01
- Servant type in the .Api module, with Plain and Binary content types.
- I added a FromBinary class in the binary module to play nicely with the Binary content-type
@KtorZ KtorZ force-pushed the anviking/219/jörmungandr-network branch from 5793f43 to 586c722 Compare May 27, 2019 08:30
@KtorZ KtorZ merged commit 91c61a4 into master May 27, 2019
@KtorZ KtorZ mentioned this pull request May 27, 2019
12 tasks
@Anviking Anviking deleted the anviking/219/jörmungandr-network branch May 27, 2019 13:57
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.

None yet

2 participants