Compare commits
No commits in common. "24fd6e2e95b69f06e9a9341be08dc51d542fdf42" and "de211d03b0c7e9a012c8cc36b346ff6aa998e306" have entirely different histories.
24fd6e2e95
...
de211d03b0
4 changed files with 9 additions and 42 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue