mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
c0356439d2
commit
8f1b59b0a0
|
@ -35,10 +35,10 @@ data GitRepoRefFact =
|
|||
|
||||
data GitRepoHeadFact =
|
||||
GitRepoHeadFact1
|
||||
{ gitRepoName :: Text
|
||||
{ gitRepoHeadRef :: HashRef
|
||||
, gitRepoName :: Text
|
||||
, gitRepoBrief :: Text
|
||||
, gitRepoEncrypted :: Bool
|
||||
, gitRepoHeadRef :: HashRef
|
||||
}
|
||||
deriving stock (Generic)
|
||||
|
||||
|
@ -48,14 +48,23 @@ data GitRepoFacts =
|
|||
| GitRepoHeadFact HashRef GitRepoHeadFact
|
||||
deriving stock (Generic)
|
||||
|
||||
|
||||
instance Serialise GitRepoRefFact
|
||||
instance Serialise GitRepoHeadFact
|
||||
instance Serialise GitRepoFacts
|
||||
|
||||
instance Pretty GitRepoFacts where
|
||||
pretty (GitRepoRefFact x) = pretty x
|
||||
pretty (GitRepoHeadFact _ x) = pretty x
|
||||
|
||||
instance Pretty GitRepoRefFact where
|
||||
pretty (GitRepoFact1{..}) =
|
||||
parens ( "gitrepofact1" <+> hsep [pretty gitLwwRef, pretty gitLwwSeq, pretty gitRefLog])
|
||||
|
||||
instance Pretty GitRepoHeadFact where
|
||||
pretty (GitRepoHeadFact1{..}) =
|
||||
parens ( "gitrepoheadfact1" <+> hsep [pretty gitRepoHeadRef])
|
||||
|
||||
|
||||
runOracle :: forall m . MonadUnliftIO m => Oracle m ()
|
||||
runOracle = do
|
||||
|
@ -80,12 +89,14 @@ runOracle = do
|
|||
(lwwSeq lw)
|
||||
(RefLogKey rk)
|
||||
|
||||
facts <- S.toList_ do
|
||||
|
||||
for_ repos $ \what@GitRepoFact1{..} -> do
|
||||
|
||||
mhead <- callRpcWaitMay @RpcRefLogGet (TimeoutSec 1) reflog (coerce gitRefLog)
|
||||
mhead <- lift $ callRpcWaitMay @RpcRefLogGet (TimeoutSec 1) reflog (coerce gitRefLog)
|
||||
<&> join
|
||||
|
||||
forM_ mhead $ \mh -> do
|
||||
for_ mhead $ \mh -> do
|
||||
|
||||
txs <- S.toList_ $ do
|
||||
walkMerkle @[HashRef] (fromHashRef mh) (getBlock sto) $ \case
|
||||
|
@ -102,16 +113,11 @@ runOracle = do
|
|||
|
||||
let tx' = maximumByMay (comparing fst) txs
|
||||
|
||||
headFact <- forM tx' $ \(n,tx) -> void $ runMaybeT do
|
||||
for_ tx' $ \(n,tx) -> void $ runMaybeT do
|
||||
|
||||
(rhh,RepoHeadSimple{..}) <- readRepoHeadFromTx sto tx
|
||||
>>= toMPlus
|
||||
|
||||
let enc = isJust _repoHeadGK0
|
||||
let name = Text.take 256 $ _repoHeadName
|
||||
let brief = Text.take 1024 $ _repoHeadBrief
|
||||
let manifest = _repoManifest
|
||||
|
||||
debug $ "found head"
|
||||
<+> pretty enc
|
||||
<+> pretty n
|
||||
|
@ -125,22 +131,18 @@ runOracle = do
|
|||
<> line
|
||||
<> line
|
||||
|
||||
let repoFactHash = hashObject @HbSync (serialise what) & HashRef
|
||||
|
||||
let f1 = GitRepoRefFact what
|
||||
let f2 = GitRepoHeadFact
|
||||
repoFactHash
|
||||
(GitRepoHeadFact1 name brief enc undefined
|
||||
)
|
||||
(GitRepoHeadFact1 rhh name brief enc)
|
||||
|
||||
pure undefined
|
||||
lift $ S.yield f1
|
||||
lift $ S.yield f2
|
||||
|
||||
for_ facts $ \f -> do
|
||||
debug $ pretty f
|
||||
pure ()
|
||||
-- debug $ "found head"
|
||||
-- <+> pretty gitLwwRef
|
||||
-- <+> pretty n
|
||||
-- <+> pretty enc
|
||||
-- <+> pretty gitRefLog
|
||||
-- <+> pretty name
|
||||
-- <+> pretty brief
|
||||
-- <+> pretty manifest
|
||||
-- <+> pretty tx
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue