mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
ba7cc35bbc
commit
e405142b8c
|
@ -39,6 +39,7 @@ commands =
|
|||
hsubparser ( command "export" (info pExport (progDesc "export repo to hbs2-git"))
|
||||
<> command "import" (info pImport (progDesc "import repo from reflog"))
|
||||
<> command "key" (info pKey (progDesc "key management"))
|
||||
<> command "track" (info pTrack (progDesc "track tools"))
|
||||
<> command "tools" (info pTools (progDesc "misc tools"))
|
||||
)
|
||||
|
||||
|
@ -46,6 +47,8 @@ commands =
|
|||
pRefLogId :: ReadM RefLogId
|
||||
pRefLogId = maybeReader (fromStringMay @RefLogId)
|
||||
|
||||
pRefChanId :: ReadM GitRefChanId
|
||||
pRefChanId = maybeReader (fromStringMay @GitRefChanId)
|
||||
|
||||
pLwwKey :: ReadM (LWWRefKey 'HBS2Basic)
|
||||
pLwwKey = maybeReader fromStringMay
|
||||
|
@ -205,6 +208,18 @@ pKeyUpdate = do
|
|||
Nothing -> liftIO $ putStrLn "not added" >> exitFailure
|
||||
Just x -> liftIO $ print $ pretty x
|
||||
|
||||
|
||||
pTrack :: GitPerks m => Parser (GitCLI m ())
|
||||
pTrack = hsubparser ( command "send-repo-notify" (info pSendRepoNotify (progDesc "sends repository notification"))
|
||||
)
|
||||
|
||||
pSendRepoNotify :: GitPerks m => Parser (GitCLI m ())
|
||||
pSendRepoNotify = do
|
||||
notifyChan <- argument pRefChanId (metavar "CHANNEL-KEY")
|
||||
pure do
|
||||
notice "JOPA"
|
||||
pure ()
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
(o, action) <- customExecParser (prefs showHelpOnError) $
|
||||
|
|
|
@ -17,6 +17,7 @@ module HBS2.Git.Client.Prelude
|
|||
, module HBS2.Peer.Proto.LWWRef
|
||||
, module HBS2.Peer.RPC.API.Peer
|
||||
, module HBS2.Peer.RPC.API.RefLog
|
||||
, module HBS2.Peer.RPC.API.RefChan
|
||||
, module HBS2.Peer.RPC.API.LWWRef
|
||||
, module HBS2.Peer.RPC.API.Storage
|
||||
, module HBS2.Peer.RPC.Client.StorageClient
|
||||
|
@ -33,6 +34,7 @@ module HBS2.Git.Client.Prelude
|
|||
, getSocketName
|
||||
, formatRef
|
||||
, deserialiseOrFail
|
||||
, GitRefChanId
|
||||
) where
|
||||
|
||||
import HBS2.Prelude.Plated hiding (at)
|
||||
|
@ -56,6 +58,7 @@ import HBS2.Net.Proto.Service
|
|||
import HBS2.Peer.Proto.LWWRef
|
||||
import HBS2.Peer.RPC.API.Peer
|
||||
import HBS2.Peer.RPC.API.RefLog
|
||||
import HBS2.Peer.RPC.API.RefChan
|
||||
import HBS2.Peer.RPC.API.LWWRef
|
||||
import HBS2.Peer.RPC.API.Storage
|
||||
import HBS2.Peer.RPC.Client.StorageClient
|
||||
|
@ -73,6 +76,9 @@ import System.Process.Typed
|
|||
import Lens.Micro.Platform
|
||||
import Codec.Serialise
|
||||
|
||||
-- FIXME: subject-to-change-signature
|
||||
type GitRefChanId = RefChanId L4Proto
|
||||
|
||||
data RPCNotFoundError = RPCNotFoundError
|
||||
deriving stock (Show,Typeable)
|
||||
|
||||
|
|
|
@ -161,6 +161,15 @@ makeTx sto rewrite r puk findSk rh prev lbss = do
|
|||
|
||||
let meRef = HashRef me
|
||||
|
||||
-- FIXME: ASAP-race-condition-on-seq-ref
|
||||
-- При разборе транзакции, если по какой-то причине
|
||||
-- голова сразу не подъезжает, то не подъедет уже никогда,
|
||||
-- и бранчи не приедут (Import).
|
||||
--
|
||||
-- Возможные решения: запатчить процедуру импорта (1)
|
||||
-- Добавить ссылкун а RepoHead в блок, где приезжают
|
||||
-- пулы
|
||||
|
||||
-- TODO: post-real-rank-for-tx
|
||||
let tx = SequentialRef r (AnnotatedHashRef (Just headRef) meRef)
|
||||
& serialise
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{-# Language UndecidableInstances #-}
|
||||
{-# Language AllowAmbiguousTypes #-}
|
||||
module HBS2.Git.Data.Tx.Index where
|
||||
|
||||
import HBS2.Git.Client.Prelude
|
||||
|
@ -6,7 +7,8 @@ import HBS2.Data.Types.Refs
|
|||
import HBS2.Data.Types.SignedBox
|
||||
|
||||
import Data.ByteString (ByteString)
|
||||
|
||||
import Data.ByteString.Lazy qualified as LBS
|
||||
import Data.Coerce
|
||||
|
||||
-- |
|
||||
-- Module : HBS2.Git.Data.Tx.Index
|
||||
|
@ -43,21 +45,27 @@ instance ForGitIndex s => Serialise (GitRepoAnnounce s)
|
|||
|
||||
|
||||
data NotifyCredentials s =
|
||||
NotifyCredentials (PubKey 'Sign s) (PrivKey 'Sign s)
|
||||
|
||||
data RepoCredentials s =
|
||||
RepoCredentials
|
||||
{ rcPubKey :: PubKey 'Sign s
|
||||
, rcSeckey :: PrivKey 'Sign s
|
||||
NotifyCredentials
|
||||
{ notifyPk :: PubKey 'Sign s
|
||||
, notifySk :: PrivKey 'Sign s
|
||||
}
|
||||
|
||||
-- | makes notification tx
|
||||
-- | it is signed by lwwref private key in order to proove authorship
|
||||
-- | and signed with published notification private key in order
|
||||
-- | to publish tx via rpc
|
||||
makeNotificationTx :: forall s m . (Monad m, ForGitIndex s)
|
||||
=> NotifyCredentials s
|
||||
-> RepoCredentials s
|
||||
-> LWWRefKey s
|
||||
-> ( PubKey 'Sign s -> m (Maybe (PrivKey 'Sign s) ) )
|
||||
-> Maybe (RepoForkInfo s)
|
||||
-> m ByteString
|
||||
makeNotificationTx ncred repocred forkInfo = do
|
||||
-- makeSignedBox @e (LBS.toStrict $ serialise tx)
|
||||
let annData = GitRepoAnnounceData @s (LWWRefKey $ rcPubKey repocred)
|
||||
undefined
|
||||
-> m (Maybe (SignedBox ByteString s))
|
||||
makeNotificationTx ncred lww klook forkInfo = runMaybeT do
|
||||
let annData = GitRepoAnnounceData @s lww forkInfo
|
||||
let lwpk = coerce lww :: PubKey 'Sign s
|
||||
lwsk <- MaybeT $ klook lwpk
|
||||
let repoAnn = makeSignedBox @s lwpk lwsk (LBS.toStrict $ serialise annData)
|
||||
pure $ makeSignedBox @s (notifyPk ncred) (notifySk ncred) (LBS.toStrict $ serialise repoAnn)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -172,6 +172,21 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_8": {
|
||||
"locked": {
|
||||
"lastModified": 1644229661,
|
||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"haskell-flake-utils": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2"
|
||||
|
@ -268,6 +283,24 @@
|
|||
"inputs": {
|
||||
"flake-utils": "flake-utils_7"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1698938553,
|
||||
"narHash": "sha256-oXpTKXioqFbl2mhhvpJIAvgNd+wYyv4ekI+YnJHEJ6s=",
|
||||
"owner": "ivanovs-4",
|
||||
"repo": "haskell-flake-utils",
|
||||
"rev": "19b273b5dc401a0a565e7f75cf50a593871b80c9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ivanovs-4",
|
||||
"repo": "haskell-flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"haskell-flake-utils_7": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_8"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1672412555,
|
||||
"narHash": "sha256-Kaa8F7nQFR3KuS6Y9WRUxeJeZlp6CCubyrRfmiEsW4k=",
|
||||
|
@ -288,6 +321,7 @@
|
|||
"fixme": "fixme",
|
||||
"haskell-flake-utils": "haskell-flake-utils_4",
|
||||
"hspup": "hspup",
|
||||
"lsm": "lsm",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
|
@ -295,16 +329,16 @@
|
|||
"suckless-conf": "suckless-conf_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710646368,
|
||||
"narHash": "sha256-0ayUFjOSX4UqSRBbLJeqPMBAn+qSAlFRoICVABliF80=",
|
||||
"ref": "lwwrepo",
|
||||
"rev": "16b5b6220a4be96e30c65f34d631445c28676feb",
|
||||
"revCount": 1002,
|
||||
"lastModified": 1711190148,
|
||||
"narHash": "sha256-XnvjD8yvSrSTMmsy3fE7chVg1oDBamMaWkEZ0lJ8sHU=",
|
||||
"ref": "dev-0.24.2",
|
||||
"rev": "37618a32bb0ae5bfa8b8380c6537638b1f5d412d",
|
||||
"revCount": 983,
|
||||
"type": "git",
|
||||
"url": "http://git.hbs2/BTThPdHKF8XnEq4m6wzbKHKA6geLFK4ydYhBXAqBdHSP"
|
||||
},
|
||||
"original": {
|
||||
"ref": "lwwrepo",
|
||||
"ref": "dev-0.24.2",
|
||||
"type": "git",
|
||||
"url": "http://git.hbs2/BTThPdHKF8XnEq4m6wzbKHKA6geLFK4ydYhBXAqBdHSP"
|
||||
}
|
||||
|
@ -351,6 +385,28 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"lsm": {
|
||||
"inputs": {
|
||||
"haskell-flake-utils": "haskell-flake-utils_6",
|
||||
"nixpkgs": [
|
||||
"hbs2",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1711033804,
|
||||
"narHash": "sha256-z9cb5yuWfuZmGukxsZebXhc6KUZoPVT60oXxQ6j6ML8=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "0e8286a43da5b9e54c4f3ecdb994173fe77351db",
|
||||
"revCount": 26,
|
||||
"type": "git",
|
||||
"url": "https://git.hbs2.net/5BCaH95cWsVKBmWaDNLWQr2umxzzT5kqRRKNTm2J15Ls"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://git.hbs2.net/5BCaH95cWsVKBmWaDNLWQr2umxzzT5kqRRKNTm2J15Ls"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1685566663,
|
||||
|
@ -433,7 +489,7 @@
|
|||
},
|
||||
"suckless-conf_2": {
|
||||
"inputs": {
|
||||
"haskell-flake-utils": "haskell-flake-utils_6",
|
||||
"haskell-flake-utils": "haskell-flake-utils_7",
|
||||
"nixpkgs": [
|
||||
"hbs2",
|
||||
"nixpkgs"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
extra-container.url = "github:erikarvstedt/extra-container";
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
hbs2.url =
|
||||
"git+http://git.hbs2/BTThPdHKF8XnEq4m6wzbKHKA6geLFK4ydYhBXAqBdHSP?ref=lwwrepo";
|
||||
"git+http://git.hbs2/BTThPdHKF8XnEq4m6wzbKHKA6geLFK4ydYhBXAqBdHSP?ref=dev-0.24.2";
|
||||
hbs2.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
home-manager.url = "github:nix-community/home-manager";
|
||||
|
|
Loading…
Reference in New Issue