wip, log merging, debug-16

This commit is contained in:
Dmitry Zuikov 2023-07-19 20:14:55 +03:00
parent 88b4d929eb
commit 796a5a6f54
2 changed files with 5 additions and 3 deletions

View File

@ -443,7 +443,7 @@ refChanUpdateProto self pc adapter msg = do
-- FIXME: random-delay-to-avoid-race -- FIXME: random-delay-to-avoid-race
-- выглядит не очень хорошо, 100ms -- выглядит не очень хорошо, 100ms
-- и не гарантирует от гонок -- и не гарантирует от гонок
pause @'Seconds 0.10 pause @'Seconds 0.25
-- FIXME: check-if-we-authorized -- FIXME: check-if-we-authorized
-- проверить, что мы вообще авторизованы -- проверить, что мы вообще авторизованы
@ -520,6 +520,7 @@ refChanUpdateProto self pc adapter msg = do
ha <- MaybeT $ liftIO $ putBlock sto (serialise msg) ha <- MaybeT $ liftIO $ putBlock sto (serialise msg)
atomically $ modifyTVar (view refChanRoundTrans rcRound) (HashSet.insert (HashRef ha)) atomically $ modifyTVar (view refChanRoundTrans rcRound) (HashSet.insert (HashRef ha))
atomically $ modifyTVar (view refChanRoundTrans rcRound) (HashSet.insert hashRef) -- propose just in case we missed it?
accepts <- atomically $ readTVar (view refChanRoundAccepts rcRound) <&> HashMap.size accepts <- atomically $ readTVar (view refChanRoundAccepts rcRound) <&> HashMap.size
@ -535,12 +536,13 @@ refChanUpdateProto self pc adapter msg = do
forM_ trans $ \t -> do forM_ trans $ \t -> do
lift $ refChanWriteTran adapter t lift $ refChanWriteTran adapter t
debug $ "WRITING TRANS" <+> pretty t
let pips = view refChanHeadPeers headBlock & HashMap.keys & HashSet.fromList let pips = view refChanHeadPeers headBlock & HashMap.keys & HashSet.fromList
votes <- readTVarIO (view refChanRoundAccepts rcRound) <&> HashSet.fromList . HashMap.keys votes <- readTVarIO (view refChanRoundAccepts rcRound) <&> HashSet.fromList . HashMap.keys
when (pips `HashSet.isSubsetOf` votes) do when (pips `HashSet.isSubsetOf` votes) do
debug $ "CLOSING ROUND" <+> pretty hashRef debug $ "CLOSING ROUND" <+> pretty hashRef <+> pretty (length trans)
atomically $ writeTVar (view refChanRoundClosed rcRound) True atomically $ writeTVar (view refChanRoundClosed rcRound) True
where where

View File

@ -217,7 +217,7 @@ refChanWorker env brains = do
debug $ "ON ROUND STARTED" <+> pretty rcrk debug $ "ON ROUND STARTED" <+> pretty rcrk
forever do forever do
pause @'Seconds 30 pause @'Seconds 60
now <- getTimeCoarse now <- getTimeCoarse
xs <- readTVarIO rounds <&> HashSet.toList xs <- readTVarIO rounds <&> HashSet.toList