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