From a73c2c4659631d5b75590053369ef64b217abd17 Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Wed, 19 Jul 2023 20:52:13 +0300 Subject: [PATCH] wip, log merging, debug-20 --- hbs2-core/lib/HBS2/Net/Proto/RefChan.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/hbs2-core/lib/HBS2/Net/Proto/RefChan.hs b/hbs2-core/lib/HBS2/Net/Proto/RefChan.hs index bcbed321..1d1e4545 100644 --- a/hbs2-core/lib/HBS2/Net/Proto/RefChan.hs +++ b/hbs2-core/lib/HBS2/Net/Proto/RefChan.hs @@ -427,16 +427,22 @@ refChanUpdateProto self pc adapter msg = do let toWait = TimeoutSec (fromIntegral $ 2 * view refChanHeadWaitAccept headBlock) let ttl = ts + fromNanoSecs (fromIntegral $ toNanoSeconds toWait) - defRound <- RefChanRound @e (HashRef hash) refchanKey ttl - <$> newTVarIO False - <*> newTVarIO Nothing - <*> newTVarIO (HashSet.singleton (HashRef hash)) -- save propose - <*> newTVarIO (HashMap.singleton peerKey ()) let rcrk = RefChanRoundKey (HashRef hash) - void $ lift $ update defRound rcrk id - lift $ emit @e RefChanRoundEventKey (RefChanRoundEvent rcrk) + rndHere <- lift $ find rcrk id + + unless (isJust rndHere) do + + defRound <- RefChanRound @e (HashRef hash) refchanKey ttl + <$> newTVarIO False + <*> newTVarIO Nothing + <*> newTVarIO (HashSet.singleton (HashRef hash)) -- save propose + <*> newTVarIO (HashMap.singleton peerKey ()) + + lift $ update defRound rcrk id + + lift $ emit @e RefChanRoundEventKey (RefChanRoundEvent rcrk) lift $ gossip msg