Skip to content

Commit

Permalink
Merge #3619
Browse files Browse the repository at this point in the history
3619: Add IsString (Hash BlockHeader) r=andreabedini a=andreabedini

This PR adds the instance IsString (Hash BlockHeader) following the same
pattern of many other keys in Cardano.Api. The use case is simple, being
able to refer to a specific point on the chain.

E.g.

recentPoint :: ChainPoint
recentPoint = ChainPoint (SlotNo 53427524) "5e2bde4e504a9888a4..."

I am also changing the Show instance, as it seems to be the common
pattern.


Co-authored-by: Andrea Bedini <andrea@andreabedini.com>
  • Loading branch information
iohk-bors[bot] and andreabedini authored Mar 9, 2022
2 parents bf8b0e1 + 9c34646 commit 2c32629
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cardano-api/src/Cardano/Api/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import qualified Data.Aeson as Aeson
import qualified Data.ByteString as BS
import qualified Data.ByteString.Short as SBS
import Data.Foldable (Foldable (toList))
import Data.String (IsString)

import Cardano.Slotting.Block (BlockNo)
import Cardano.Slotting.Slot (EpochNo, SlotNo, WithOrigin (..))
Expand Down Expand Up @@ -259,6 +260,7 @@ data BlockHeader = BlockHeader !SlotNo
newtype instance Hash BlockHeader = HeaderHash SBS.ShortByteString
deriving (Eq, Ord, Show)
deriving (ToJSON, FromJSON) via UsingRawBytesHex (Hash BlockHeader)
deriving IsString via UsingRawBytesHex (Hash BlockHeader)



Expand Down

0 comments on commit 2c32629

Please sign in to comment.