在EOS数据库中每个集合的主要模式由四个部分构成:
- Block-区块
- Transaction-交易
- Action-动作
- Account-账户
熟悉eos的人就会知道,它们主体之间的关系是:一个区块由多笔交易组成,而一笔交易之中,又可能包含多条Action. 区块与交易,交易与Action, 是一对多的关系。
在EOSwiki文档中,可以看到如下的一张图,也全面阐述了它们之间的关系:[注意图中Message的说法现在已经由Action替换]。
通过网址: 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": []
}
}
}