util

package
v0.0.0-...-89de7d0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidVote = errors.New("invalid message type to change vote")
)

Functions

func GetChainID

func GetChainID(r *types.Replica) (string, error)

func GetPrivKey

func GetPrivKey(r *types.Replica) (crypto.PrivKey, error)

Should cache key instead of decoding everytime

func GetProposalBlockID

func GetProposalBlockID(msg *TMessage) (*ttypes.BlockID, bool)

func GetProposalBlockIDS

func GetProposalBlockIDS(msg *TMessage) (string, bool)

func GetReplicaAddress

func GetReplicaAddress(r *types.Replica) ([]byte, error)

func GetVoteBlockID

func GetVoteBlockID(msg *TMessage) (*ttypes.BlockID, bool)

func GetVoteBlockIDS

func GetVoteBlockIDS(msg *TMessage) (string, bool)

func GetVoteTime

func GetVoteTime(msg *TMessage) (time.Time, bool)

func GetVoteValidator

func GetVoteValidator(msg *TMessage) ([]byte, bool)

func IsVoteFrom

func IsVoteFrom(msg *TMessage, replica *types.Replica) bool

Types

type GenericPartitioner

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

func NewGenericPartitioner

func NewGenericPartitioner(replicasStore *types.ReplicaStore) *GenericPartitioner

func (*GenericPartitioner) CreatePartition

func (g *GenericPartitioner) CreatePartition(sizes []int, labels []string) (*Partition, error)

type MessageType

type MessageType string
const (
	NewRoundStep  MessageType = "NewRoundStep"
	NewValidBlock MessageType = "NewValidBlock"
	Proposal      MessageType = "Proposal"
	ProposalPol   MessageType = "ProposalPol"
	BlockPart     MessageType = "BlockPart"
	Vote          MessageType = "Vote"
	Prevote       MessageType = "Prevote"
	Precommit     MessageType = "Precommit"
	HasVote       MessageType = "HasVote"
	VoteSetMaj23  MessageType = "VoteSetMaj23"
	VoteSetBits   MessageType = "VoteSetBits"
	None          MessageType = "None"
)

type Part

type Part struct {
	ReplicaSet *ReplicaSet
	Label      string
}

func (*Part) Contains

func (p *Part) Contains(replica types.ReplicaID) bool

func (*Part) ContainsVal

func (p *Part) ContainsVal(addr []byte) bool

func (*Part) Size

func (p *Part) Size() int

func (*Part) String

func (p *Part) String() string

type Partition

type Partition struct {
	Parts map[string]*Part
	// contains filtered or unexported fields
}

func NewPartition

func NewPartition(parts ...*Part) *Partition

func (*Partition) GetPart

func (p *Partition) GetPart(label string) (*Part, bool)

func (*Partition) String

func (p *Partition) String() string

type ReplicaSet

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

func NewReplicaSet

func NewReplicaSet() *ReplicaSet

func (*ReplicaSet) Add

func (r *ReplicaSet) Add(replica *types.Replica)

func (*ReplicaSet) Exists

func (r *ReplicaSet) Exists(id types.ReplicaID) bool

func (*ReplicaSet) ExistsVal

func (r *ReplicaSet) ExistsVal(addr []byte) bool

func (*ReplicaSet) GetRandom

func (r *ReplicaSet) GetRandom() *types.Replica

func (*ReplicaSet) Iter

func (r *ReplicaSet) Iter() []types.ReplicaID

func (*ReplicaSet) Size

func (r *ReplicaSet) Size() int

func (*ReplicaSet) String

func (r *ReplicaSet) String() string

type TMessage

type TMessage struct {
	ChannelID uint16          `json:"chan_id"`
	MsgB      []byte          `json:"msg"`
	From      types.ReplicaID `json:"from"`
	To        types.ReplicaID `json:"to"`
	Type      MessageType     `json:"-"`
	Data      *tmsg.Message   `json:"-"`
}

func ChangeProposalBlockIDToNil

func ChangeProposalBlockIDToNil(replica *types.Replica, pMsg *TMessage) (*TMessage, error)

func ChangeProposalLockedValue

func ChangeProposalLockedValue(replica *types.Replica, pMsg *TMessage) (*TMessage, error)

func ChangeVote

func ChangeVote(replica *types.Replica, tMsg *TMessage, blockID *ttypes.BlockID) (*TMessage, error)

func ChangeVoteRound

func ChangeVoteRound(replica *types.Replica, tMsg *TMessage, round int32) (*TMessage, error)

func ChangeVoteTime

func ChangeVoteTime(replica *types.Replica, tMsg *TMessage, add time.Duration) (*TMessage, error)

func ChangeVoteToNil

func ChangeVoteToNil(replica *types.Replica, voteMsg *TMessage) (*TMessage, error)

func GetMessageFromEvent

func GetMessageFromEvent(e *types.Event, ctx *testlib.Context) (*TMessage, bool)

func GetParsedMessage

func GetParsedMessage(m *types.Message) (*TMessage, bool)

func (*TMessage) Clone

func (t *TMessage) Clone() types.ParsedMessage

func (*TMessage) Height

func (t *TMessage) Height() int

func (*TMessage) HeightRound

func (t *TMessage) HeightRound() (int, int)

func (*TMessage) Marshal

func (t *TMessage) Marshal() ([]byte, error)

func (*TMessage) Round

func (t *TMessage) Round() int

func (*TMessage) String

func (t *TMessage) String() string

type TMessageParser

type TMessageParser struct {
}

func (*TMessageParser) Parse

func (p *TMessageParser) Parse(m []byte) (types.ParsedMessage, error)

Jump to

Keyboard shortcuts

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