consensus

package
v0.0.0-...-17e6b21 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsensusState

type ConsensusState struct {
	Height     int64
	Round      int32
	Step       string
	Proposal   *Proposal
	Prevotes   map[string]*Vote
	Precommits map[string]*Vote
}

type Node

type Node struct {
	ID      string
	Address string
	PubKey  []byte
}

type PBFTConsensus

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

func NewPBFTConsensus

func NewPBFTConsensus(nodeID string, nodes map[string]Node, tracer tracing.Tracer) *PBFTConsensus

func (*PBFTConsensus) ProcessRequest

func (p *PBFTConsensus) ProcessRequest(ctx context.Context, request []byte) error

type PBFTState

type PBFTState int
const (
	PrePrepare PBFTState = iota
	Prepare
	Commit
)

type Proposal

type Proposal struct {
	Height    int64
	Round     int32
	BlockID   []byte
	Timestamp time.Time
	Signature []byte
}

type RaftConfig

type RaftConfig struct {
	NodeID           string
	RaftDir          string
	RaftBind         string
	JoinAddrs        []string
	RetainLogs       int
	SnapshotInterval time.Duration
}

type RaftConsensus

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

func NewRaftConsensus

func NewRaftConsensus(config RaftConfig, tracer tracing.Tracer) (*RaftConsensus, error)

func (*RaftConsensus) ApplyLog

func (r *RaftConsensus) ApplyLog(ctx context.Context, data []byte) (interface{}, error)

func (*RaftConsensus) GetLeader

func (r *RaftConsensus) GetLeader(ctx context.Context) (string, error)

type TendermintConsensus

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

func NewTendermintConsensus

func NewTendermintConsensus(nodeID string, validators map[string]ValidatorInfo, tracer tracing.Tracer) *TendermintConsensus

func (*TendermintConsensus) ProcessProposal

func (t *TendermintConsensus) ProcessProposal(ctx context.Context, proposal *Proposal) error

func (*TendermintConsensus) ProcessVote

func (t *TendermintConsensus) ProcessVote(ctx context.Context, vote *Vote) error

type ValidatorInfo

type ValidatorInfo struct {
	Address     string
	PubKey      []byte
	VotingPower int64
}

type Vote

type Vote struct {
	Height    int64
	Round     int32
	Type      string
	BlockID   []byte
	Timestamp time.Time
	Signature []byte
}

Jump to

Keyboard shortcuts

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