找回密码
 立即注册

扫一扫,登录网站

首页 自媒体 查看内容
  • 2672
  • 0
  • 分享到

Hyperledger的区块结构:交易是怎么存入区块的 如何存入LevelDB

2018-7-5 14:27

来源: Uni-times


编者按


学习比特币和以太坊,必先学习其区块结构。

之前学习比特币和以太坊,必先学习其区块结构,当时在银行做Hyperledger相关项目时,我却对结构很忽略,只关心智能合约,居然也能初步掌握并开始项目相关的开发。这说明超级账本的区块属性其实比较弱,重要的是智能合约的属性。性能也不错。从这个意义上讲Hyperledger用来做存证是大材小用的。


问题1:交易是怎么存入区块的?


Transactions are collected into blocks/batches on the ordering service first. Blocks are cut either when the BatchSize is met, or when BatchTimeout elapses (provided a non-empty block).


也就是说,满足这2个条件,区块生成了:


交易数量够了

超时时间到了


所以Hyperledger的区块生成不是定时的,高峰时间,区块生成速度明显加快


configtx.yaml in the common/configtx/tool/ directory for more info on the block-cutting criteria.

The Block type definition in protos/common/common.proto



和以太坊一样,hyperledger的区别,也有区块号、指向前一个区块的指针、指向数据的指针,因为没有挖矿,头部简洁了很多。


// This is finalized block structure to be shared among the orderer and peer


// Note that the BlockHeader chains to the previous BlockHeader, and the

BlockData hash is embedded


// in the BlockHeader.  This makes it natural and obvious that the Data is included in the hash, but


// the Metadata is not.


message Block {


}


// BlockHeader is the element of the block which forms the block chain


// The block header is hashed using the configured chain hashing algorithm


// over the ASN.1 encoding of the BlockHeader


message BlockHeader {


}

message BlockData {


}


message BlockMetadata {


}


问题2:怎么存入LevelDB


These blocks are stored locally to disk on every ordering service node along with a LevelDB to index these blocks by number – see orderer/ledger/file



作者:郑泽洲

原文链接:

http://www.blockchainbrother.com/article/893

版权申明:本内容来自于互联网,属第三方汇集推荐平台。本文的版权归原作者所有,文章言论不代表链门户的观点,链门户不承担任何法律责任。如有侵权请联系QQ:3341927519进行反馈。
相关新闻
发表评论

请先 注册/登录 后参与评论

    回顶部