Publish Zenith beta version #80

Merged
pitmutt merged 90 commits from dev041 into master 2024-05-09 19:15:41 +00:00
Showing only changes of commit 6b48f49760 - Show all commits

View file

@ -1,7 +1,17 @@
{-# LANGUAGE OverloadedStrings #-}
module Zenith.Scanner where
import Control.Monad (when)
import Control.Exception (throwIO)
import Data.HexString
import qualified Data.Text as T
import Network.HTTP.Simple (getResponseBody)
import ZcashHaskell.Types
( BlockResponse(..)
, RpcResponse(..)
, ZebraGetBlockChainInfo(..)
)
import ZcashHaskell.Utils (makeZebraCall)
import Zenith.Core (checkBlockChain)
-- | Function to scan the Zcash blockchain through the Zebra node and populate the Zenith database
@ -16,7 +26,22 @@ scanZebra b host port dbFilePath = do
case bc of
Nothing -> throwIO $ userError "Failed to determine blockchain status"
Just bStatus -> do
if b > zgb_blocks bStatus
if b > zgb_blocks bStatus || b < 1
then throwIO $ userError "Invalid starting block for scan"
else do
let bList = [b .. (zgb_blocks bStatus)]
print bList
-- | Function to process a raw block and extract the transaction information
processBlock ::
Int -- ^ The block number to process
-> T.Text -- ^ Host name for `zebrad`
-> Int -- ^ Port for `zebrad`
-> IO [HexString]
processBlock b host port = do
r <-
result . getResponseBody <$>
makeZebraCall host port "getblock" [fromIntegral b, 1]
case r of
Nothing -> throwIO $ userError "Unable to get block data from Zebra"
Just b' -> return $ bl_txs b'