数据模型

The Transaction Model

交易的结构

{
"id": "<hash of transaction, excluding signatures>",
"version": "<version number of the transaction model>",
"inputs": ["<list of inputs>"],
"outputs": ["<list of outputs>"],
"operation": "<string>",
"asset": "<asset model>",
"metadata": "<any JSON document>"
}
  • id: 交易的id,也数据库的主键
  • version:Version number of the transaction model
  • inputs:
  • outputs:
  • operation:正在执行的操作的字符串表示形式,可以是“CREATE”, “TRANSFER” 或者 “GENESIS”
  • asset:定义的资产
  • metadata:用户提供的交易元数据,可以是任何JSON文档,也可以是NULL

The Asset Model

为了避免交易中的冗余数据,对于CREATE and TRANSFER交易,资产模型是不同的。
在 CREATE 交易中,“资产”必须正好包含一个键-值对,键必须是“data”,值可以是任何有效的JSON文档,也可以是null
在 TRANSFER 交易中,“资产”必须正好包含一个键-值对。键必须是“id”,值必须包含交易id。the ID of the CREATE transaction which created the asset, which also serves as the asset ID

Inputs and Outputs

pass

The Block Model

区块的结构

{
    "id": "<hash of block>",
    "block": {
        "timestamp": "<block-creation timestamp>",
        "transactions": ["<list of transactions>"],
        "node_pubkey": "<public key of the node creating the block>",
        "voters": ["<list of public keys of all nodes in the cluster>"]
    },
    "signature": "<signature of block>"
}

  • id: 序列化的内部块的散列
  • timestamp: 创建块的Unix时间, 它由创建块的节点提供
  • transactions: A list of the transactions included in the block
  • node_pubkey: The public key of the node that created the block
  • voters: 创建块时所有集群节点的公钥列表
  • signature: 创建块的节点对块的加密签名。为了生成签名,节点使用node_pubkey对应的私钥对序列化后的内部块进行签名

The Vote Model

投票的结构

{
    "node_pubkey": "<The public key of the voting node>",
    "vote": {
        "voting_for_block": "<ID of the block the node is voting on>",
        "previous_block": "<ID of the block previous to the block being voted on>",
        "is_block_valid": "<true OR false>",
        "invalid_reason": null,
        "timestamp": "<Unix time when the vote was generated, provided by the voting node>"
    },
    "signature": "<Cryptographic signature of vote>"
}

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容