actions 中带transaction的status

2018-08-08 22:08:00

查询笔记,稍后问题完结后,会重新整理

App开发的小伙伴想有个接口,根据账户名查询交易记录,并且每条交易记录都带有status。

了解到完成上面的数据需要三步

  1. 根据账户名查询actions表,查询出一些记录

  2. 根据记录的transaction id,查询所在block (不用此步,action 中已有block id)

  3. 根据block id查询所在块的此transaction id的status

    • 查看测试数据:
curl 'https://api1.eosdublin.io/v1/chain/get_block' -H 'Referer: https://eostracker.io/transactions/91206e95c247e76e924bf2b3a75b0e894347de138e3a5e7b0b011c6b3e6b268b' -H 'Origin: https://eostracker.io' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36' -H 'Content-Type: text/plain;charset=UTF-8' --data-binary '{"block_num_or_id":4265926}' --compressed

获取的actions数据

看第一步的,获取的actions数据中,同一个transaction id(91206e95c247e76e924bf2b3a75b0e894347de138e3a5e7b0b011c6b3e6b268b),会有多笔的交易。

查transaction id

那我们查下此transaction id,什么情况。(点击打开)

看下几个数据的链接

https://eostracker.io/actions/4265926/91206e95c247e76e924bf2b3a75b0e894347de138e3a5e7b0b011c6b3e6b268b/0
https://eostracker.io/actions/4265926/91206e95c247e76e924bf2b3a75b0e894347de138e3a5e7b0b011c6b3e6b268b/1
https://eostracker.io/actions/4265926/91206e95c247e76e924bf2b3a75b0e894347de138e3a5e7b0b011c6b3e6b268b/0?parentId=4926446
https://eostracker.io/actions/4265926/91206e95c247e76e924bf2b3a75b0e894347de138e3a5e7b0b011c6b3e6b268b/1?parentId=4926446
https://eostracker.io/actions/4265926/91206e95c247e76e924bf2b3a75b0e894347de138e3a5e7b0b011c6b3e6b268b/2
https://eostracker.io/actions/4265926/91206e95c247e76e924bf2b3a75b0e894347de138e3a5e7b0b011c6b3e6b268b/0?parentId=4926449

明显的树形结构,


再看下具体的数据
https://api.eostracker.io/transactions/91206e95c247e76e924bf2b3a75b0e894347de138e3a5e7b0b011c6b3e6b268b/actions?page=1&size=10

得出,在相同的transaction id和blockId情况下,

  • seq和parentId都为0,此节点为顶级节点。
  • parentId为0,seq不为0,为二级顶节点。
  • parentId不为0,则为对应id二级节点的三级节点。

对于这些交易,App那边更期望,查询此transaction id后,界面显示此任务为顶级节点所做的事,查看详情后才显示二,三级数据。

首先查下status,有哪些类型
eos\libraries\chain\include\eosio\chain\block.hpp

struct transaction_receipt_header {
      enum status_enum {
         executed  = 0, ///< succeed, no error handler executed
         soft_fail = 1, ///< objectively failed (not executed), error handler executed
         hard_fail = 2, ///< objectively failed and error handler objectively failed thus no state change
         delayed   = 3, ///< transaction delayed/deferred/scheduled for future execution
         expired   = 4  ///< transaction expired and storage space refuned to user
      };
当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »