Compare commits

..

No commits in common. "b3e33b798bcafb772c0dc82644892f9d13353523" and "0a2e585eb920598bc646e3322c3596e8b4568aeb" have entirely different histories.

4 changed files with 9 additions and 42 deletions

View file

@ -12,4 +12,4 @@ main = do
{-dataStorePath <- require config "dataStorePath"-} {-dataStorePath <- require config "dataStorePath"-}
zebraPort <- require config "zebraPort" zebraPort <- require config "zebraPort"
zebraHost <- require config "zebraHost" zebraHost <- require config "zebraHost"
scanZebra 2772000 zebraHost zebraPort dbFilePath scanZebra 2764500 zebraHost zebraPort dbFilePath

View file

@ -5,18 +5,15 @@ module Zenith.Scanner where
import Control.Exception (throwIO, try) import Control.Exception (throwIO, try)
import Data.Aeson import Data.Aeson
import Data.HexString import Data.HexString
import Data.Maybe
import qualified Data.Text as T import qualified Data.Text as T
import GHC.Utils.Monad (concatMapM) import GHC.Utils.Monad (concatMapM)
import Network.HTTP.Simple (getResponseBody)
import ZcashHaskell.Types import ZcashHaskell.Types
( BlockResponse(..) ( BlockResponse(..)
, RawZebraTx(..) , RpcResponse(..)
, Transaction(..)
, ZebraGetBlockChainInfo(..) , ZebraGetBlockChainInfo(..)
, ZebraTxResponse(..)
, fromRawTBundle
) )
import ZcashHaskell.Utils (makeZebraCall, readZebraTransaction) import ZcashHaskell.Utils (makeZebraCall)
import Zenith.Core (checkBlockChain) import Zenith.Core (checkBlockChain)
import Zenith.DB (initRawStore) import Zenith.DB (initRawStore)
import Zenith.Utils (jsonNumber) import Zenith.Utils (jsonNumber)
@ -42,7 +39,7 @@ scanZebra b host port dbFilePath = do
let bList = [b .. (zgb_blocks bStatus)] let bList = [b .. (zgb_blocks bStatus)]
txList <- txList <-
try $ concatMapM (processBlock host port) bList :: IO try $ concatMapM (processBlock host port) bList :: IO
(Either IOError [Transaction]) (Either IOError [HexString])
case txList of case txList of
Left e1 -> print e1 Left e1 -> print e1
Right txList' -> print txList' Right txList' -> print txList'
@ -52,7 +49,7 @@ processBlock ::
T.Text -- ^ Host name for `zebrad` T.Text -- ^ Host name for `zebrad`
-> Int -- ^ Port for `zebrad` -> Int -- ^ Port for `zebrad`
-> Int -- ^ The block number to process -> Int -- ^ The block number to process
-> IO [Transaction] -> IO [HexString]
processBlock host port b = do processBlock host port b = do
r <- r <-
makeZebraCall makeZebraCall
@ -62,34 +59,4 @@ processBlock host port b = do
[Data.Aeson.String $ T.pack $ show b, jsonNumber 1] [Data.Aeson.String $ T.pack $ show b, jsonNumber 1]
case r of case r of
Left e -> throwIO $ userError e Left e -> throwIO $ userError e
Right blk -> do Right blk -> return $ bl_txs blk
x <- mapM (processTx host port) $ bl_txs blk
return $ catMaybes x
-- | Function to process a raw transaction
processTx ::
T.Text -- ^ Host name for `zebrad`
-> Int -- ^ Port for `zebrad`
-> HexString -- ^ transaction id
-> IO (Maybe Transaction)
processTx host port t = do
r <-
makeZebraCall
host
port
"getrawtransaction"
[Data.Aeson.String $ toText t, jsonNumber 1]
case r of
Left e -> throwIO $ userError e
Right rawTx -> do
case readZebraTransaction (ztr_hex rawTx) of
Nothing -> return Nothing
Just rzt ->
return $
Just $
Transaction
t
(ztr_blockheight rawTx)
(ztr_conf rawTx)
(fromIntegral $ zt_expiry rzt)
(fromRawTBundle $ zt_tBundle rzt)

@ -1 +1 @@
Subproject commit 4b064af4dece54fe51e3704aa95db18324167d36 Subproject commit f0995441628381fee14ae1c655c3c4f8d96162e5

View file

@ -1,6 +1,6 @@
cabal-version: 3.0 cabal-version: 3.0
name: zenith name: zenith
version: 0.4.4.2 version: 0.4.4.1
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Rene Vergara author: Rene Vergara