昨天HiBlock區塊鏈社區「超級帳本討論羣」的小夥伴們在討論是用Hyperledger的Fabric更好,仍是Composer更方便。有小夥伴提出,在討論這個以前仍是得先了解這二者到底有什麼關係。正好社區「技術佈道小組」有成員產出了一篇文章,本期《區塊鏈100講》就借這篇文章來看看Hyperledger的Composer和Fabric究竟是什麼關係。node
總之web
Hyperledger Composer是屬於Hyperledger下的,包含了開發構架,和工具的開源項目。api
團隊的目的是爲了簡化blockchain applications開發過程當中,一部分開發過程。微信
Hyperledger Composer本來是爲了抽象出接口,能夠和任何區塊鏈網絡對聯,但目前的開發情況基本上是基於Hyperledger Fabric來實現的。網絡
Hyperledger Composer is an extensive, open development toolset and framework to make developing blockchain applications easier. Our primary goal is to accelerate time to value, and make it easier to integrate your blockchain applications with the existing business systems. You can use Composer to rapidly develop use cases and deploy a blockchain solution in weeks rather than months. Composer allows you to model your business network and integrate existing systems and data with your blockchain applications.app
關係composer
關係圖less
Composer Diagram 圖片來自官方網模塊化
上面的部分,就是Composer,經過一些腳本(JS的童鞋開心了吧 )語言,來定義須要的內容(參與方,CA,資產,交易等),而後打包成.bna文件,就能夠直接部署(到Fabric私有鏈網絡上)了。工具
至於本來Fabric實現的時候,須要本身實現的區塊鏈讀寫操做等,Composer都爲你實現好了。
栗子
一家房地產商能夠這樣子模塊化(定義)他們的業務:
Assets: 房屋,土地等
Participants: 買房者,賣房者,中介
Transactions: 買,賣等
參與方都根據在交易裏的角色,才能夠查詢和查詢相關的交易。 房地產商能夠提供一些接口,好比給賣方:公開房源,關閉房源等。
比較
Innovation That Matters(https://blog.selman.org/2017/07/08/getting-started-with-blockchain-development/)
It isn’t possible to make a complete apples-to-apples comparison, because the Go version of Marbles includes queries, whereas the Composer version does not, however it is clear that the Composer version is far shorter and includes much less boilerplate code:
marbles_chaincode.go : 627 lines
Composer marbles-network : 63 lines total, 26 lines (logic), 37 lines (model)
This ±10x reduction in the number of lines of code when Go and Composer solutions are compared is fairly consistent across several samples.
Composer includes several other major features and productivity enhancements:
business networks are automatically exposed as OpenAPI (Swagger) REST APIs via the composer-rest-server. The composer-rest-server uses passport.js to support pluggable end-user authentication schemes.
Composer includes a declarative Access Control Language, allowing developers to define which participants have access to which assets and under which circumstances. Composer ACLs drastically reduce the amount of procedural access control checks required in business logic.
Use the Composer Node-RED nodes to integrate Composer with IoT, analytics, dashboards etc.
VSCode extension to validate Composer model, ACL and query files
Integrate Composer with industry leading BPM and Integration tools, via OpenAPI and the LoopBack connector
Unit test using the Node.js embedded Composer runtime using standard JS tools like Mocha, Chai, Sinon, Istambul etc
Develop and test on the web interactively using the Composer Playground, simulating the blockchain in the browser, or connected to a Fabric.
Generate skeleton Angular web application from a business network definition
Publish and reuse models across business networks
There are of course some advantages to coding in Go to the Fabric APIs directly:
follow the absolute latest evolutions in the Fabric APIs and capabilities
possibly better raw performance, although for most application chaincode performance is unlikely to be the determining factor
type-safety
single language for both business logic and model
can incorporate third-party C and Go libraries easily
In summary I believe that for 90% of business developers Hyperledger Composer is the right choice to get started with blockchain development. It allows them to focus on the business logic, and avoids a lot of error-prone boilerplate code. They will also benefit from many of the higher-level tools and abstractions that Composer has to offer.
本文做者:HiBlock區塊鏈技術佈道羣-AmyWu
原文發佈於簡書
加微信baobaotalk_com,加入技術佈道羣
活動推薦
掃描下圖中二維碼或點擊「閱讀原文」便可報名參加