rvv041 - Address Book table added to database
getAdrBook function to get a list of all addresses recorded in AddressBook table
This commit is contained in:
parent
94b16f743f
commit
2fb6747bfb
3 changed files with 19 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
.stack-work/
|
.stack-work/
|
||||||
*~
|
*~
|
||||||
dist-newstyle/
|
dist-newstyle/
|
||||||
|
zenith.db
|
||||||
|
zenith.log
|
|
@ -246,6 +246,12 @@ share
|
||||||
position Int
|
position Int
|
||||||
UniqueSSPos tx position
|
UniqueSSPos tx position
|
||||||
deriving Show Eq
|
deriving Show Eq
|
||||||
|
AddressBook
|
||||||
|
network ZcashNetDB
|
||||||
|
descrip T.Text
|
||||||
|
address HexStringDB
|
||||||
|
UniqueABA address
|
||||||
|
deriving Show Eq
|
||||||
|]
|
|]
|
||||||
|
|
||||||
-- * Database functions
|
-- * Database functions
|
||||||
|
@ -1467,5 +1473,16 @@ readUnifiedAddressDB :: WalletAddress -> Maybe UnifiedAddress
|
||||||
readUnifiedAddressDB =
|
readUnifiedAddressDB =
|
||||||
isValidUnifiedAddress . TE.encodeUtf8 . getUA . walletAddressUAddress
|
isValidUnifiedAddress . TE.encodeUtf8 . getUA . walletAddressUAddress
|
||||||
|
|
||||||
|
-- | Get list of external zcash addresses from database
|
||||||
|
getAdrBook :: ConnectionPool -> ZcashNet -> IO [Entity AddressBook]
|
||||||
|
getAdrBook pool n =
|
||||||
|
runNoLoggingT $
|
||||||
|
PS.retryOnBusy $
|
||||||
|
flip PS.runSqlPool pool $ do
|
||||||
|
select $ do
|
||||||
|
adrbook <- from $ table @AddressBook
|
||||||
|
where_ (adrbook ^. AddressBookNetwork ==. val (ZcashNetDB n))
|
||||||
|
pure adrbook
|
||||||
|
|
||||||
rmdups :: Ord a => [a] -> [a]
|
rmdups :: Ord a => [a] -> [a]
|
||||||
rmdups = map head . group . sort
|
rmdups = map head . group . sort
|
||||||
|
|
BIN
zenith.db
BIN
zenith.db
Binary file not shown.
Loading…
Reference in a new issue