10.24 push summary - Agzs/geth-pbft-study GitHub Wiki

consensus/pbft/external.go

从fabric中copy该文件,用于stateUpdateEventstateUpdatedEvent的定义,该事件的处理待完善。。。

consensus/pbft/helper.go

该文件为新添加文件,该文件定义Helper,如下:

type Helper struct {
	valid   bool           // Whether we believe the state is up to date
	manager events.Manager //=> helper.manager == pbft.manager == protocolManager.pbftManager
	databaseHelper         //=> replaced persist.Helper --Agzs
	blockchainHelper *core.BlockChain //=> add ethHelper for get blockchain info --Agzs

}

自定义一些函数:InvalidateState()ValidateState()skipTo()getValidatorHandle()getValidatorHandles() UpdateState()getState(),这些函数涉及pbftCore的成员变量,原先通过instance.consumer.XXX()调用,目前暂定义为helper的方法

consensus/pbft/external.go

从fabric中导入该文件,用于定义stateUpdateEventstateUpdatedEvent事件,stateUpdatedEvent在processEvent()中处理,目前只有接收该事件并处理,还没有发送该事件的操作;stateUpdateEvent目前只有发送操作,还没有处理操作。 待完善。。。

fabric中,先发送stateUpdateEvent事件,接收后进行操作,然后会发送stateUpdatedEvent事件,不过涉及到batch,需要进一步研究

consensus/pbft/pbft-persist.go

沿用fabric中的函数,将其中protoMarshalUnmarshal全部替换为jsonMarshalUnmarshal,部分函数进行了重写,将该文件中间接调用的函数定义在persist.go文件中,通过helper调用。

consensus/pbft/persist.go

继续沿用fabric的gorocksdb,并没有将fabric下的db.go文件复制到get-pbft,而是通过导包解决import "github.com/hyperledger/fabric/core/db",将该文件中的Helper更改为databaseHelper,作为helper.goHelper的成员变量

之前尝试将db.go文件放到geth-pbft中,但是一直报错。

安装rocksdb

gorocksdb包

core/types/peer_message.go

fabric.pb.go中复制而来,注意,一定要注释其中的所有和block相关的,否则会和ethereum中的block发生冲突,该文件的使用需要后期进一步研究,只是在恢复viewchange的过程中,需要用到该文件中部分定义。