@@ -11,8 +11,9 @@ import Cardano.Api
1111import Cardano.Rpc.Proto.Api.UtxoRpc.Sync qualified as U5c
1212import Cardano.Rpc.Server.Internal.Error
1313import Cardano.Rpc.Server.Internal.Monad
14- import Cardano.Rpc.Server.Internal.NodeKernelAccess
1514import Cardano.Rpc.Server.Internal.Tracing ()
15+ import Cardano.Rpc.Server.NodeKernelAccess
16+ import Cardano.Rpc.Server.NodeKernelAccess.Internal
1617
1718import RIO
1819
@@ -25,17 +26,12 @@ fetchBlockMethod
2526 => Proto U5c. FetchBlockRequest
2627 -> m (Proto U5c. FetchBlockResponse )
2728fetchBlockMethod request = do
28- nodeKernelAccessRef <- grab -- @(IORef (Maybe (NodeKernelAccess m)))
29+ nodeKernelAccessRef <- grab
2930 let blockRefs = request ^. U5c. ref
30- liftIO $ withNodeKernelAccess nodeKernelAccessRef $ \ nodeKernelAccess -> do
31+ withNodeKernelAccess nodeKernelAccessRef $ \ nodeKernelAccess -> do
3132 blocks <- mapM (fetchOne nodeKernelAccess) blockRefs
3233 pure $ defMessage & U5c. block .~ blocks
3334 where
34- fetchOne
35- :: MonadRpc e m
36- => NodeKernelAccess m
37- -> Proto U5c. BlockRef
38- -> m (Proto U5c. AnyChainBlock )
3935 fetchOne nodeKernelAccess blockRef = do
4036 let slot = SlotNo $ blockRef ^. U5c. slot
4137 hashBytes = blockRef ^. U5c. hash
@@ -50,4 +46,10 @@ fetchBlockMethod request = do
5046 Nothing ->
5147 throwGrpcErrorWithMessage GrpcNotFound $
5248 " block not found at slot " <> tshow (unSlotNo slot)
53- Just rawBytes -> pure $ defMessage & U5c. nativeBytes .~ rawBytes
49+ Just (rawBytes, BlockNo height) ->
50+ pure $
51+ defMessage
52+ & U5c. nativeBytes .~ rawBytes
53+ & U5c. cardano . U5c. header . U5c. slot .~ unSlotNo slot
54+ & U5c. cardano . U5c. header . U5c. hash .~ hashBytes
55+ & U5c. cardano . U5c. header . U5c. height .~ height
0 commit comments