Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ data NodeToClientVersion
| NodeToClientV_23
-- ^ added @QueryDRepsDelegations@,
-- LedgerPeerSnapshot CBOR encoding contains block hash and NetworkMagic
| NodeToClientV_24
-- ^ added @ValidateTx@ query
deriving (Eq, Ord, Enum, Bounded, Show, Generic, NFData)

-- | We set 16ths bit to distinguish `NodeToNodeVersion` and
Expand All @@ -84,6 +86,7 @@ nodeToClientVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm }
NodeToClientV_21 -> enc 21
NodeToClientV_22 -> enc 22
NodeToClientV_23 -> enc 23
NodeToClientV_24 -> enc 24
where
enc :: Int -> CBOR.Term
enc = CBOR.TInt . (`setBit` nodeToClientVersionBit)
Expand All @@ -98,6 +101,7 @@ nodeToClientVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm }
21 -> Right NodeToClientV_21
22 -> Right NodeToClientV_22
23 -> Right NodeToClientV_23
24 -> Right NodeToClientV_24
n -> Left (unknownTag n)
where
dec :: CBOR.Term -> Either (Text, Maybe Int) Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ instance FromJSON NodeToClientVersion where
Number 21 -> pure NodeToClientV_21
Number 22 -> pure NodeToClientV_22
Number 23 -> pure NodeToClientV_23
Number 24 -> pure NodeToClientV_24
Number x -> fail $ "FromJSON.NodeToClientVersion: unsupported node-to-client protocol version " ++ show x
x -> fail $ "FromJSON.NodeToClientVersion: error parsing NodeToClientVersion: " ++ show x

Expand All @@ -92,6 +93,7 @@ instance ToJSON NodeToClientVersion where
NodeToClientV_21 -> Number 21
NodeToClientV_22 -> Number 22
NodeToClientV_23 -> Number 23
NodeToClientV_24 -> Number 24

instance ToJSON NodeToNodeVersionData where
toJSON (NodeToNodeVersionData (NetworkMagic m) dm ps q) = object
Expand Down