common

package
v0.0.0-...-3442dc8 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeRole_Unknown   NodeRole = 0x00
	NodeRole_Executor           = 0x01
	NodeRole_Proposer           = 0x02
	NodeRole_Validator          = 0x04
	NodeRole_Archiver           = 0x08
)
View Source
const (
	EpochSpan = 300
)

Variables

View Source
var CurrentNetworkType = NetworkType_Testnet

Functions

func BytesCopy

func BytesCopy(src []byte) []byte

func BytesToNumber

func BytesToNumber(ptr interface{}, b []byte)

func BytesToUint64

func BytesToUint64(d []byte) uint64

func Clone

func Clone(dst, src interface{}) error

func CloneSlice

func CloneSlice(a [][]byte) [][]byte

func CreateDomainID

func CreateDomainID(seed string) string

func DeepCopyByGob

func DeepCopyByGob(dst, src interface{}) error

func GenerateRandomNumber

func GenerateRandomNumber(start int, end int, count int) []int

Generate count randon number in [start, end)

func Has0xPrefix

func Has0xPrefix(str string) bool

func IsContainItem

func IsContainItem(target interface{}, array []interface{}) bool

func IsContainString

func IsContainString(target string, str_array []string) bool

func IsHex

func IsHex(str string) bool

func IsHexCharacter

func IsHexCharacter(c byte) bool

func MinInt64

func MinInt64(x, y int64) int64

func MinUint64

func MinUint64(x, y uint64) uint64

func NewRandReader

func NewRandReader(seed string) (io.Reader, error)

func NodeIDs

func NodeIDs(nodeM []*NodeDomainMember) []string

func NumberToByte

func NumberToByte(number interface{}) []byte

func RemoveIfExistString

func RemoveIfExistString(target string, str_array []string) []string

func SafeAddUint64

func SafeAddUint64(a, b uint64) (uint64, error)

func SafeMul

func SafeMul(a uint64, b uint64) *big.Int

func SafeSubUint64

func SafeSubUint64(a, b uint64) (uint64, error)

func Uint64ToBytes

func Uint64ToBytes(v uint64) []byte

Types

type DomainType

type DomainType byte
const (
	DomainType_Unknown DomainType = iota
	DomainType_Execute
	DomainType_Consensus
)

type EpochInfo

type EpochInfo struct {
	Epoch          uint64
	StartTimeStamp uint64
	StartHeight    uint64
}

type Hasher

type Hasher interface {
	Compute(string) []byte
	Size() int
	Writer() io.Writer
	Bytes() []byte
	Reset()
}

func NewBlake2bHasher

func NewBlake2bHasher(size int) Hasher

type IterCBFunc

type IterCBFunc func(key interface{}, val interface{})

type LedgerState

type LedgerState byte
const (
	LedgerState_Uninitialized LedgerState = iota
	LedgerState_Genesis
	LedgerState_AutoInc
)

type NetworkType

type NetworkType byte
const (
	NetworkType_Unknown NetworkType = iota
	NetworkType_Mainnet
	NetworkType_Testnet
)

func (NetworkType) String

func (n NetworkType) String() string

func (NetworkType) Value

func (n NetworkType) Value(netType byte) NetworkType

type NodeConsensusDomain

type NodeConsensusDomain struct {
	Threshold    int
	NParticipant int
	PublicKey    []byte
	PubShares    [][]byte
	Members      []*NodeDomainMember
}

type NodeDomainInfo

type NodeDomainInfo struct {
	ID               string
	Type             DomainType
	ValidHeightStart uint64
	ValidHeightEnd   uint64
	CSDomainData     *NodeConsensusDomain
	ExeDomainData    *NodeExecuteDomain
}

type NodeDomainMember

type NodeDomainMember struct {
	NodeID   string
	NodeRole NodeRole
	Weight   uint64
}

type NodeExecuteDomain

type NodeExecuteDomain struct {
	Members []string //nodeIDs
}

type NodeInfo

type NodeInfo struct {
	NodeID        string
	Address       string
	Weight        uint64
	DKGPartPubKey string
	DKGPriShare   []byte
	Role          NodeRole
	State         NodeState
}

type NodeRole

type NodeRole uint64

func (NodeRole) String

func (n NodeRole) String() string

func (NodeRole) Value

func (n NodeRole) Value(role string) NodeRole

type NodeState

type NodeState byte
const (
	NodeState_Unknown NodeState = iota
	NodeState_Standby
	NodeState_Active
	NodeState_Frozen
)

type SeedRandReader

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

func NewSeedRandReader

func NewSeedRandReader(seed []byte) (*SeedRandReader, error)

func (*SeedRandReader) Read

func (srr *SeedRandReader) Read(p []byte) (n int, err error)

type ShrinkableMap

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

func NewShrinkMap

func NewShrinkMap() *ShrinkableMap

func (*ShrinkableMap) AllKeys

func (m *ShrinkableMap) AllKeys() []interface{}

func (*ShrinkableMap) Del

func (m *ShrinkableMap) Del(key interface{})

func (*ShrinkableMap) Get

func (m *ShrinkableMap) Get(key interface{}) (interface{}, bool)

func (*ShrinkableMap) IterateCallback

func (m *ShrinkableMap) IterateCallback(iterCBF IterCBFunc)

func (*ShrinkableMap) Set

func (m *ShrinkableMap) Set(key, value interface{})

func (*ShrinkableMap) Size

func (m *ShrinkableMap) Size() int

Jump to

Keyboard shortcuts

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