libs

package
v0.0.0-...-b6e904f Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConsensusModule  = "consensus"
	ConsensusChannel = int32(0)

	HotstuffChaindStep = 3
)

Variables

View Source
var (
	ErrValNotFound     = errors.New("cannot find target, it's a nil pointer or an empty value struct")
	ErrWrongElement    = errors.New("element type invalid, check parameters")
	ErrParentEmptyNode = errors.New("node's parent is empty")
	ErrOrphanNode      = errors.New("cannot find the location where the node can be inserted")
	ErrRepeatInsert    = errors.New("key has been inserted before")
)
View Source
var (
	IDToModuleMap = map[int32]string{
		ConsensusChannel: ConsensusModule,
	}
)

Functions

func F

func F(input []byte) string

func FileIsExist

func FileIsExist(name string) bool

func GenRandomID

func GenRandomID() uint64

func GetCurExecDir

func GetCurExecDir() string

func GetCurRootDir

func GetCurRootDir() string

func GetSum

func GetSum(b []byte) string

func MakeDir

func MakeDir(name string) error

func SetRootDir

func SetRootDir(path string)

Types

type Config

type Config struct {
	Host      string   `yaml:"host,omitempty"`
	Module    string   `yaml:"module,omitempty"`
	Filename  string   `yaml:"filename,omitempty"`
	Address   string   `yaml:"address,omitempty"`
	Bootstrap []string `yaml:"bootstrap,omitempty"`
	Netpath   string   `yaml:"netpath,omitempty"`
	Keypath   string   `yaml:"keypath,omitempty"`

	// TODO: loading WAL instead of configuration
	Round      int      `yaml:"round,omitempty"`
	Startk     string   `yaml:"startk,omitempty"`
	Startv     string   `yaml:"startv,omitempty"`
	Validators []string `yaml:"validators,omitempty"`
}

func GetConfig

func GetConfig(cfgFile string) (*Config, error)

type Logger

type Logger interface {
	Error(msg string, ctx ...interface{})
	Warn(msg string, ctx ...interface{})
	Info(msg string, ctx ...interface{})
	Trace(msg string, ctx ...interface{})
	Debug(msg string, ctx ...interface{})
}

Logger is what any go-hotstuff library should take.

type Reactor

type Reactor interface {
	HandleFunc(chID int32, msgBytes []byte)
	SetSwitch(sw Switch)
}

type Switch

type Switch interface {
	Broadcast(chID int32, msgBytes []byte)
	Send(peerID string, chID int32, msgBytes []byte) error
	GetP2PID(peerID string) (string, error)
}

Jump to

Keyboard shortcuts

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