Skip to content
Permalink
Browse files

Remove BlockId for getDescendants

  • Loading branch information...
Anviking committed Jun 12, 2019
1 parent 2fdacde commit b01eca7d5a81fe2e57ee7961dd2061719ae89d52
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/jormungandr/src/Cardano/Wallet/Jormungandr/Network.hs
@@ -114,7 +114,9 @@ data JormungandrLayer m = JormungandrLayer
, getBlock
:: Hash "BlockHeader" -> ExceptT ErrGetBlock m Block
, getDescendantIds
:: BlockId -> Word -> ExceptT ErrGetDescendants m [BlockId]
:: Hash "BlockHeader"
-> Word
-> ExceptT ErrGetDescendants m [Hash "BlockHeader"]
}

-- | Construct a 'JormungandrLayer'-client
@@ -152,14 +154,14 @@ mkJormungandrLayer mgr baseUrl = JormungandrLayer
left ErrGetBlockNetworkUnreachable <$> defaultHandler ctx x

, getDescendantIds = \parentId count -> ExceptT $ do
run (cGetBlockDescendantIds parentId (Just count)) >>= \case
run (map getBlockId <$> cGetBlockDescendantIds (BlockId parentId) (Just count)) >>= \case
Left (FailureResponse e) | responseStatusCode e == status404 ->
return . Left $ ErrGetDescendantsParentNotFound parentId
x -> do
let ctx = safeLink
api
(Proxy @GetBlockDescendantIds)
parentId
(BlockId parentId)
(Just count)
left ErrGetDescendantsNetworkUnreachable <$> defaultHandler ctx x
}
@@ -198,5 +200,5 @@ instance Exception ErrUnexpectedNetworkFailure

data ErrGetDescendants
= ErrGetDescendantsNetworkUnreachable ErrNetworkUnreachable
| ErrGetDescendantsParentNotFound BlockId
| ErrGetDescendantsParentNotFound (Hash "BlockHeader")
deriving (Show, Eq)

0 comments on commit b01eca7

Please sign in to comment.
You can’t perform that action at this time.