mirror of https://github.com/voidlizard/hbs2
okay...
This commit is contained in:
parent
1893123ccb
commit
9a497efea4
|
@ -134,6 +134,7 @@ getHash :: forall salt h m .
|
|||
( Hashable salt
|
||||
, Hashed h ByteString
|
||||
, MonadIO m
|
||||
, Block ByteString ~ ByteString
|
||||
, Pretty (Hash h)
|
||||
)
|
||||
=> ChunkWriter h m
|
||||
|
|
|
@ -338,12 +338,10 @@ instance ( HasProtocol e p
|
|||
thatPeer _ = asks (view answTo)
|
||||
|
||||
deferred _ action = do
|
||||
me <- lift $ ownPeer @e
|
||||
who <- asks (view answTo)
|
||||
fab <- lift $ getFabriq @e
|
||||
pip <- lift $ asks (view envDeferred)
|
||||
ss <- lift getStorage
|
||||
liftIO $ addJob pip $ runPeerM ss fab me (runResponseM who action)
|
||||
env <- lift ask
|
||||
liftIO $ addJob pip $ withPeerM env (runResponseM who action)
|
||||
|
||||
response msg = do
|
||||
let proto = protoId @e @p (Proxy @p)
|
||||
|
|
|
@ -178,10 +178,6 @@ blockDownloadLoop = do
|
|||
|
||||
debug $ "subscribing to" <+> pretty h
|
||||
|
||||
-- let wtf1 = newSKey (BlockChunksEventKey h)
|
||||
|
||||
-- emit @e (BlockChunksEventKey (head blks)) (BlockReady (head blks))
|
||||
|
||||
subscribe @e (BlockChunksEventKey h) $ \(BlockReady _) -> do
|
||||
debug $ "GOT BLOCK!" <+> pretty h
|
||||
pure ()
|
||||
|
@ -203,8 +199,6 @@ blockDownloadLoop = do
|
|||
fix \next -> do
|
||||
liftIO $ print "piu!"
|
||||
|
||||
-- emit @e (BlockChunksEventKey (head blks)) (BlockReady (head blks))
|
||||
|
||||
pause ( 0.85 :: Timeout 'Seconds )
|
||||
next
|
||||
|
||||
|
@ -265,16 +259,7 @@ mkAdapter cww = do
|
|||
&& written >= mbSize
|
||||
|
||||
when mbDone $ lift do
|
||||
emit @e @(BlockChunks e) (BlockChunksEventKey h) (BlockReady h)
|
||||
|
||||
-- ВОТ ЖЕ БЛЯДЬ! СЧИТАТЬ ХЭШ ДОЛГО.
|
||||
-- ЗАМОРОЗИМСЯ ЗДЕСЬ.
|
||||
--
|
||||
-- ЕСЛИ СОБЫТИЕ ПОШЛЁМ РАНЬЕ -- ОНО ПРИШЛО,
|
||||
-- А БЛОКА НЕТ
|
||||
--
|
||||
-- А ПОШЛЁМ ИЗ DEFERRED - ТИП БУДЕТ ДРУГОЙ
|
||||
-- СУКА!
|
||||
deferred (Proxy @(BlockChunks e)) $ do
|
||||
h1 <- liftIO $ getHash cww cKey h
|
||||
|
||||
|
@ -284,11 +269,7 @@ mkAdapter cww = do
|
|||
when ( h1 == h ) $ do
|
||||
liftIO $ commitBlock cww cKey h
|
||||
expire cKey
|
||||
-- WTF!! THIS IS A DIFFERENT MONAD FROM OUTSIDE,
|
||||
-- SO EVENTS EMITTED HERE WILL HAVE ANOTHER
|
||||
-- TYPE SIGNATURES AND WILL NOT BE DECODED
|
||||
-- WHEREVER THEIR ARE LISTENED
|
||||
-- HOLY SHIT
|
||||
emit @e (BlockChunksEventKey h) (BlockReady h)
|
||||
|
||||
when (written > mbSize * defBlockDownloadThreshold) $ do
|
||||
debug $ "SESSION DELETED BECAUSE THAT PEER IS JERK:" <+> pretty p
|
||||
|
|
Loading…
Reference in New Issue