Milestone 3: RPC server, ZIP-320 #104
3 changed files with 30 additions and 16 deletions
|
@ -1611,15 +1611,29 @@ getOrchardCmxs pool zt = do
|
|||
getMaxOrchardNote :: Pool SqlBackend -> IO OrchActionId
|
||||
getMaxOrchardNote pool = do
|
||||
flip PS.runSqlPool pool $ do
|
||||
x <-
|
||||
maxBlock <-
|
||||
selectOne $ do
|
||||
n <- from $ table @OrchAction
|
||||
where_ (n ^. OrchActionId >. val (toSqlKey 0))
|
||||
orderBy [desc $ n ^. OrchActionId]
|
||||
pure (n ^. OrchActionId)
|
||||
case x of
|
||||
blks <- from $ table @ZcashBlock
|
||||
where_ $ blks ^. ZcashBlockHeight >. val 0
|
||||
pure $ blks ^. ZcashBlockHeight
|
||||
case maxBlock of
|
||||
Nothing -> return $ toSqlKey 0
|
||||
Just (Value y) -> return y
|
||||
Just (Value mb) -> do
|
||||
x <-
|
||||
selectOne $ do
|
||||
(blks :& txs :& n) <-
|
||||
from $ table @ZcashBlock `innerJoin` table @ZcashTransaction `on`
|
||||
(\(blks :& txs) ->
|
||||
blks ^. ZcashBlockId ==. txs ^. ZcashTransactionBlockId) `innerJoin`
|
||||
table @OrchAction `on`
|
||||
(\(_ :& txs :& n) ->
|
||||
txs ^. ZcashTransactionId ==. n ^. OrchActionTx)
|
||||
where_ (blks ^. ZcashBlockHeight <=. val (mb - 5))
|
||||
orderBy [desc $ n ^. OrchActionId]
|
||||
pure (n ^. OrchActionId)
|
||||
case x of
|
||||
Nothing -> return $ toSqlKey 0
|
||||
Just (Value y) -> return y
|
||||
|
||||
updateOrchNoteRecord ::
|
||||
Pool SqlBackend
|
||||
|
|
16
test/Spec.hs
16
test/Spec.hs
|
@ -265,7 +265,7 @@ main = do
|
|||
18232
|
||||
TestNet
|
||||
(toSqlKey 1)
|
||||
3000789
|
||||
3000785
|
||||
0.005
|
||||
(fromJust uaRead)
|
||||
"Sending memo to orchard"
|
||||
|
@ -286,15 +286,15 @@ main = do
|
|||
"localhost"
|
||||
18232
|
||||
TestNet
|
||||
(toSqlKey 1)
|
||||
2999396
|
||||
(toSqlKey 4)
|
||||
3000789
|
||||
0.005
|
||||
(fromJust uaRead)
|
||||
"Sending memo to orchard"
|
||||
"Sending memo to sapling"
|
||||
Full
|
||||
tx `shouldBe` Right (hexString "deadbeef")
|
||||
describe "Medium" $ do
|
||||
it "To Orchard" $ do
|
||||
xit "To Orchard" $ do
|
||||
let uaRead =
|
||||
parseAddress
|
||||
"utest1dl54utt6prjj5e0dnlknwumnxq9hycdjpkfr0sy6e6h522remqee8axe9zax0wsjrwpj76v555pdhvj9rnargpfyycs0vpkapq98xcdhem99gc4wchzn0ggepq3y6nz3a9sscwgqxgsh9vzhcad402y3x9szfregck5gslkya3c79d86xx0l33tpk8gnn7ew9vw37w43zh22u8dgdax"
|
||||
|
@ -316,7 +316,7 @@ main = do
|
|||
"Sending memo to orchard"
|
||||
Medium
|
||||
tx `shouldBe` Right (hexString "deadbeef")
|
||||
it "To Sapling" $ do
|
||||
xit "To Sapling" $ do
|
||||
let uaRead =
|
||||
parseAddress
|
||||
"ztestsapling136jp8z89v2jh6kqd5rs4dtvlxym90m43svzdwzxaplyvc5ttzppytpvx80ncllcsqzpmukxjl3y"
|
||||
|
@ -332,9 +332,9 @@ main = do
|
|||
18232
|
||||
TestNet
|
||||
(toSqlKey 1)
|
||||
2999396
|
||||
3000789
|
||||
0.005
|
||||
(fromJust uaRead)
|
||||
"Sending memo to orchard"
|
||||
Full
|
||||
Medium
|
||||
tx `shouldBe` Right (hexString "deadbeef")
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 63a97b880cb32d8e008650f0efef2fdadc7d3d4a
|
||||
Subproject commit 12296026a0ebb9a5afe0904b251c5d31080eab18
|
Loading…
Reference in a new issue