Publish Zenith beta version #80

Merged
pitmutt merged 90 commits from dev041 into master 2024-05-09 19:15:41 +00:00
4 changed files with 32 additions and 12 deletions
Showing only changes of commit 865f7241b1 - Show all commits

View file

@ -161,8 +161,7 @@ createWalletAddress n i zNet scope za = do
-- * Wallet
-- | Sync the wallet with the data store
syncWallet ::
T.Text -- ^ Wallet database
-> T.Text -- ^ Data store database
T.Text -- ^ The database path
-> Entity ZcashWallet
-> IO ()
syncWallet walletDb dataDb w = undefined
syncWallet walletDb w = undefined

View file

@ -79,19 +79,21 @@ share
UniqueAddName accId name
deriving Show Eq
WalletTransaction
addrId WalletAddressId
txId HexStringDB
block Int
conf Int
time Int
deriving Show Eq
WalletTrNote
tx WalletTransactionId
addrId WalletAddressId
value Int
rawId TransparentNoteId
spent Bool
deriving Show Eq
WalletSapNote
tx WalletTransactionId
addrId WalletAddressId
value Int
recipient BS.ByteString
memo T.Text
@ -100,6 +102,7 @@ share
deriving Show Eq
WalletOrchNote
tx WalletTransactionId
addrId WalletAddressId
value Int
recipient BS.ByteString
memo T.Text
@ -206,6 +209,18 @@ getMaxBlock dbPath = do
Nothing -> return $ -1
Just x -> return $ zcashTransactionBlock $ entityVal x
-- | Returns the largest block in the wallet
getMaxWalletBlock ::
T.Text -- ^ The database path
-> IO Int
getMaxWalletBlock dbPath = do
b <-
runSqlite dbPath $
selectFirst [WalletTransactionBlock >. 0] [Desc WalletTransactionBlock]
case b of
Nothing -> return $ -1
Just x -> return $ walletTransactionBlock $ entityVal x
-- | Returns a list of addresses associated with the given account
getAddresses ::
T.Text -- ^ The database path

View file

@ -8,6 +8,7 @@ import Data.HexString
import Data.Maybe
import qualified Data.Text as T
import GHC.Utils.Monad (concatMapM)
import System.Console.AsciiProgress
import ZcashHaskell.Types
( BlockResponse(..)
, RawZebraTx(..)
@ -39,13 +40,15 @@ scanZebra b host port dbFilePath = do
Left e -> print e
Right bStatus -> do
dbBlock <- getMaxBlock dbFilePath
let sb = min dbBlock b
let sb = max dbBlock b
if sb > zgb_blocks bStatus || sb < 1
then throwIO $ userError "Invalid starting block for scan"
else do
let bList = [sb .. (zgb_blocks bStatus)]
displayConsoleRegions $ do
pg <- newProgressBar def {pgTotal = fromIntegral $ length bList}
txList <-
try $ mapM_ (processBlock host port dbFilePath) bList :: IO
try $ mapM_ (processBlock host port dbFilePath pg) bList :: IO
(Either IOError ())
case txList of
Left e1 -> print e1
@ -56,9 +59,10 @@ processBlock ::
T.Text -- ^ Host name for `zebrad`
-> Int -- ^ Port for `zebrad`
-> T.Text -- ^ DB file path
-> ProgressBar -- ^ Progress bar
-> Int -- ^ The block number to process
-> IO ()
processBlock host port dbFp b = do
processBlock host port dbFp pg b = do
r <-
makeZebraCall
host
@ -80,6 +84,7 @@ processBlock host port dbFp b = do
let blockTime = getBlockTime hb
mapM_ (processTx host port blockTime dbFp) $
bl_txs $ addTime blk blockTime
tick pg
where
addTime :: BlockResponse -> Int -> BlockResponse
addTime bl t =

View file

@ -65,6 +65,7 @@ library
, vector
, vty
, word-wrap
, ascii-progress
, zcash-haskell
--pkgconfig-depends: rustzcash_wrapper
default-language: Haskell2010