common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2018 License: LGPL-3.0 Imports: 18 Imported by: 78

Documentation

Index

Constants

View Source
const (
	// SlotLength interval of generate block
	SlotLength = 3
	// SecondsInHour ...
	SecondsInHour = 3600
	// SecondsInDay ...
	SecondsInDay = 24 * 3600
)
View Source
const (
	// HashLength ...
	HashLength = 32
	// AddressLength ...
	AddressLength = 20
	// VoteInterval the interval between the votes
	VoteInterval = 200
)
View Source
const UINT160SIZE int = 20

UINT160SIZE ...

Variables

View Source
var PublicIPDetechUrls = []string{
	"http://ipecho.net/plain",
	"http://myexternalip.com/raw",
}

PublicIPDetechUrls test public ip

Functions

func Base58Decode

func Base58Decode(s string) []byte

Base58Decode ...

func Base58Encode

func Base58Encode(raw []byte) string

Base58Encode ...

func BytesToInt

func BytesToInt(b []byte) int

BytesToInt ...

func BytesToInt64

func BytesToInt64(b []byte) int64

BytesToInt64 ...

func BytesToUint64

func BytesToUint64(b []byte) uint64

BytesToUint64 ...

func CopyBytes

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

CopyBytes ...

func FromHex

func FromHex(s string) []byte

FromHex string to bytes

func GetPulicIP

func GetPulicIP() string

GetPulicIP get public network IP

func Hash160

func Hash160(raw []byte) []byte

Hash160 ...

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes hex string to bytes

func Int64ToBytes

func Int64ToBytes(i int64) []byte

Int64ToBytes ...

func IntToBytes

func IntToBytes(n int) []byte

IntToBytes ...

func IntervalSecond

func IntervalSecond(t1 Timestamp, t2 Timestamp) int64

IntervalSecond ...

func IntervalSecondBySlot

func IntervalSecondBySlot(slot1 int64, slot2 int64) int64

IntervalSecondBySlot the interval between the slots

func IsPublicIP

func IsPublicIP(IP net.IP) bool

IsPublicIP check public network IP

func Parity

func Parity(bit []byte) []byte

Parity ...

func ParseHex

func ParseHex(s string) []byte

ParseHex ...

func RandHash

func RandHash(n int) []byte

RandHash ...

func ReadFile

func ReadFile(src string) ([]byte, error)

ReadFile read the file

func Sha256

func Sha256(raw []byte) []byte

Sha256 ...

func Sha3

func Sha3(raw []byte) []byte

Sha3 ...

func ToHex

func ToHex(data []byte) string

ToHex ...

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

Uint64ToBytes ...

Types

type ACCConfig

type ACCConfig struct {
	ID        string
	SecKey    string
	Algorithm string
}

ACCConfig account of the system

type App

type App []Service

App is a list of Service.

func (*App) Start

func (a *App) Start() error

Start starts all the service. It breaks and returns an error if any error occurs.

func (*App) Stop

func (a *App) Stop()

Stop stops all the service.

type BlockIDType

type BlockIDType Uint160

BlockIDType ...

type Config

type Config struct {
	ACC     *ACCConfig
	Genesis *GenesisConfig
	VM      *VMConfig
	DB      *DBConfig
	P2P     *P2PConfig
	RPC     *RPCConfig
	Log     *LogConfig
	Metrics *MetricsConfig
	Debug   *DebugConfig
}

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 GenesisConfig

type GenesisConfig struct {
	CreateGenesis    bool
	GenesisHash      string
	WitnessInfo      []string
	VoteContractPath string
	AdminID          string
}

GenesisConfig config of the genesis block

type Hash

type Hash [HashLength]byte

Hash is hash of data

func BytesToHash

func BytesToHash(b []byte) Hash

BytesToHash ...

func HexToHash

func HexToHash(s string) Hash

HexToHash ...

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes return hash

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

SetBytes ...

type LogConfig

type LogConfig struct {
	FileLog    *FileLogConfig
	ConsoleLog *ConsoleLogConfig
	AsyncWrite 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
}

P2PConfig is the config for p2p network.

type RPCConfig

type RPCConfig struct {
	JSONPort int
	GRPCPort int
}

RPCConfig is the config for RPC Server.

type Serializable

type Serializable interface {
	Encode() []byte
	Decode([]byte) error
	Hash() []byte
}

Serializable data serializable

type Service

type Service interface {
	Start() error
	Stop()
}

Service defines APIs of resident goroutines.

type StorageSize

type StorageSize float64

StorageSize ...

type Timestamp

type Timestamp struct {
	Slot int64
}

Timestamp the interval between the blocks

func GetCurrentTimestamp

func GetCurrentTimestamp() Timestamp

GetCurrentTimestamp return value of current timestamp

func GetTimestamp

func GetTimestamp(timeSec int64) Timestamp

GetTimestamp return value of timestamp

func (*Timestamp) Add

func (t *Timestamp) Add(intervalSlot int64)

Add add one slot

func (*Timestamp) AddDay

func (t *Timestamp) AddDay(intervalDay int64)

AddDay add one day

func (*Timestamp) AddHour

func (t *Timestamp) AddHour(intervalHour int64)

AddHour add one hour

func (*Timestamp) AddSecond

func (t *Timestamp) AddSecond(interval int64)

AddSecond add one second

func (*Timestamp) After

func (t *Timestamp) After(t2 Timestamp) bool

After ...

func (*Timestamp) ToUnixSec

func (t *Timestamp) ToUnixSec() int64

ToUnixSec slot to second

type Uint160

type Uint160 [UINT160SIZE]uint8

Uint160 ...

type VMConfig

type VMConfig struct {
	JsPath   string
	LogLevel string
}

VMConfig config of the v8vm

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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