raft

package
v0.1.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MemCache = cache.NewMemCache("raft", 0, 0)

Functions

This section is empty.

Types

type RaftConsensus

type RaftConsensus struct {
	consensus.Consensus
}

func GetRaftConsensus

func GetRaftConsensus() *RaftConsensus

func (*RaftConsensus) ReceiveCommited

func (this *RaftConsensus) ReceiveCommited(chainMessage *entity3.ChainMessage) (*entity3.ChainMessage, error)

*

  • follow收到commited消息,完成后,向leader发送reply消息,
  • 这里与pbft的差异是不用判断,完成后reply消息发送给leader,而不是发给客户端

func (*RaftConsensus) ReceiveConsensus

func (this *RaftConsensus) ReceiveConsensus(chainMessage *entity3.ChainMessage) (*entity3.ChainMessage, error)

*

  • leader 收到消息请求,向每个follow发送preprepared消息,实现与pbft一样 *
  • @param chainMessage
  • @return

func (*RaftConsensus) ReceivePrepared

func (this *RaftConsensus) ReceivePrepared(chainMessage *entity3.ChainMessage) (*entity3.ChainMessage, error)

* leader收到prepared消息,计算是否到达提交标准,向follow发送commited消息 与pbft的差异是只有leader能收到这种消息

func (*RaftConsensus) ReceivePreprepared

func (this *RaftConsensus) ReceivePreprepared(chainMessage *entity3.ChainMessage) (*entity3.ChainMessage, error)

* follow收到Preprepared消息,准备完成后向leader发送prepared消息

func (*RaftConsensus) ReceiveReply

func (this *RaftConsensus) ReceiveReply(chainMessage *entity3.ChainMessage) (*entity3.ChainMessage, error)

* leader收到reply消息,判断完成后向客户就返回reply消息 与pbft的差异是pbft在上一步就完成了向客户端发送reply

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL