如何在Hyperledger Fabric中编写自己的共识?

问题描述:

我想使用Hyperledger Fabric.但是我需要一个特殊的共识算法.我已经准备好了这个概念,但不知道如何在Fabric中实现它.

I want to use Hyperledger Fabric. But I need a special consensus algorithm. I have the concept ready but no idea how to get it implemented in Fabric.

文档说:

共识插件需要实现共识和链 共识包中定义的接口.有两个插件 已针对这些界面构建:solo和kafka.你可以学习 他们会为自己的实施提供线索.订购服务 代码可以在订购包中找到.

A consensus plugin needs to implement the Consenter and Chain interfaces defined in the consensus package. There are two plugins built against these interfaces already: solo and kafka. You can study them to take cues for your own implementation. The ordering service code can be found under the orderer package.

第一个问题:是否可以编写我自己的共识方法并在Hyperledger Fabric中运行?第二:如果是,我应该如何开始?

First question: Is it possible to code my own consensus method and run it in Hyperledger Fabric? Second: If yes, how should I start?

我认为您已经回答了自己的问题. Hyperledger Fabric中的共识算法由订购服务实现.因此,要实现新算法,您需要编写一个新的共识包,将其添加到Ordering服务中,并构建一个新的Fabric运行时分支.

I think you've just about answered your own question. The consensus algorithms in Hyperledger Fabric are implemented by the Ordering service. So, to implement a new algorithm, you would need to code a new consensus package, add this to the Ordering service, and a build a new fork of the fabric runtime.

使用现有的实现之一作为起点(solo或kafka),然后开始吧! :)

Use one of the existing implementations as a starting point (solo or kafka), and have at it! :)