Add new Scanner module

This commit is contained in:
Rene Vergara 2024-03-19 15:09:12 -05:00
parent c227f80dcc
commit 826ed5b697
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
2 changed files with 23 additions and 0 deletions

22
src/Zenith/Scanner.hs Normal file
View file

@ -0,0 +1,22 @@
module Zenith.Scanner where
import Control.Monad (when)
import qualified Data.Text as T
import Zenith.Core (checkBlockChain)
-- | Function to scan the Zcash blockchain through the Zebra node and populate the Zenith database
scanZebra ::
Int -- ^ Starting block
-> T.Text -- ^ Host
-> Int -- ^ Port
-> T.Text -- ^ Path to database file
-> IO ()
scanZebra b host port dbFilePath = do
bc <- checkBlockChain host port
case bc of
Nothing -> throwIO $ userError "Failed to determine blockchain status"
Just bStatus -> do
if b > zgb_blocks bStatus
then throwIO $ userError "Invalid starting block for scan"
else do
let bList = [b .. (zgb_blocks bStatus)]

View file

@ -32,6 +32,7 @@ library
Zenith.Types
Zenith.Utils
Zenith.Zcashd
Zenith.Scanner
hs-source-dirs:
src
build-depends: