EOS的区块、交易、Action的结构解析

在EOS数据库中每个集合的主要模式由四个部分构成:

  • Block-区块
  • Transaction-交易
  • Action-动作
  • Account-账户

熟悉eos的人就会知道,它们主体之间的关系是:一个区块由多笔交易组成,而一笔交易之中,又可能包含多条Action. 区块与交易,交易与Action, 是一对多的关系。

在EOSwiki文档中,可以看到如下的一张图,也全面阐述了它们之间的关系:[注意图中Message的说法现在已经由Action替换]。


block.png

通过网址: http://eostracker.io/ 我们可以直观的查找到eos的区块和交易结构,下面我们对查询的到数据json来进行结构分析。

(1)查询区块1978398,可以看到其中包含一笔交易信息

{
  <!--时间戳-->
  "timestamp": "2018-06-22T02:58:49.500",
  <!--区块生产者-->
  "producer": "eoscannonchn",
  "confirmed": 0,
  <!--向前区块信息-->
  "previous": "001e301d169f21f6f50924d5be192da9a34ea7bc6ef160f229f51c920ac953e1",
  <!--交易 Merkle根节点-->
  "transaction_mroot": "93fdc20c3150b2edd57e52a2134f2b528712e8924ddc5bdb4c06def977d9e5b1",
  <!--Action Merkle根节点-->
  "action_mroot": "e1cdf2061cd73ad64fdeed34a219e25804a14de096e340178bdc3d3a102fdd5f",
  "schedule_version": 45,
  "new_producers": null,
  "header_extensions": [],
  <!--生产者签名-->
  "producer_signature": "SIG_K1_KktSfFNrE3PinW1k87Bvwd6f61gEcsifqpincwpwupLjCoZHEDt6hxAz9mCyv8Kf194Zq7kbFMMDbHUBmoXKYKC3e1euJu",
  <!--区块交易信息-->
  "transactions": [
    {
      "status": "executed",
      "cpu_usage_us": 7064,
      "net_usage_words": 34,
      "trx": {
        <!--交易ID-->
        "id": "e86b07fd7155e40d53bf7eabdfefeda9befff9f5b27d918e2f54b89d1d6f754f",
        "signatures": [
          "SIG_K1_KZuhAnLqvz8dMYkCxZoE4vWkqPx5JznVduWcJcNsVPFzdfNRmeS9yFjLsJG2LSssgQXkknkC7uzAZaXVcqKQj51ahURquU"
        ],
        "compression": "none",
        "packed_context_free_data": "",
        "context_free_data": [],
        "packed_trx": "096d2c5bbe2e9590fada00000000010000000000ea30557015d289deaa32dd017091835bb9db62dd00000000a8ed3232b1017091835bb9db62dd000000000000000014206952ea2e413055500f9bee3975305590293dd375773055202932c94c833055301b9a744e83305570d5be0a23933055508f9f465ec530551029adee50dd3055a026cd4a49ea30551042088161ea3055e0b3dbe632ec3055707444d354f330552029a24652133155401dbcd47335315590b13aead28c31556054c65419953155f033c754fdcc315550cf44982a1aa36a40196594a988cca5104208a11e4cd5f900",
        <!--transaction交易信息-->
        "transaction": {
          "expiration": "2018-06-22T03:29:13",
          "ref_block_num": 11966,
          "ref_block_prefix": 3673854101,
          "max_net_usage_words": 0,
          "max_cpu_usage_ms": 0,
          "delay_sec": 0,
          "context_free_actions": [],
          <!--actions 信息-->
          "actions": [
            {
              <!--处理账户-->
              "account": "eosio",
              <!--action类型名称-->
              "name": "voteproducer",
              <!--授权-->
              "authorization": [
                {
                  "actor": "vplhrievkicr",
                  "permission": "active"
                }
              ],
              <!--action 主体数据-->
              "data": {
                <!--投票者-->
                "voter": "vplhrievkicr",
                "proxy": "",
                <!--被投节点-->
                "producers": [
                  "eos42freedom",
                  "eosbeijingbp",
                  "eosbixinboot",
                  "eoscanadacom",
                  "eoscannonchn",
                  "eosdacserver",
                  "eosgermanybp",
                  "eoshuobipool",
                  "eosiomeetone",
                  "eosiosg11111",
                  "eosisgravity",
                  "eosjapanclub",
                  "eoslaomaocom",
                  "eosnewyorkio",
                  "eosstorebest",
                  "eosteaeostea",
                  "eoswtzeoswtz",
                  "helloeoscnbp",
                  "oraclegogogo",
                  "zbeosbp11111"
                ]
              },
              "hex_data": "7091835bb9db62dd000000000000000014206952ea2e413055500f9bee3975305590293dd375773055202932c94c833055301b9a744e83305570d5be0a23933055508f9f465ec530551029adee50dd3055a026cd4a49ea30551042088161ea3055e0b3dbe632ec3055707444d354f330552029a24652133155401dbcd47335315590b13aead28c31556054c65419953155f033c754fdcc315550cf44982a1aa36a40196594a988cca5104208a11e4cd5f9"
            }
          ],
          "transaction_extensions": []
        }
      }
    }
  ],
  "block_extensions": [],
  <!--区块ID-->
  "id": "001e301e50665f777daf0b78ee50b0bf4e6171fb99b75222c5216c6fd7f331de",
  <!--区块计数-->
  "block_num": 1978398,
  "ref_block_prefix": 2014031741
}

(2)下面的json数据是记录了一个完整的交易,这笔交易中只包含了一个action,action为: voteproducer(节点投票)。

交易内容为: 账户名gu4dgmjxgyge对两个节点bitfinexeos1和eosisgravity进行了投票

{
  "status": "executed",
  "cpu_usage_us": 2926,
  "net_usage_words": 16,
  "trx": {
    "id": "f5799408cfd6e8931c8c55c4bfe6e607726417468e19b7369e1c3652191a5dde",
    "signatures": [
      "SIG_K1_Jxm6oGatcqsH22RgbnfwiG9rC7GGQfpQ8nvh1jgB7EeeUBuhp3AqBhzNd7MmvQdkXe2UdiPhNmc5ieY1BHan2tPf7et1L2"
    ],
    "compression": "none",
    "packed_context_free_data": "",
    "context_free_data": [],
    "packed_trx": "aa5f2c5bda217bfa947000000000010000000000ea30557015d289deaa32dd01a09867fd4996886600000000a8ed323221a09867fd499688660000000000000000021030555d4db7b23be0b3dbe632ec305500",
    "transaction": {
      "expiration": "2018-06-22T02:32:10",
      "ref_block_num": 8666,
      "ref_block_prefix": 1888811643,
      "max_net_usage_words": 0,
      "max_cpu_usage_ms": 0,
      "delay_sec": 0,
      "context_free_actions": [],
      "actions": [
        {
          "account": "eosio",
          "name": "voteproducer",
          "authorization": [
            {
              "actor": "gu4dgmjxgyge",
              "permission": "active"
            }
          ],
          "data": {
            "voter": "gu4dgmjxgyge",
            "proxy": "",
            "producers": [
              "bitfinexeos1",
              "eosisgravity"
            ]
          },
          "hex_data": "a09867fd499688660000000000000000021030555d4db7b23be0b3dbe632ec3055"
        }
      ],
      "transaction_extensions": []
    }
  }
}

(3)下面的json数据同样记录了一个完整的交易,这笔交易中包含了3个action,action分别为 newaccount(创建账户)、buyrambytes(购买内存)、delegatebw();

交易内容为:账户gi3tqojvhage创建了一个新账号eosoceanliao, 并对新账户eosoceanliao执行了buyrambytes和delegatebw两个action操作。

{
  "status": "executed",
  "cpu_usage_us": 6336,
  "net_usage_words": 42,
  "trx": {
    "id": "2ffcaa89f11a0319f899fcb2bbd40ea2c795d80fecc1eb62174df3e298b2adc1",
    "signatures": [
      "SIG_K1_Jz5eZQfCnrV1nuwRRBBt4kCaXVEvNJ9buuq4N2MS5qkNaRCnH7H8fL5VJ7a6JWqTWisjXH8eS6Cg5sq1vUPjf8iHockJ7L"
    ],
    "compression": "none",
    "packed_context_free_data": "",
    "context_free_data": [],
    "packed_trx": "9b692c5bba352ef352c200000000030000000000ea305500409e9a2264b89a01a09869fb519b876300000000a8ed323266a09869fb519b8763408d8bd328443155010000000100027f8751c1d2474bec3abc92df7074fd77a27a216ec9c4a122420994ff84affb9201000000010000000100027f8751c1d2474bec3abc92df7074fd77a27a216ec9c4a122420994ff84affb92010000000000000000ea305500b0cafe4873bd3e01a09869fb519b876300000000a8ed323214a09869fb519b8763408d8bd328443155002000000000000000ea305500003f2a1ba6a24a01a09869fb519b876300000000a8ed323231a09869fb519b8763408d8bd328443155e80300000000000004454f5300000000a00f00000000000004454f53000000000100",
    "transaction": {
      "expiration": "2018-06-22T03:14:35",
      "ref_block_num": 13754,
      "ref_block_prefix": 3260216110,
      "max_net_usage_words": 0,
      "max_cpu_usage_ms": 0,
      "delay_sec": 0,
      "context_free_actions": [],
      "actions": [
        {
          "account": "eosio",
          "name": "newaccount",
          "authorization": [
            {
              "actor": "gi3tqojvhage",
              "permission": "active"
            }
          ],
          "data": {
            "creator": "gi3tqojvhage",
            <!--创建的新账户名称-->
            "name": "eosoceanliao",
            "owner": {
              "threshold": 1,
              "keys": [
                {
                  "key": "EOS5reuB1G1qRp6yySavMLTdPFouuWXU4YXZtJjrEG5mQkYAoTAjy",
                  "weight": 1
                }
              ],
              "accounts": [],
              "waits": []
            },
            "active": {
              "threshold": 1,
              "keys": [
                {
                  "key": "EOS5reuB1G1qRp6yySavMLTdPFouuWXU4YXZtJjrEG5mQkYAoTAjy",
                  "weight": 1
                }
              ],
              "accounts": [],
              "waits": []
            }
          },
          "hex_data": "a09869fb519b8763408d8bd328443155010000000100027f8751c1d2474bec3abc92df7074fd77a27a216ec9c4a122420994ff84affb9201000000010000000100027f8751c1d2474bec3abc92df7074fd77a27a216ec9c4a122420994ff84affb9201000000"
        },
        {
          "account": "eosio",
          "name": "buyrambytes",
          "authorization": [
            {
              "actor": "gi3tqojvhage",
              "permission": "active"
            }
          ],
          "data": {
            "payer": "gi3tqojvhage",
            "receiver": "eosoceanliao",
            "bytes": 8192
          },
          "hex_data": "a09869fb519b8763408d8bd32844315500200000"
        },
        {
          "account": "eosio",
          "name": "delegatebw",
          "authorization": [
            {
              "actor": "gi3tqojvhage",
              "permission": "active"
            }
          ],
          "data": {
            "from": "gi3tqojvhage",
            "receiver": "eosoceanliao",
            "stake_net_quantity": "0.1000 EOS",
            "stake_cpu_quantity": "0.4000 EOS",
            "transfer": 1
          },
          "hex_data": "a09869fb519b8763408d8bd328443155e80300000000000004454f5300000000a00f00000000000004454f530000000001"
        }
      ],
      "transaction_extensions": []
    }
  }
}
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 202,802评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,109评论 2 379
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,683评论 0 335
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,458评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,452评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,505评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,901评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,550评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,763评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,556评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,629评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,330评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,898评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,897评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,140评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,807评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,339评论 2 342

推荐阅读更多精彩内容