monaparty / counterblock

Provides extended API services to Counterwallet, as well as Counterparty 3rd-party applications
http://counterparty.io
MIT License
3 stars 5 forks source link

Use pagenation on getting assets in get_normalized_balances. #30

Open cryptcoin-junkey opened 2 years ago

cryptcoin-junkey commented 2 years ago

Signed-off-by: Cryptcoin Junkey cryptcoin.junkey@gmail.com

fixes #29

cryptcoin-junkey commented 2 years ago
curl localhost:4100 --data-binary '{ "jsonrpc": "2.0", "method": "get_normalized_balances", "params": { "addresses": ["MLJ11FmnsikavGbcHm9HpfgcPhA81NdBzM"]}, "id": 1 }' | jq . | grep _quantity | wc -l
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  279k  100  279k  100   132   380k    179 --:--:-- --:--:-- --:--:--  380k
1701

After applied this patch, we can get all (more than 1000) balances that Monapa-chan has.

codecov[bot] commented 2 years ago

Codecov Report

Merging #30 (fa8350e) into monaparty-develop (0b94e65) will decrease coverage by 0.00%. The diff coverage is 0.00%.

Impacted file tree graph

@@                 Coverage Diff                  @@
##           monaparty-develop     #30      +/-   ##
====================================================
- Coverage               3.95%   3.94%   -0.01%     
====================================================
  Files                     30      30              
  Lines                   3973    3981       +8     
====================================================
  Hits                     157     157              
- Misses                  3816    3824       +8     
Impacted Files Coverage Δ
counterblock/lib/modules/assets.py 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0b94e65...fa8350e. Read the comment docs.

anipopina commented 2 years ago

どうしても気になってしまったためコメントで失礼します。 地味なのですが result = result + sub の後に if len(sub) < size: でbreakしてあげるようにすれば、多くの場合においてget_balancesを1回減らせると思いました。

cryptcoin-junkey commented 2 years ago

@anipopina ご指摘はそのとおりなのですが、#29 でのコメントの通り、それなりの規模で書き換える前提で作業にはいっており、現時点では最適化は考慮していません。