mirror of https://github.com/voidlizard/hbs2
wip lref-list, lref-update
This commit is contained in:
parent
95fd2f2c0a
commit
1802c5bc9e
|
@ -844,7 +844,7 @@ FIXME: Обработка ошибок в асинхронном приложе
|
||||||
FIXME: RPC, cli для линейных ссылок
|
FIXME: RPC, cli для линейных ссылок
|
||||||
|
|
||||||
* [x] lref-get через rpc пира get
|
* [x] lref-get через rpc пира get
|
||||||
* [ ] lref-new через rpc пира new
|
* [x] lref-new через rpc пира new
|
||||||
* [ ] lref-update через rpc пира update
|
* [ ] lref-update через rpc пира update
|
||||||
|
|
||||||
* [ ] lref-list через rpc пира list
|
* [ ] lref-list через rpc пира list
|
||||||
|
|
|
@ -179,7 +179,9 @@ data RPCCommand =
|
||||||
| SETLOG SetLogging
|
| SETLOG SetLogging
|
||||||
| LREFANN (Hash HbSync)
|
| LREFANN (Hash HbSync)
|
||||||
| LREFNEW (PubKey 'Sign UDP) Text
|
| LREFNEW (PubKey 'Sign UDP) Text
|
||||||
|
| LREFLIST
|
||||||
| LREFGET (Hash HbSync)
|
| LREFGET (Hash HbSync)
|
||||||
|
| LREFUPDATE (PrivKey 'Sign UDP) (PubKey 'Sign UDP) (Hash HbSync) (Hash HbSync)
|
||||||
|
|
||||||
data PeerOpts =
|
data PeerOpts =
|
||||||
PeerOpts
|
PeerOpts
|
||||||
|
@ -244,9 +246,9 @@ runCLI = join . customExecParser (prefs showHelpOnError) $
|
||||||
<> command "log" (info pLog (progDesc "set logging level"))
|
<> command "log" (info pLog (progDesc "set logging level"))
|
||||||
<> command "lref-ann" (info pLRefAnn (progDesc "announce linear ref"))
|
<> command "lref-ann" (info pLRefAnn (progDesc "announce linear ref"))
|
||||||
<> command "lref-new" (info pLRefNew (progDesc "generates a new linear ref"))
|
<> command "lref-new" (info pLRefNew (progDesc "generates a new linear ref"))
|
||||||
-- <> command "lref-list" (info pLRefList (progDesc "list node linear refs"))
|
<> command "lref-list" (info pLRefList (progDesc "list node linear refs"))
|
||||||
<> command "lref-get" (info pLRefGet (progDesc "get a linear ref"))
|
<> command "lref-get" (info pLRefGet (progDesc "get a linear ref"))
|
||||||
-- <> command "lref-update" (info pLRefUpdate (progDesc "updates a linear ref"))
|
<> command "lref-update" (info pLRefUpdate (progDesc "updates a linear ref"))
|
||||||
)
|
)
|
||||||
|
|
||||||
confOpt = strOption ( long "config" <> short 'c' <> help "config" )
|
confOpt = strOption ( long "config" <> short 'c' <> help "config" )
|
||||||
|
@ -331,11 +333,28 @@ runCLI = join . customExecParser (prefs showHelpOnError) $
|
||||||
<&> parseCredentials @UDP . AsCredFile . LBS.toStrict . LBS.take 4096)
|
<&> parseCredentials @UDP . AsCredFile . LBS.toStrict . LBS.take 4096)
|
||||||
`orDie` "can't parse credential file"
|
`orDie` "can't parse credential file"
|
||||||
runRpcCommand rpc (LREFNEW (_peerSignPk cred) t)
|
runRpcCommand rpc (LREFNEW (_peerSignPk cred) t)
|
||||||
|
|
||||||
|
pLRefList = do
|
||||||
|
rpc <- pRpcCommon
|
||||||
|
pure $ do
|
||||||
|
runRpcCommand rpc (LREFLIST)
|
||||||
|
|
||||||
pLRefGet = do
|
pLRefGet = do
|
||||||
rpc <- pRpcCommon
|
rpc <- pRpcCommon
|
||||||
h <- strArgument ( metavar "REF-ID" )
|
h <- strArgument ( metavar "REF-ID" )
|
||||||
pure $ runRpcCommand rpc (LREFGET h)
|
pure $ runRpcCommand rpc (LREFGET h)
|
||||||
|
|
||||||
|
pLRefUpdate = do
|
||||||
|
rpc <- pRpcCommon
|
||||||
|
credFile <- strOption ( short 'k' <> long "key" <> help "author keys file" )
|
||||||
|
lrefId <- strArgument ( metavar "REF-ID" )
|
||||||
|
hval <- strArgument ( metavar "HASH" )
|
||||||
|
pure $ do
|
||||||
|
cred <- (LBS.readFile credFile
|
||||||
|
<&> parseCredentials @UDP . AsCredFile . LBS.toStrict . LBS.take 4096)
|
||||||
|
`orDie` "can't parse credential file"
|
||||||
|
runRpcCommand rpc (LREFUPDATE (_peerSignSk cred) (_peerSignPk cred) lrefId hval)
|
||||||
|
|
||||||
|
|
||||||
myException :: SomeException -> IO ()
|
myException :: SomeException -> IO ()
|
||||||
myException e = die ( show e ) >> exitFailure
|
myException e = die ( show e ) >> exitFailure
|
||||||
|
|
Loading…
Reference in New Issue