1. Primary Schema Relationships
下图说明了数据库中各集合的主要的schemas: 区块, Transaction, Message, and 账户. 为提高读写性能,降低总体的存储需要,我们选择了不要denormalize并且把这些不同的entities nest起来展示他们的关系。这里同时展示了各个集合的主键及其外键。
约定
- 主键和外键的字段名应以
_id
结尾, 除非是一个keys的列表,如果是列表情况下字段名应当是列表中包含的对象的schema类型的复数形式。
2. 区块
字段名 |
类型 |
Ref ID |
描述 |
id |
String |
PK |
系统中唯一的id |
block_num |
Integer |
|
区块的顺序id |
previous |
String |
FK |
前一个区块SHA256值 |
timestamp |
MongoDB Date (timestamp) |
|
Scheduled time |
transaction_merkle_root |
String |
|
区块产生时的校验和(SHA256) |
producer |
String |
FK |
区块生产者的账户名 |
producer_signature |
String |
|
|
transactions |
[ObjectId,...] |
|
和此区块相关的transaction ids |
ref_block_prefix |
Integer |
|
|
producer_changes |
Array |
|
生产者列表的变化 |
例子
{
"previous": "000000099271295c7e73dcf268802491f8d7e715608a6ec8182f0d4c4d6921bf",
"timestamp": "2017-12-04T03:09:10",
"transaction_merkle_root": "0000000000000000000000000000000000000000000000000000000000000000",
"producer": "inita",
"producer_changes": [],
"producer_signature": "20621b7582a272a8ef15e0caa2590c279b706b851e9007ba558855c0b2844e0bb975481417ecbe7f3b5ffb488ec733f508c6455743bc26604d5f220bcd25e4f731",
"cycles": [],
"id": "0000000abf6baeb841293e7b6423f47e98517206595bbae4eb69281ca0501a57",
"block_num": 10,
"ref_block_prefix": 2067671361
}
3. Transaction
字段 |
类型 |
Ref ID |
描述 |
transaction_id |
ObjectId |
PK |
系统唯一id |
ref_block_num |
Integer |
|
引用的区块数量 |
ref_block_prefix |
Integer |
|
Reference block header |
expiration |
String |
|
transaction过期时间 |
scope |
Array |
|
涉及的账户范围 |
transaction_merkle_root |
String |
|
区块产生时的校验和(SHA256) |
producer_account_id |
String |
FK |
区块生产者名称 |
signatures |
Array |
|
签名列表 |
例子
{
"transaction_id": "f989025b959026f4d1e97346c0808b0fa316f7426384ce4ded83d52fde0404bf",
"transaction": {
"ref_block_num": 7284,
"ref_block_prefix": 1294303748,
"expiration": "2017-12-04T07:31:48",
"scope": [
"benchmark...3",
"benchmark...i"
],
"signatures": [
"1f58d30c249bebfca299d485636b1bf6836df9df4a362221648f433897170fb70f1dc8933f70936d82266534883d187ba39f6fa7a448e881803c8c7530ff3afb18"
]
4. Message
字段 |
类型 |
Ref ID |
描述 |
code |
String |
|
合约名称 |
type |
String |
|
action名称 |
authorization |
Nested_Document |
|
授权的账户及其permission |
data |
Nested document |
|
一个nested文档,任何格式,因使用它的message而不同 |
hex_data |
String |
|
data的16进制表示 |
例子
"messages": [{
"code": "eos",
"type": "transfer",
"authorization": [{
"account": "benchmark...i",
"permission": "active"
}
],
"data": {
"from": "benchmark...i",
"to": "benchmark...3",
"amount": 1,
"memo": "2017-12-04T07:31:19 1512372679244267"
},
"hex_data": "0e0080d7c886a63a030080d7c886a63a010000000000000024323031372d31322d30345430373a33313a31392031353132333732363739323434323637"
}
]
Authorization Nested 文档
字段 |
类型 |
Ref ID |
描述 |
account |
String |
FK |
授权账户名 |
permission |
Permission |
|
用于授权的账户Permission |
Example
"authorization": [{
"account": "benchmark...i",
"permission": "active"
}
]
5. 账户 (集合)
字段 |
类型 |
Ref ID |
描述 |
name |
String |
PK |
账户名 |
eos_balance |
String |
|
余额 |
staked_balance |
String |
|
Staked balance |
unstaking_balance |
String |
|
Unstaking balance |
last_unstaking_time |
Date (timestamp)) |
|
上次改动的时间戳 |
permissions |
[Nested document,...] |
|
Nested的permission结构 |
例子
{
"account_name": "inita",
"eos_balance": "999977.9995 EOS",
"staked_balance": "0.0000 EOS",
"unstaking_balance": "0.0000 EOS",
"last_unstaking_time": "1969-12-31T23:59:59",
"permissions": [{
"perm_name": "active",
"parent": "owner",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"weight": 1
}
],
"accounts": []
}
},{
"perm_name": "owner",
"parent": "",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"weight": 1
}
],
"accounts": []
}
}
]
}