remove DNSChain mode

It's been dead for a few years now...
master
Michele Guerini Rocco 2022-06-12 03:51:20 +02:00
parent 387e3b05e4
commit 945f44a63a
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
3 changed files with 9 additions and 43 deletions

View File

@ -1,11 +1,13 @@
# Rosa
## Query the namecoin blockchain
Rosa is a commmand line tool to query the namecoin blockchain.
It gets the JSON value of a name and other data using namecoind local server or the dnschain REST api and displays it in a pretty format.
It gets the JSON value of a name and other data using namecoind local server and displays it in a pretty format.
### Usage
Run rosa -h for help
Show the value for a name with
@ -35,7 +37,7 @@ Connect to namecoind server for blockchain data
### License
Copyright (C) 2015 Michele Guerini Rocco
Copyright (C) 2022 Michele Guerini Rocco
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -5,14 +5,13 @@ description:
Rosa is a commmand line tool to query the namecoin blockhain.
It gets the JSON value of a name and other infos using namecoind
local server or the dnschain REST api and display them in a pretty
format.
local server and displays them in a pretty format.
license: GPL-3
license-file: LICENSE
author: rnhmjoj
maintainer: rnhmjoj@inventati.org
copyright: (C) Michele Guerini Rocco 2019
copyright: (C) Michele Guerini Rocco 2022
category: Utility
build-type: Simple
extra-source-files: README.md, LICENSE
@ -29,7 +28,7 @@ executable rosa
default-language: Haskell2010
other-extensions: RecordWildCards, OverloadedStrings
build-depends: base >=4.8 && <5.0 , aeson, text,
vector, uri-encode, unordered-containers,
wreq, lens, bytestring, directory,
vector, uri-encode,
bytestring, directory,
optparse-applicative, namecoin-update
ghc-options: -O2

View File

@ -9,7 +9,6 @@ import Json
-- Networking
import Namecoin (rpcRequest, uri)
import Network.Wreq (get, responseBody)
import qualified Network.URI.Encode as U
-- IO
@ -18,14 +17,12 @@ import System.Directory (XdgDirectory(..), getXdgDirectory)
import qualified Data.Text.IO as T
-- Data manipulation
import Data.Text (Text)
import Data.Aeson (Value(..), encode, decode, toJSON)
import Data.Aeson.KeyMap (delete)
import Data.ByteString.Lazy.Char8 (pack, unpack)
-- Misc
import Data.Maybe (fromMaybe)
import Control.Lens (view)
import Control.Monad (when)
@ -34,9 +31,7 @@ import Control.Monad (when)
-- | Program arguments record
data Options = Options
{ name :: String
, url :: String
, conf :: Maybe FilePath
, dnschain :: Bool
, block :: Bool
, raw :: Bool
}
@ -47,21 +42,11 @@ options = Options
<$> strArgument
( metavar "NAME"
<> help "Namecoin name id" )
<*> strOption
( long "url"
<> short 'u'
<> value "http://namecoin.dns"
<> metavar "URL"
<> help "Use custom API URL" )
<*> (optional $ strOption $
long "conf"
<> short 'c'
<> metavar "FILE"
<> help "Use custom namecoin config file" )
<*> switch
( long "dnschain"
<> short 'd'
<> help "Use dnschain API " )
<*> switch
( long "block"
<> short 'b'
@ -86,10 +71,7 @@ description = info (helper <*> options)
-- | Main function
main :: IO ()
main = execParser description >>= exec where
exec Options{..} =
if dnschain
then doDnschain url name raw block
else doLocal name raw block conf
exec Options{..} = doLocal name raw block conf
-- | Load namecoin configuration
@ -118,20 +100,3 @@ doLocal name raw block conf = do
where
tryParse = fromMaybe (res |. "value") . decode . pack
blockInfo = toJSON (delete "value" res)
-- | Connect to dnschain API endpoint
doDnschain :: String -> String -> Bool -> Bool -> IO ()
doDnschain url name raw block = do
body <- view responseBody <$> get (url++"/v1/namecoin/key/"++U.encode name)
if raw
then putStrLn (unpack body)
else do
case decode body of
Nothing -> putStrLn "Error parsing data"
Just res -> putStrLn $
if block
then repr res
else repr $ (res .| "data") .| "value"
where (Object x) .| y = x |. y