Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
share
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张振华
share
Commits
65d77751
Commit
65d77751
authored
Nov 09, 2018
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add files
parent
5fb0c863
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
0 deletions
+44
-0
exec-balance-param.png
resource/exec-balance-param.png
+0
-0
exec-balance-query.png
resource/exec-balance-query.png
+0
-0
查询地址在所有合约中代币余额的需求.md
查询地址在所有合约中代币余额的需求.md
+44
-0
No files found.
resource/exec-balance-param.png
0 → 100644
View file @
65d77751
9.66 KB
resource/exec-balance-query.png
0 → 100644
View file @
65d77751
40 KB
查询地址在所有合约中代币余额的需求.md
0 → 100644
View file @
65d77751
#1.需求描述
遍历某个地址在合约中的所有余额,并列出有币合约的合约地址和frozen和active的值。
存储格式mavl-coins-bty-exec-exec_addr-addr,例如:mavl-coins-bty-exec-16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp:1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP,16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp为合约地址,1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP为具体账户地址。
#2.输入参数

样例:
cli exec_balance -symbol bty -exec coins -addr 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -exec_addr 16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp -height -1
#3.输出结果
{
"totalAmount":10,
"frozenAmount":3,
"activeAmount":7,
"execBalances":
[
{
"execAddr":"xxxx",
"frozen":1,
"active":2
},
...
]
}
#4.调用过程及处理逻辑

ReplyGetExecBalance.IterateExecBalanceByStateHash中的处理逻辑如下:
合法的key例子:mavl-coins-bty-exec-16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp:1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP
对于遍历时遇到的key和value进行如下处理:
1.如果查询请求中的前缀以:结尾,说明携带了具体合约地址,则一个用户地址对应该合约有一条记录,处理完成即可返回结果。
2.如果查询请求中未以:结尾,说明未携带具体合约地址,需要遍历所有合约地址,对于用户地址相符的记录进行解码处理,并统计余额及记录合约地址和该合约上的余额信息,直到遍历完成。
<font
color=
#FF0000
>
注意:
由于存储合约余额的格式中,用户地址在后,变化的合约地址在前,导致处理上不是很直接,避免不了遍历所有合约及用户地址,在性能上需要注意。
</font>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment