EOS的區(qū)塊、交易、Action的結(jié)構(gòu)解析

在EOS數(shù)據(jù)庫中每個集合的主要模式由四個部分構(gòu)成:

  • Block-區(qū)塊
  • Transaction-交易
  • Action-動作
  • Account-賬戶

熟悉eos的人就會知道,它們主體之間的關(guān)系是:一個區(qū)塊由多筆交易組成,而一筆交易之中,又可能包含多條Action. 區(qū)塊與交易,交易與Action, 是一對多的關(guān)系。

在EOSwiki文檔中,可以看到如下的一張圖,也全面闡述了它們之間的關(guān)系:[注意圖中Message的說法現(xiàn)在已經(jīng)由Action替換]。


block.png

通過網(wǎng)址: http://eostracker.io/ 我們可以直觀的查找到eos的區(qū)塊和交易結(jié)構(gòu),下面我們對查詢的到數(shù)據(jù)json來進(jìn)行結(jié)構(gòu)分析。

(1)查詢區(qū)塊1978398,可以看到其中包含一筆交易信息

{
  <!--時間戳-->
  "timestamp": "2018-06-22T02:58:49.500",
  <!--區(qū)塊生產(chǎn)者-->
  "producer": "eoscannonchn",
  "confirmed": 0,
  <!--向前區(qū)塊信息-->
  "previous": "001e301d169f21f6f50924d5be192da9a34ea7bc6ef160f229f51c920ac953e1",
  <!--交易 Merkle根節(jié)點(diǎn)-->
  "transaction_mroot": "93fdc20c3150b2edd57e52a2134f2b528712e8924ddc5bdb4c06def977d9e5b1",
  <!--Action Merkle根節(jié)點(diǎn)-->
  "action_mroot": "e1cdf2061cd73ad64fdeed34a219e25804a14de096e340178bdc3d3a102fdd5f",
  "schedule_version": 45,
  "new_producers": null,
  "header_extensions": [],
  <!--生產(chǎn)者簽名-->
  "producer_signature": "SIG_K1_KktSfFNrE3PinW1k87Bvwd6f61gEcsifqpincwpwupLjCoZHEDt6hxAz9mCyv8Kf194Zq7kbFMMDbHUBmoXKYKC3e1euJu",
  <!--區(qū)塊交易信息-->
  "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",
              <!--授權(quán)-->
              "authorization": [
                {
                  "actor": "vplhrievkicr",
                  "permission": "active"
                }
              ],
              <!--action 主體數(shù)據(jù)-->
              "data": {
                <!--投票者-->
                "voter": "vplhrievkicr",
                "proxy": "",
                <!--被投節(jié)點(diǎn)-->
                "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": [],
  <!--區(qū)塊ID-->
  "id": "001e301e50665f777daf0b78ee50b0bf4e6171fb99b75222c5216c6fd7f331de",
  <!--區(qū)塊計(jì)數(shù)-->
  "block_num": 1978398,
  "ref_block_prefix": 2014031741
}

(2)下面的json數(shù)據(jù)是記錄了一個完整的交易,這筆交易中只包含了一個action,action為: voteproducer(節(jié)點(diǎn)投票)。

交易內(nèi)容為: 賬戶名gu4dgmjxgyge對兩個節(jié)點(diǎn)bitfinexeos1和eosisgravity進(jìn)行了投票

{
  "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數(shù)據(jù)同樣記錄了一個完整的交易,這筆交易中包含了3個action,action分別為 newaccount(創(chuàng)建賬戶)、buyrambytes(購買內(nèi)存)、delegatebw();

交易內(nèi)容為:賬戶gi3tqojvhage創(chuàng)建了一個新賬號eosoceanliao, 并對新賬戶eosoceanliao執(zhí)行了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",
            <!--創(chuàng)建的新賬戶名稱-->
            "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": []
    }
  }
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容