common

package
v3.0.0-rc2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: LGPL-3.0 Imports: 14 Imported by: 76

Documentation

Index

Constants

View Source
const (
	VoteInterval = 1200
	SlotLength   = 3
)

consts

Variables

View Source
var (
	MaxBlockGasLimit = int64(800000000)
	MaxTxTimeLimit   = 200 * time.Millisecond
)

Constant of limit

Functions

func Base58Decode

func Base58Decode(s string) []byte

Base58Decode ...

func Base58Encode

func Base58Encode(raw []byte) string

Base58Encode ...

func BytesToFloat64 added in v1.1.0

func BytesToFloat64(b []byte) float64

BytesToFloat64 converts byte slice to float64.

func BytesToInt32 added in v1.1.0

func BytesToInt32(b []byte) int32

BytesToInt32 converts byte slice to int32.

func BytesToInt64

func BytesToInt64(b []byte) int64

BytesToInt64 converts byte slice to int64.

func CopyBytes

func CopyBytes(b []byte) (copiedBytes []byte)

CopyBytes ...

func Float64ToBytes added in v1.1.0

func Float64ToBytes(f float64) []byte

Float64ToBytes converts float64 to byte slice.

func FromHex

func FromHex(s string) []byte

FromHex string to bytes

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes hex string to bytes

func Int32ToBytes added in v1.1.0

func Int32ToBytes(n int32) []byte

Int32ToBytes converts int32 to byte slice.

func Int64ToBytes

func Int64ToBytes(n int64) []byte

Int64ToBytes converts int64 to byte slice.

func LoadYamlAsViper added in v1.1.0

func LoadYamlAsViper(configfile string) *viper.Viper

LoadYamlAsViper load yaml file as viper object

func Parity

func Parity(bit []byte) []byte

Parity ...

func ParseHex

func ParseHex(s string) []byte

ParseHex ...

func Sha3

func Sha3(raw []byte) []byte

Sha3 ...

func StringSliceEqual

func StringSliceEqual(a, b []string) bool

StringSliceEqual is compare two strings

func ToHex

func ToHex(data []byte) string

ToHex ...

func UnifyDecimal added in v1.1.0

func UnifyDecimal(a *Fixed, b *Fixed) (*Fixed, *Fixed, error)

UnifyDecimal make two fix point number have same decimal.

Types

type ACCConfig

type ACCConfig struct {
	ID        string
	SecKey    string
	Algorithm string
}

ACCConfig account of the system

type Config

type Config struct {
	ACC      *ACCConfig
	Genesis  string
	VM       *VMConfig
	DB       *DBConfig
	Snapshot *SnapshotConfig
	P2P      *P2PConfig
	RPC      *RPCConfig
	Log      *LogConfig
	Metrics  *MetricsConfig
	Debug    *DebugConfig
	Version  *VersionConfig
}

Config provide all configuration for the application

func NewConfig

func NewConfig(configfile string) *Config

NewConfig returns a new instance of Config

func (*Config) YamlString

func (c *Config) YamlString() string

YamlString config to string

type ConsoleLogConfig

type ConsoleLogConfig struct {
	Level  string
	Enable bool
}

ConsoleLogConfig is the config for consolewriter of ilog.

type DBConfig

type DBConfig struct {
	LdbPath string
}

DBConfig config of the database

type DebugConfig

type DebugConfig struct {
	ListenAddr string
}

DebugConfig is the config of debug.

type FileLogConfig

type FileLogConfig struct {
	Path   string
	Level  string
	Enable bool
}

FileLogConfig is the config for filewriter of ilog.

type Fixed added in v1.1.0

type Fixed struct {
	Value   int64
	Decimal int
	Err     error
}

Fixed implements fixed point number for user of token balance

func NewFixed added in v1.1.0

func NewFixed(amount string, decimal int) (*Fixed, error)

NewFixed generate Fixed from string and decimal, will truncate if decimal is smaller. Decimal < 0 means auto detecting decimal

func UnmarshalFixed added in v1.1.0

func UnmarshalFixed(s string) (*Fixed, error)

UnmarshalFixed unmarshal from string

func (*Fixed) Add added in v1.1.0

func (f *Fixed) Add(other *Fixed) *Fixed

Add ...

func (*Fixed) BiggerThan added in v1.1.0

func (f *Fixed) BiggerThan(other *Fixed) bool

BiggerThan ...

func (*Fixed) ChangeDecimal added in v1.1.0

func (f *Fixed) ChangeDecimal(targetDecimal int) *Fixed

ChangeDecimal change decimal to give decimal, without changing its real value

func (*Fixed) Div added in v1.1.0

func (f *Fixed) Div(i int64) *Fixed

Div divide by a scalar

func (*Fixed) Equals added in v1.1.0

func (f *Fixed) Equals(other *Fixed) bool

Equals check equal

func (*Fixed) IsNegative added in v1.1.0

func (f *Fixed) IsNegative() bool

IsNegative ...

func (*Fixed) IsPositive added in v1.1.0

func (f *Fixed) IsPositive() bool

IsPositive ...

func (*Fixed) IsZero added in v1.1.0

func (f *Fixed) IsZero() bool

IsZero checks whether the value is zero

func (*Fixed) LessThan added in v1.1.0

func (f *Fixed) LessThan(other *Fixed) bool

LessThan ...

func (*Fixed) Marshal added in v1.1.0

func (f *Fixed) Marshal() string

Marshal ...

func (*Fixed) Multiply added in v1.1.0

func (f *Fixed) Multiply(other *Fixed) *Fixed

Multiply ...

func (*Fixed) Neg added in v1.1.0

func (f *Fixed) Neg() *Fixed

Neg get negative number

func (*Fixed) Sub added in v1.1.0

