fix: optimize FFI for large results
This commit is contained in:
parent
fa2b34e26f
commit
f4ecfe9d11
1 changed files with 33 additions and 17 deletions
|
@ -132,9 +132,10 @@ createTransaction ::
|
||||||
-> ZcashNet -- ^ the network to be used
|
-> ZcashNet -- ^ the network to be used
|
||||||
-> Int -- ^ target block height
|
-> Int -- ^ target block height
|
||||||
-> Bool -- ^ True to build, False to estimate fee
|
-> Bool -- ^ True to build, False to estimate fee
|
||||||
-> HexString
|
-> IO (Either TxError HexString)
|
||||||
createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing znet bh build =
|
createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing znet bh build = do
|
||||||
withPureBorshVarBuffer $
|
txResult <-
|
||||||
|
withBorshBufferOfInitSize 5120 $
|
||||||
rustWrapperCreateTx
|
rustWrapperCreateTx
|
||||||
(case sapAnchor of
|
(case sapAnchor of
|
||||||
Nothing -> "0"
|
Nothing -> "0"
|
||||||
|
@ -149,3 +150,18 @@ createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing znet bh bui
|
||||||
(znet == MainNet)
|
(znet == MainNet)
|
||||||
(fromIntegral bh)
|
(fromIntegral bh)
|
||||||
build
|
build
|
||||||
|
if BS.length (hexBytes txResult) > 1
|
||||||
|
then pure $ Right txResult
|
||||||
|
else case head (BS.unpack $ hexBytes txResult) of
|
||||||
|
0 -> pure $ Left InsufficientFunds
|
||||||
|
1 -> pure $ Left ChangeRequired
|
||||||
|
2 -> pure $ Left Fee
|
||||||
|
3 -> pure $ Left Balance
|
||||||
|
4 -> pure $ Left TransparentBuild
|
||||||
|
5 -> pure $ Left SaplingBuild
|
||||||
|
6 -> pure $ Left OrchardBuild
|
||||||
|
7 -> pure $ Left OrchardSpend
|
||||||
|
8 -> pure $ Left OrchardRecipient
|
||||||
|
9 -> pure $ Left SaplingBuilderNotAvailable
|
||||||
|
10 -> pure $ Left OrchardBuilderNotAvailable
|
||||||
|
_ -> pure $ Left ZHError
|
||||||
|
|
Loading…
Reference in a new issue