diff --git a/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/Export.hs b/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/Export.hs index f2526c39..e9a2e69d 100644 --- a/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/Export.hs +++ b/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/Export.hs @@ -160,13 +160,17 @@ export key refs = do reflog <- asks _refLogAPI ip <- asks _progress + subscribeLWWRef key + lww@LWWBlockData{..} <- waitOrInitLWWRef + let puk0 = fromLwwRefKey key + debug $ red $ pretty $ AsBase58 lwwRefLogPubKey (sk0,pk0) <- liftIO $ runKeymanClient do - creds <- loadCredentials lwwRefLogPubKey - >>= orThrowUser "can't load credentials" + creds <- loadCredentials puk0 + >>= orThrowUser ("can't load credentials" <+> pretty (AsBase58 puk0)) pure ( view peerSignSk creds, view peerSignPk creds ) (puk,sk) <- derivedKey @HBS2Basic @'Sign lwwRefSeed sk0 diff --git a/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/Import.hs b/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/Import.hs index 348227d8..c2b3734e 100644 --- a/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/Import.hs +++ b/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/Import.hs @@ -72,6 +72,8 @@ importRepoWait lwwKey = do meet <- newTVarIO (mempty :: HashMap HashRef Int) + subscribeLWWRef lwwKey + flip fix (IWaitLWWBlock 20) $ \next -> \case IWaitLWWBlock w | w <= 0 -> do @@ -86,9 +88,8 @@ importRepoWait lwwKey = do pause @'Seconds 2 next (IWaitLWWBlock (pred w)) - Just blk -> do - error "FOUND SHIT!" - pure () + Just (LWWBlockData{..}) -> do + next (IWaitRefLog 20 lwwRefLogPubKey) IWaitRefLog w puk | w <= 0 -> do throwIO ImportRefLogNotFound diff --git a/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/RefLog.hs b/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/RefLog.hs index 94689362..98ede6a8 100644 --- a/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/RefLog.hs +++ b/hbs21-git/hbs2-git-client-lib/HBS2/Git/Client/RefLog.hs @@ -3,6 +3,7 @@ module HBS2.Git.Client.RefLog where import HBS2.Git.Client.Prelude import HBS2.Git.Client.App.Types import HBS2.Git.Data.RefLog +import HBS2.Git.Data.LWWBlock data RefLogRequestTimeout = RefLogRequestTimeout deriving (Show,Typeable) @@ -20,6 +21,11 @@ subscribeRefLog puk = do void $ callService @RpcPollAdd api (puk, "reflog", 13) +subscribeLWWRef :: (GitPerks m, MonadReader GitEnv m) => LWWRefKey HBS2Basic -> m () +subscribeLWWRef puk = do + api <- asks _peerAPI + void $ callService @RpcPollAdd api (fromLwwRefKey puk, "lwwref", 17) + getRefLogMerkle :: (GitPerks m, MonadReader GitEnv m) => RefLogId -> m (Maybe HashRef) getRefLogMerkle puk = do