func (f *Fixed) Sub(other *Fixed) *Fixed

Sub ...

func (*Fixed) Times added in v1.1.0

func (f *Fixed) Times(i int64) *Fixed

Times multiply a int scalar

func (*Fixed) TimesF added in v1.1.0

func (f *Fixed) TimesF(v float64) *Fixed

TimesF multiply a float scalar

func (*Fixed) ToFloat added in v1.1.0

func (f *Fixed) ToFloat() float64

ToFloat ...

func (*Fixed) ToString added in v1.1.0

func (f *Fixed) ToString() string

ToString generate string of Fixed without post zero

func (*Fixed) ToStringWithDecimal added in v1.1.0

func (f *Fixed) ToStringWithDecimal() string

ToStringWithDecimal convert to string with tailing 0s

type GenesisConfig

type GenesisConfig struct {
	CreateGenesis    bool
	InitialTimestamp string
	TokenInfo        *TokenInfo
	WitnessInfo      []*Witness
	ContractPath     string
	AdminInfo        *Witness
	FoundationInfo   *Witness
}

GenesisConfig config of the genesis bloc

type LogConfig

type LogConfig struct {
	FileLog           *FileLogConfig
	ConsoleLog        *ConsoleLogConfig
	AsyncWrite        bool
	EnableContractLog bool
}

LogConfig is the config of ilog.

type MetricsConfig

type MetricsConfig struct {
	PushAddr string
	Username string
	Password string
	Enable   bool
	ID       string
}

MetricsConfig is the config of metrics.

type P2PConfig

type P2PConfig struct {
	ListenAddr   string
	SeedNodes    []string
	ChainID      uint32
	Version      uint16
	DataPath     string
	InboundConn  int
	OutboundConn int
	BlackPID     []string
	BlackIP      []string
	AdminPort    string
}

P2PConfig is the config for p2p network.

type RPCConfig

type RPCConfig struct {
	Enable       bool
	GatewayAddr  string
	GRPCAddr     string
	AllowOrigins []string
	TryTx        bool
	ExecTx       bool
}

RPCConfig is the config for RPC Server.

type SimpleDecoder

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

SimpleDecoder is a simple decoder used to convert bytes to other types. Not used now!!!

func NewSimpleDecoder

func NewSimpleDecoder(input []byte) *SimpleDecoder

NewSimpleDecoder returns a new SimpleDecoder instance.

func (*SimpleDecoder) ParseByte

func (sd *SimpleDecoder) ParseByte() (byte, error)

ParseByte parse input, return first byte

func (*SimpleDecoder) ParseBytes

func (sd *SimpleDecoder) ParseBytes() ([]byte, error)

ParseBytes parse input, return first byte array

func (*SimpleDecoder) ParseInt32

func (sd *SimpleDecoder) ParseInt32() (int32, error)

ParseInt32 parse input, return first int32

type SimpleEncoder

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

SimpleEncoder is a simple encoder used to convert struct to bytes.

func NewSimpleEncoder

func NewSimpleEncoder() *SimpleEncoder

NewSimpleEncoder returns a new SimpleEncoder instance.

func (*SimpleEncoder) Bytes

func (se *SimpleEncoder) Bytes() []byte

Bytes returns the result bytes of buffer.

func (*SimpleEncoder) Reset

func (se *SimpleEncoder) Reset()

Reset resets the buffer.

func (*SimpleEncoder) WriteByte

func (se *SimpleEncoder) WriteByte(b byte)

WriteByte writes a byte to buffer.

func (*SimpleEncoder) WriteBytes

func (se *SimpleEncoder) WriteBytes(bs []byte)

WriteBytes writes a byte slice to buffer.

func (*SimpleEncoder) WriteBytesSlice

func (se *SimpleEncoder) WriteBytesSlice(p [][]byte)

WriteBytesSlice writes a bytes slice to buffer.

func (*SimpleEncoder) WriteFloat64

func (se *SimpleEncoder) WriteFloat64(f float64)

WriteFloat64 writes a float64 to buffer.

func (*SimpleEncoder) WriteInt32

func (se *SimpleEncoder) WriteInt32(i int32)

WriteInt32 writes a int32 to buffer.

func (*SimpleEncoder) WriteInt64

func (se *SimpleEncoder) WriteInt64(i int64)

WriteInt64 writes a int64 to buffer.

func (*SimpleEncoder) WriteMapStringToI64

func (se *SimpleEncoder) WriteMapStringToI64(m map[string]int64)

WriteMapStringToI64 writes a map[string]int64 to buffer.

func (*SimpleEncoder) WriteString

func (se *SimpleEncoder) WriteString(s string)

WriteString writes a string to buffer.

func (*SimpleEncoder) WriteStringSlice

func (se *SimpleEncoder) WriteStringSlice(p []string)

WriteStringSlice writes a string slice to buffer.

type SnapshotConfig

type SnapshotConfig struct {
	Enable   bool
	FilePath string
}

SnapshotConfig is the config of snapshot

type TokenInfo added in v1.1.0

type TokenInfo struct {
	FoundationAccount string
	IOSTTotalSupply   int64
	IOSTDecimal       int64
}

TokenInfo config of the genesis block

type VMConfig

type VMConfig struct {
	JsPath   string
	LogLevel string
}

VMConfig config of the v8vm

type VersionConfig added in v1.1.0

type VersionConfig struct {
	NetName         string
	ProtocolVersion string
}

VersionConfig contrains netname(mainnet / testnet etc) and protocol info

type Witness added in v1.1.0

type Witness struct {
	ID             string
	Owner          string
	Active         string
	SignatureBlock string
	Balance        int64
}

Witness config of the genesis block

Jump to

Keyboard shortcuts

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