From deb0673d8b559f6e361492442fc3804031dff32e Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Thu, 19 Sep 2024 07:22:19 +0300 Subject: [PATCH] wip --- fixme-new/lib/Fixme/Run/Internal.hs | 18 +++++++++++++----- fixme-new/lib/Fixme/State.hs | 2 +- .../HBS2/Peer/Proto/RefChan/RefChanUpdate.hs | 3 +++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fixme-new/lib/Fixme/Run/Internal.hs b/fixme-new/lib/Fixme/Run/Internal.hs index 4f720d86..23f54459 100644 --- a/fixme-new/lib/Fixme/Run/Internal.hs +++ b/fixme-new/lib/Fixme/Run/Internal.hs @@ -467,13 +467,18 @@ refchanExport opts = do gk0 <- loadGroupKey + -- TODO: this-may-cause-to-tx-flood + -- сделать какой-то период релакса, + -- что ли + now <- liftIO $ getPOSIXTime <&> round + withState do - what <- select_ @_ @FixmeExported [qc| - select distinct o,w,k,cast (v as text) + what <- select @FixmeExported [qc| + select distinct o,?,k,cast (v as text) from object obj where not exists (select null from scanned where hash = obj.nonce) order by o, k, v, w - |] + |] (Only now) let chu = chunksOf 10000 what @@ -578,7 +583,10 @@ refchanImport = do tq <- newTQueueIO - let goodToGo x = do + ignCached <- asks fixmeEnvFlags >>= readTVarIO <&> HS.member FixmeIgnoreCached + + let goodToGo x | ignCached = pure True + | otherwise = do here <- selectIsAlreadyScanned x pure $ not here @@ -605,7 +613,7 @@ refchanImport = do scanned <- lift $ selectIsAlreadyScanned href - unless scanned do + when (not scanned || ignCached) do -- check if metadata tx meta <- runExceptT (extractMetaData @'HBS2Basic (const $ pure Nothing) sto href) diff --git a/fixme-new/lib/Fixme/State.hs b/fixme-new/lib/Fixme/State.hs index ead1514e..b5719fd1 100644 --- a/fixme-new/lib/Fixme/State.hs +++ b/fixme-new/lib/Fixme/State.hs @@ -404,7 +404,7 @@ insertFixme fme = do when excluded.w > object.w and (excluded.v <> object.v) then excluded.w else object.w end, - nonce = case when excluded.w > object.w and (excluded.v <> object.v) then null + nonce = case when excluded.w > object.w and (excluded.v <> object.v) then excluded.nonce else object.nonce end |] diff --git a/hbs2-peer/lib/HBS2/Peer/Proto/RefChan/RefChanUpdate.hs b/hbs2-peer/lib/HBS2/Peer/Proto/RefChan/RefChanUpdate.hs index 2801b941..b6d8cfb6 100644 --- a/hbs2-peer/lib/HBS2/Peer/Proto/RefChan/RefChanUpdate.hs +++ b/hbs2-peer/lib/HBS2/Peer/Proto/RefChan/RefChanUpdate.hs @@ -267,6 +267,9 @@ refChanUpdateProto self pc adapter msg = do guard =<< lift (refChanSubscribed adapter (getRefChanId msg)) let h0 = hashObject @HbSync (serialise msg) + + debug $ "RefchanUpdate: ALREADY" <+> pretty h0 + guard =<< liftIO (hasBlock sto h0 <&> isNothing) case msg of