raft

package
v1.64.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: BSD-3-Clause Imports: 30 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRaftCluster

func NewRaftCluster(cfg *types.Consensus, sub []byte) queue.Module

NewRaftCluster create raft cluster

Types

type BlockInfo

type BlockInfo struct {
	Height int64  `json:"height"`
	Hash   string `json:"hash"`
}

BlockInfo struct

type Client

type Client struct {
	*drivers.BaseClient
	// contains filtered or unexported fields
}

Client Raft implementation

func NewBlockstore

func NewBlockstore(ctx context.Context, cfg *types.Consensus, snapshotter *snap.Snapshotter, proposeC chan<- BlockInfo, commitC <-chan *BlockInfo, errorC <-chan error, validatorC <-chan bool, cancel context.CancelFunc) *Client

NewBlockstore create Raft Client

func (*Client) CheckBlock

func (client *Client) CheckBlock(parent *types.Block, current *types.BlockDetail) error

CheckBlock method

func (*Client) CheckBlockInfo

func (client *Client) CheckBlockInfo(info *BlockInfo) bool

CheckBlockInfo check corresponding block

func (*Client) Close

func (client *Client) Close()

Close method

func (*Client) CmpBestBlock

func (client *Client) CmpBestBlock(newBlock *types.Block, cmpBlock *types.Block) bool

比较newBlock是不是最优区块

func (*Client) CreateBlock

func (client *Client) CreateBlock()

CreateBlock method

func (*Client) CreateGenesisTx

func (client *Client) CreateGenesisTx() (ret []*types.Transaction)

CreateGenesisTx get genesis tx

func (*Client) GetCurrentInfo

func (client *Client) GetCurrentInfo() *BlockInfo

GetCurrentInfo ...

func (*Client) GetCurrentInfoHeight

func (client *Client) GetCurrentInfoHeight() int64

GetCurrentInfoHeight ...

func (*Client) GetGenesisBlockTime

func (client *Client) GetGenesisBlockTime() int64

GetGenesisBlockTime get genesis blocktime

func (*Client) ProcEvent

func (client *Client) ProcEvent(msg *queue.Message) bool

ProcEvent method

func (*Client) SetCurrentInfo

func (client *Client) SetCurrentInfo(info *BlockInfo)

SetCurrentInfo ...

func (*Client) SetQueueClient

func (client *Client) SetQueueClient(c queue.Client)

SetQueueClient method

type Node

type Node struct {
	// contains filtered or unexported fields
}

func NewRaftNode

func NewRaftNode(ctx context.Context, id int, join bool, peers []string, readOnlyPeers []string, addPeers []string, getSnapshot func() ([]byte, error), proposeC <-chan BlockInfo,
	confChangeC <-chan raftpb.ConfChange) (*Node, <-chan *BlockInfo, <-chan error, <-chan *snap.Snapshotter, <-chan bool)

NewRaftNode create raft node

func (Node) IsIDRemoved

func (rc Node) IsIDRemoved(id uint64) bool

func (Node) Process

func (rc Node) Process(ctx context.Context, m raftpb.Message) error

func (Node) ReportSnapshot

func (rc Node) ReportSnapshot(id uint64, status raft.SnapshotStatus)

func (Node) ReportUnreachable

func (rc Node) ReportUnreachable(id uint64)

func (*Node) SetClient

func (node *Node) SetClient(client *Client)

func (Node) Status

func (rc Node) Status() raft.Status

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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