Documentation ¶
Index ¶
- Constants
- Variables
- func Compress(plain []byte) ([]byte, error)
- func CopyBytes(b []byte) []byte
- func Decompress(compressed []byte) ([]byte, error)
- func Fatalf(format string, args ...interface{})
- func GetBucket(timestamp uint32) uint32
- func GetChainIdByName(name string) uint32
- func GetHardFork(blockNum uint64) uint64
- func HostByteOrder() binary.ByteOrder
- func InitializeStruct(t reflect.Type, v reflect.Value)
- func Int2Bytes(n uint32) []byte
- func IsLittleEndianPlatform() bool
- func JsonNumberInt64(jn json.Number) (r int64)
- func JsonNumberUint64(jn json.Number) (r uint64)
- func PackBlockApplyHash(dataChangeHash uint32) uint64
- func TaposRefBlockNum(blockNum uint64) uint32
- func TaposRefBlockPrefix(blockId []byte) uint32
- func UnpackBlockApplyHash(hash uint64) (version, dataChangeHash uint32)
- type BlockID
- type EasyTiming
- type IBlockHeader
- type IPeer
- type ISignedBlock
- type ISignedBlockHeader
- type ISignedTransaction
- type ITransaction
- type ITransactionReceiptWithInfo
- type Marshaller
- type ShuffleFunc
- type Timing
- type Uint128
- func NewUint128() *Uint128
- func NewUint128FromBigInt(i *big.Int) (*Uint128, error)
- func NewUint128FromFixedSizeByteSlice(bytes []byte) (*Uint128, error)
- func NewUint128FromFixedSizeBytes(bytes [16]byte) *Uint128
- func NewUint128FromInt(i int64) (*Uint128, error)
- func NewUint128FromString(str string) (*Uint128, error)
- func NewUint128FromUint(i uint64) *Uint128
- func Uint128Zero() *Uint128
- func (u *Uint128) Add(x *Uint128) (*Uint128, error)
- func (u *Uint128) Bytes() []byte
- func (u *Uint128) Cmp(x *Uint128) int
- func (u *Uint128) DeepCopy() *Uint128
- func (u *Uint128) Div(x *Uint128) (*Uint128, error)
- func (u *Uint128) Exp(x *Uint128) (*Uint128, error)
- func (u *Uint128) FromFixedSizeByteSlice(bytes []byte) (*Uint128, error)
- func (u *Uint128) FromFixedSizeBytes(bytes [16]byte) *Uint128
- func (u *Uint128) Mul(x *Uint128) (*Uint128, error)
- func (u *Uint128) String() string
- func (u *Uint128) Sub(x *Uint128) (*Uint128, error)
- func (u *Uint128) ToFixedSizeByteSlice() ([]byte, error)
- func (u *Uint128) ToFixedSizeBytes() ([16]byte, error)
- func (u *Uint128) Uint64() uint64
- func (u *Uint128) Validate() error
Constants ¶
const ( ChainNameMainNet = "main" ChainNameTestNet = "test" ChainNameDevNet = "dev" )
const ( // Uint128Bytes defines the number of bytes for Uint128 type. Uint128Bytes = 16 // Uint128Bits defines the number of bits for Uint128 type. Uint128Bits = 128 )
const Is32bitPlatform = ^uint(0)>>32 == 0
const (
TaposMaxBlockCount = 0x800
)
Variables ¶
var ( ChainIdMainNet = GetChainIdByName(ChainNameMainNet) ChainIdTestNet = GetChainIdByName(ChainNameTestNet) ChainIdDevNet = GetChainIdByName(ChainNameDevNet) )
var ( // ErrUint128Overflow indicates the value is greater than uint128 maximum value 2^128. ErrUint128Overflow = errors.New("uint128: overflow") // ErrUint128Underflow indicates the value is smaller then uint128 minimum value 0. ErrUint128Underflow = errors.New("uint128: underflow") // ErrUint128InvalidBytesSize indicates the bytes size is not equal to Uint128Bytes. ErrUint128InvalidBytesSize = errors.New("uint128: invalid bytes") // ErrUint128InvalidString indicates the string is not valid when converted to uin128. ErrUint128InvalidString = errors.New("uint128: invalid string to uint128") )
var EmptyBlockID = BlockID{}
Functions ¶
func Decompress ¶ added in v1.0.2
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf formats a message to standard error and exits the program. The message is also printed to standard output if standard error is redirected to a different file.
func GetChainIdByName ¶ added in v1.0.2
func GetHardFork ¶ added in v1.0.2
func HostByteOrder ¶ added in v1.0.2
func IsLittleEndianPlatform ¶ added in v1.0.2
func IsLittleEndianPlatform() bool
func JsonNumberInt64 ¶ added in v1.0.2
func JsonNumberUint64 ¶ added in v1.0.2
func PackBlockApplyHash ¶ added in v1.0.2
func TaposRefBlockNum ¶ added in v1.0.2
func TaposRefBlockPrefix ¶ added in v1.0.2
func UnpackBlockApplyHash ¶ added in v1.0.2
Types ¶
type BlockID ¶
type BlockID struct {
Data [32]byte
}
BlockID is a sha256 byte array, the first 2 byte is replaced by the block number
type EasyTiming ¶ added in v1.0.2
func EasyTimer ¶ added in v1.0.2
func EasyTimer() EasyTiming
func (EasyTiming) Elapsed ¶ added in v1.0.2
func (t EasyTiming) Elapsed() time.Duration
func (EasyTiming) String ¶ added in v1.0.2
func (t EasyTiming) String() string
func (EasyTiming) Time ¶ added in v1.0.2
func (t EasyTiming) Time() time.Time
type IBlockHeader ¶
BlockHeader ...
type ISignedBlockHeader ¶
type ISignedBlockHeader interface { IBlockHeader Id() BlockID GetSignee() (interface{}, error) }
SignedBlockHeader ...
type ISignedTransaction ¶
type ISignedTransaction interface { ITransaction }
type ITransaction ¶
type ITransaction interface {
Validate() error
}
type ITransactionReceiptWithInfo ¶ added in v1.0.2
type ITransactionReceiptWithInfo interface { }
type Marshaller ¶
Marshaller ...
type ShuffleFunc ¶ added in v1.0.2
type ShuffleFunc func(head ISignedBlock) (bool, []string)
type Timing ¶ added in v1.0.2
type Timing struct {
// contains filtered or unexported fields
}
func (*Timing) SetPartial ¶ added in v1.0.2
type Uint128 ¶
type Uint128 struct {
// contains filtered or unexported fields
}
Uint128 defines uint128 type, based on big.Int.
For arithmetic operations, use uint128.Int.Add()/Sub()/Mul()/Div()/etc. For example, u1.Add(u1.Int, u2.Int) sets u1 to u1 + u2.
func NewUint128 ¶
func NewUint128() *Uint128
NewUint128 returns a new Uint128 struct with default value.
func NewUint128FromBigInt ¶
NewUint128FromBigInt returns a new Uint128 struct with given value and have a check.
func NewUint128FromFixedSizeByteSlice ¶
NewUint128FromFixedSizeByteSlice returns a new Uint128 struct with given fixed size byte slice.
func NewUint128FromFixedSizeBytes ¶
NewUint128FromFixedSizeBytes returns a new Uint128 struct with given fixed size byte array.
func NewUint128FromInt ¶
NewUint128FromInt returns a new Uint128 struct with given value and have a check.
func NewUint128FromString ¶
NewUint128FromString returns a new Uint128 struct with given value and have a check.
func NewUint128FromUint ¶
NewUint128FromUint returns a new Uint128 with given value
func (*Uint128) FromFixedSizeByteSlice ¶
FromFixedSizeByteSlice converts Big-Endian fixed size bytes to Uint128.
func (*Uint128) FromFixedSizeBytes ¶
FromFixedSizeBytes converts Big-Endian fixed size bytes to Uint128.
func (*Uint128) ToFixedSizeByteSlice ¶
ToFixedSizeByteSlice converts Uint128 to Big-Endian fixed size byte slice.
func (*Uint128) ToFixedSizeBytes ¶
ToFixedSizeBytes converts Uint128 to Big-Endian fixed size bytes.