rvv041 #82

Merged
pitmutt merged 30 commits from rvv041 into milestone2 2024-06-07 20:03:06 +00:00
Showing only changes of commit e9e56453c1 - Show all commits

View file

@ -249,7 +249,7 @@ share
AddressBook AddressBook
network ZcashNetDB network ZcashNetDB
descrip T.Text descrip T.Text
address HexStringDB address T.Text
UniqueABA address UniqueABA address
deriving Show Eq deriving Show Eq
|] |]
@ -1484,5 +1484,24 @@ getAdrBook pool n =
where_ (adrbook ^. AddressBookNetwork ==. val (ZcashNetDB n)) where_ (adrbook ^. AddressBookNetwork ==. val (ZcashNetDB n))
pure adrbook pure adrbook
-- | Save a new address into AddressBook
saveAdrsInAdrBook ::
ConnectionPool -- ^ The database path to use
-> AddressBook -- ^ The address to add to the database
-> IO (Maybe (Entity AddressBook))
saveAdrsInAdrBook pool a =
runNoLoggingT $
PS.retryOnBusy $ flip PS.runSqlPool pool $ insertUniqueEntity a
-- | Update an existing address into AddressBook
updateAdrsInAdrBook :: ConnectionPool -> T.Text -> AddressBookId -> IO ()
updateAdrsInAdrBook pool a i = do
runNoLoggingT $
PS.retryOnBusy $
flip PS.runSqlPool pool $ do
update $ \ab -> do
set ab [AddressBookAddress =. val a]
where_ $ ab ^. AddressBookId ==. val i
rmdups :: Ord a => [a] -> [a] rmdups :: Ord a => [a] -> [a]
rmdups = map head . group . sort rmdups = map head . group . sort