model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxUint64

func MaxUint64(a, b uint64) uint64

func MinUint64

func MinUint64(a, b uint64) uint64

func RandBool

func RandBool() bool

func RandBytes

func RandBytes(n int) []byte

func RandFloat32

func RandFloat32() float32

func RandFloat64

func RandFloat64() float64

func RandInt

func RandInt() int

func RandInt16

func RandInt16() int16

func RandInt31

func RandInt31() int32

func RandInt31n

func RandInt31n(n int32) int32

func RandInt32

func RandInt32() int32

func RandInt63

func RandInt63() int64

func RandInt63n

func RandInt63n(n int64) int64

func RandInt64

func RandInt64() int64

func RandIntn

func RandIntn(n int) int

func RandPerm

func RandPerm(n int) []int

func RandStr

func RandStr(length int) string

func RandTime

func RandTime() time.Time

func RandUint

func RandUint() uint

func RandUint16

func RandUint16() uint16

func RandUint32

func RandUint32() uint32

func RandUint64

func RandUint64() uint64

func Seed

func Seed(seed int64)

Types

type BitArray

type BitArray struct {
	Bits  uint64   `json:"bits"`  // NOTE: persisted via reflect, must be exported
	Elems []uint64 `json:"elems"` // NOTE: persisted via reflect, must be exported
	// contains filtered or unexported fields
}

func NewBitArray

func NewBitArray(bits int) *BitArray

There is no BitArray whose Size is 0. Use nil instead.

func (*BitArray) And

func (bA *BitArray) And(o *BitArray) *BitArray

Returns a BitArray of smaller bit size.

func (*BitArray) Bytes

func (bA *BitArray) Bytes() []byte

func (*BitArray) Copy

func (bA *BitArray) Copy() *BitArray

func (*BitArray) GetIndex

func (bA *BitArray) GetIndex(i int) bool

NOTE: behavior is undefined if i >= bA.Bits

func (*BitArray) IsEmpty

func (bA *BitArray) IsEmpty() bool

func (*BitArray) IsFull

func (bA *BitArray) IsFull() bool

func (*BitArray) MarshalJSON

func (bA *BitArray) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface by marshaling bit array using a custom format: a string of '-' or 'x' where 'x' denotes the 1 bit.

func (*BitArray) Not

func (bA *BitArray) Not() *BitArray

func (*BitArray) Or

func (bA *BitArray) Or(o *BitArray) *BitArray

Returns a BitArray of larger bits size.

func (*BitArray) PickRandom

func (bA *BitArray) PickRandom() (int, bool)

func (*BitArray) SetIndex

func (bA *BitArray) SetIndex(i int, v bool) bool

NOTE: behavior is undefined if i >= bA.Bits

func (*BitArray) Size

func (bA *BitArray) Size() uint64

func (*BitArray) String

func (bA *BitArray) String() string

String returns a string representation of BitArray: BA{<bit-string>}, where <bit-string> is a sequence of 'x' (1) and '_' (0). The <bit-string> includes spaces and newlines to help people. For a simple sequence of 'x' and '_' characters with no spaces or newlines, see the MarshalJSON() method. Example: "BA{_x_}" or "nil-BitArray" for nil.

func (*BitArray) StringIndented

func (bA *BitArray) StringIndented(indent string) string

func (*BitArray) Sub

func (bA *BitArray) Sub(o *BitArray) *BitArray

func (*BitArray) UnmarshalJSON

func (bA *BitArray) UnmarshalJSON(bz []byte) error

UnmarshalJSON implements json.Unmarshaler interface by unmarshaling a custom JSON description.

func (*BitArray) Update

func (bA *BitArray) Update(o *BitArray)

NOTE: other bitarray o is not locked when reading, so if necessary, caller must copy or lock o prior to calling Update. If bA is nil, does nothing.

type CsBftMsgType

type CsBftMsgType uint64
const (
	TypeOfNewRoundMsg CsBftMsgType = 0x101
	TypeOfProposalMsg CsBftMsgType = 0x102
	TypeOfPreVoteMsg  CsBftMsgType = 0x103
	TypeOfVoteMsg     CsBftMsgType = 0x104

	TypeOfFetchBlockReqMsg  CsBftMsgType = 0x110
	TypeOfFetchBlockRespMsg CsBftMsgType = 0x111
	TypeOfSyncBlockMsg      CsBftMsgType = 0x112
	TypeOfReqNewRoundMsg    CsBftMsgType = 0x113
)

func (CsBftMsgType) String

func (i CsBftMsgType) String() string

type FetchBlockReqDecodeMsg

type FetchBlockReqDecodeMsg struct {
	MsgId     uint64
	BlockHash common.Hash
}

type FetchBlockRespDecodeMsg

type FetchBlockRespDecodeMsg struct {
	MsgId uint64
	Block *model.Block
}

type NewRoundMsg

type NewRoundMsg struct {
	Height  uint64
	Round   uint64
	Witness *model.WitMsg
}

func NewRoundMsgWithSign

func NewRoundMsgWithSign(height uint64, round uint64, signer SignHashFunc, addr common.Address) *NewRoundMsg

func (NewRoundMsg) Hash

func (r NewRoundMsg) Hash() common.Hash

func (NewRoundMsg) Valid

func (r NewRoundMsg) Valid() error

type Proposal

type Proposal struct {
	Height    uint64
	Round     uint64
	BlockID   common.Hash
	Timestamp time.Time
	Witness   *model.WitMsg
}

func NewProposalWithSign

func NewProposalWithSign(h, r uint64, blockID common.Hash, hashFunc SignHashFunc, addr common.Address) *Proposal

func (Proposal) Hash

func (p Proposal) Hash() common.Hash

func (Proposal) ValidBlock

func (p Proposal) ValidBlock(b model.AbstractBlock) error

type Rand

type Rand struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Rand is a prng, that is seeded with OS randomness. The OS randomness is obtained from crypto/rand, however none of the provided methods are suitable for cryptographic usage. They all utilize math/rand's prng internally.

All of the methods here are suitable for concurrent use. This is achieved by using a mutex lock on all of the provided methods.

func NewRand

func NewRand() *Rand

func (*Rand) Bool

func (r *Rand) Bool() bool

Bool returns a uniformly random boolean

func (*Rand) Bytes

func (r *Rand) Bytes(n int) []byte

Bytes returns n random bytes generated from the internal prng.

func (*Rand) Float32

func (r *Rand) Float32() float32

func (*Rand) Float64

func (r *Rand) Float64() float64

func (*Rand) Int

func (r *Rand) Int() int

func (*Rand) Int16

func (r *Rand) Int16() int16

func (*Rand) Int31

func (r *Rand) Int31() int32

func (*Rand) Int31n

func (r *Rand) Int31n(n int32) int32

func (*Rand) Int32

func (r *Rand) Int32() int32

func (*Rand) Int63

func (r *Rand) Int63() int64

func (*Rand) Int63n

func (r *Rand) Int63n(n int64) int64

func (*Rand) Int64

func (r *Rand) Int64() int64

func (*Rand) Intn

func (r *Rand) Intn(n int) int

Intn returns, as an int, a uniform pseudo-random number in the range [0, n). It panics if n <= 0.

func (*Rand) Perm

func (r *Rand) Perm(n int) []int

Perm returns a pseudo-random permutation of n integers in [0, n).

func (*Rand) Seed

func (r *Rand) Seed(seed int64)

func (*Rand) Str

func (r *Rand) Str(length int) string

Str constructs a random alphanumeric string of given length.

func (*Rand) Time

func (r *Rand) Time() time.Time

func (*Rand) Uint

func (r *Rand) Uint() uint

func (*Rand) Uint16

func (r *Rand) Uint16() uint16

func (*Rand) Uint32

func (r *Rand) Uint32() uint32

func (*Rand) Uint64

func (r *Rand) Uint64() uint64

type ReqRoundMsg

type ReqRoundMsg struct {
	Height uint64
	Round  uint64
}

type RoundStepType

type RoundStepType int
const (
	RoundStepNewHeight RoundStepType = iota
	RoundStepNewRound
	RoundStepPropose
	RoundStepPreVote
	RoundStepPreCommit
)

func (RoundStepType) String

func (i RoundStepType) String() string

type SignHashFunc

type SignHashFunc func(hash []byte) ([]byte, error)

type VerifyResult

type VerifyResult struct {
	Block       model.AbstractBlock
	SeenCommits []model.AbstractVerification
}

type VerifyResultRlp

type VerifyResultRlp struct {
	Block       model.Block
	SeenCommits []model.VoteMsg
}

Jump to

Keyboard shortcuts

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