Closed ShookLyngs closed 2 months ago
Here are some suggestions from @ahonn:
noUtxosCache
option in the TxBuilder.payFee() (to the users)noUtxosCache
option can be set to true
by default when paying feedevelop branch build transaction time::
This branch builds transaction time:
Verify that there are 36 cells:
- develop branch build transaction time::
![]()
- This branch builds transaction time:
![]()
Is there still room for improvement in the time cost reduction by the cache? Or is this test case not typical enough?
Just renamed the cache-related options to make them look clearer:
Is there still room for improvement in the time cost reduction by the cache? Or is this test case not typical enough?
The problem can be broken down into two parts:
sendRgbppUtxos()
API for testing, which is indeed not typical enough because this PR aims to improve the construction time for transactions that collect a large amount of inputs during the fee-paying process.sendRgbppUtxos()
API can be optimized individually, as it contains time-costly syntax like for (...) { await fetch() }
, which can be refactored using the await Promise.all()
API.
Changes
Query data cache
Previously, when collecting inputs for paying fees, the
BtcAssetsApi.getBtcUtxos()
API and theBtcAssetsApi.getRgbppAssetsByBtcUtxo()
API were queried multiple times. In this PR, a DataCache is added to prevent querying the same API with the same params too often.Reference: https://github.com/ckb-cell/rgbpp-sdk/issues/173#issuecomment-2112523137
Test