1. Primary Schema Relationships
下圖說明了數(shù)據(jù)庫中各集合的主要的schemas: 區(qū)塊, Transaction, Message, and 賬戶. 為提高讀寫性能,降低總體的存儲需要,我們選擇了不要denormalize并且把這些不同的entities nest起來展示他們的關(guān)系。這里同時展示了各個集合的主鍵及其外鍵。
約定
- 主鍵和外鍵的字段名應(yīng)以
_id
結(jié)尾, 除非是一個keys的列表,如果是列表情況下字段名應(yīng)當(dāng)是列表中包含的對象的schema類型的復(fù)數(shù)形式。
2. 區(qū)塊
字段名 |
類型 |
Ref ID |
描述 |
id |
String |
PK |
系統(tǒng)中唯一的id |
block_num |
Integer |
|
區(qū)塊的順序id |
previous |
String |
FK |
前一個區(qū)塊SHA256值 |
timestamp |
MongoDB Date (timestamp) |
|
Scheduled time |
transaction_merkle_root |
String |
|
區(qū)塊產(chǎn)生時的校驗和(SHA256) |
producer |
String |
FK |
區(qū)塊生產(chǎn)者的賬戶名 |
producer_signature |
String |
|
|
transactions |
[ObjectId,...] |
|
和此區(qū)塊相關(guān)的transaction ids |
ref_block_prefix |
Integer |
|
|
producer_changes |
Array |
|
生產(chǎn)者列表的變化 |
例子
{
"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 |
系統(tǒng)唯一id |
ref_block_num |
Integer |
|
引用的區(qū)塊數(shù)量 |
ref_block_prefix |
Integer |
|
Reference block header |
expiration |
String |
|
transaction過期時間 |
scope |
Array |
|
涉及的賬戶范圍 |
transaction_merkle_root |
String |
|
區(qū)塊產(chǎn)生時的校驗和(SHA256) |
producer_account_id |
String |
FK |
區(qū)塊生產(chǎn)者名稱 |
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 |
|
授權(quán)的賬戶及其permission |
data |
Nested document |
|
一個nested文檔,任何格式,因使用它的message而不同 |
hex_data |
String |
|
data的16進(jìn)制表示 |
例子
"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 |
授權(quán)賬戶名 |
permission |
Permission |
|
用于授權(quán)的賬戶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結(jié)構(gòu) |
例子
{
"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": []
}
}
]
}