From 069bc1ef28927ec26c7a253e93d07e5c5e85b33f Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Sun, 22 Jan 2023 13:11:33 +0300 Subject: [PATCH] debugging --- hbs2-tests/test/Peer2Main.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hbs2-tests/test/Peer2Main.hs b/hbs2-tests/test/Peer2Main.hs index c77e0230..76f8a86f 100644 --- a/hbs2-tests/test/Peer2Main.hs +++ b/hbs2-tests/test/Peer2Main.hs @@ -80,6 +80,9 @@ instance HasProtocol Fake (BlockSize Fake) where instance Expires (EventKey Fake (BlockSize Fake)) where expiresIn _ = 3 +instance Expires (EventKey Fake (BlockChunks Fake)) where + expiresIn _ = 10 + instance HasProtocol Fake (BlockChunks Fake) where type instance ProtocolId (BlockChunks Fake) = 2 type instance Encoded Fake = ByteString @@ -157,6 +160,7 @@ blockDownloadLoop :: forall e . ( HasProtocol e (BlockSize e) , Request e (BlockSize e) (PeerM e IO) , Request e (BlockChunks e) (PeerM e IO) , EventListener e (BlockSize e) (PeerM e IO) + , EventListener e (BlockChunks e) (PeerM e IO) , Sessions e (BlockSize e) (PeerM e IO) , Sessions e (BlockChunks e) (PeerM e IO) , Num (Peer e) @@ -173,6 +177,10 @@ blockDownloadLoop = do debug $ "subscribing to" <+> pretty h + subscribe @e (BlockChunksEventKey h) $ \(BlockReady _) -> do + debug $ "GOT BLOCK!" <+> pretty h + pure () + subscribe @e @(BlockSize e) (BlockSizeEventKey h) $ \(BlockSizeEvent (p,h,s)) -> do debug $ "can't believe this shit works" <+> pretty h coo <- genCookie (p,h) @@ -260,6 +268,7 @@ mkAdapter cww = do liftIO $ commitBlock cww cKey h expire cKey debug $ "BLOCK IS READY" <+> pretty h + emit @e (BlockChunksEventKey h) (BlockReady h) -- FIXME: return this event! -- lift $ runEngineM env $ emitBlockReadyEvent ev h -- TODO: fix this crazy shit