zff0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeMillisecond = 1
	TimeSecond      = 1000 * TimeMillisecond
	TimeMinute      = 60 * TimeSecond
	TimeHour        = 60 * TimeMinute
	TimeDay         = 24 * TimeHour
	TimeYear        = 31558150 * TimeSecond
	TimeMonth       = TimeYear / 12
)

time

View Source
const (
	// HashLen the byte length of Hash
	HashLen = 32
	// AddressLen the byte length of Address
	AddressLen = 24
)
View Source
const (
	StatBaseInfo = uint8(iota)
	StatTransKey
	StatGuerdon
	StatBlockSizeLimit
	StatAvgBlockSize
	StatHashPower
	StatBlockInterval
	StatSyncInfo
	StatFirstBlockKey
	StatChangingConfig
	StatBroadcast
	StatHateRatio
	StatParentKey
	StatUser
)

Key of the running state

View Source
const (
	// OpsTransfer pTransfer
	OpsTransfer = uint8(iota)
	// OpsMove Move out of coin, move from this chain to adjacent chains
	OpsMove
	// OpsNewChain create new chain
	OpsNewChain
	// OpsNewApp create new app
	OpsNewApp
	// OpsRunApp run app
	OpsRunApp
	// OpsUpdateAppLife update app life
	OpsUpdateAppLife
	// OpsRegisterMiner Registered as a miner
	OpsRegisterMiner
	// OpsDisableAdmin disable admin
	OpsDisableAdmin
)
View Source
const (
	EncBinary = uint8(iota)
	EncJSON
	EncGob
)

encoding type

View Source
const (
	// AppFlagRun the app can be call
	AppFlagRun = uint8(1 << iota)
	// AppFlagImport the app code can be included
	AppFlagImport
	// AppFlagPlublc App funds address uses the plublc address, except for app, others have no right to operate the address.
	AppFlagPlublc
	// AppFlagGzipCompress gzip compress
	AppFlagGzipCompress
)
View Source
const (
	SyncOpsMoveCoin = iota
	SyncOpsNewChain
	SyncOpsMiner
	SyncOpsBroadcast
	SyncOpsBroadcastAck
	SyncOpsHateRatio
)

ops of sync

Variables

View Source
var ChainID uint64

ChainID ChainID

Functions

func Broadcast

func Broadcast(user interface{}, msg []byte)

Broadcast admin broadcast info to all chain from first chain

func Decode

func Decode(typ uint8, in []byte, out interface{}) int

Decode The data stream is filled into a variable of the specified type.

func DeleteAccount

func DeleteAccount(user interface{}, addr Address)

DeleteAccount Delete long unused accounts(more than 5 years),call by admin

func Encode

func Encode(typ uint8, in interface{}) []byte

Encode Encoding data into data streams.

func Event

func Event(user interface{}, event string, param ...[]byte)

Event send event

func GetDBData

func GetDBData(name string, key []byte) ([]byte, uint64)

GetDBData get data by name. name list:dbTransInfo,dbCoin,dbAdmin,dbStat,dbApp,dbHate,dbMining,depend,logBlockInfo,logSync

func IHateYou

func IHateYou(user interface{}, peer Address, cost uint64)

IHateYou It's just a joke.

func InitForTest

func InitForTest()

InitForTest init for test

func MoveCost

func MoveCost(user interface{}, chain, cost uint64)

MoveCost move app cost to other chain(child chain or parent chain)

func Recover

func Recover(address, sign, msg []byte) bool

Recover recover sign

func RegisterAdmin

func RegisterAdmin(app interface{}, index uint8, cost uint64)

RegisterAdmin app register as a admin

func SetAppAccountForTest

func SetAppAccountForTest(in interface{}, value uint64)

SetAppAccountForTest SetAppAccountForTest

func SetCostForTest

func SetCostForTest(account Address, value uint64)

SetCostForTest SetCostForTest

func TransferAccounts

func TransferAccounts(owner interface{}, payee Address, value uint64)

TransferAccounts pTransfer based on the app private object

func UpdateAppLife

func UpdateAppLife(AppName Hash, life uint64)

UpdateAppLife update app life

func UpdateConfig

func UpdateConfig(user interface{}, ops uint8, newSize uint32)

UpdateConfig admin change the config

Types

type Address

type Address [AddressLen]byte

Address the wallet address

func GetAppAccount

func GetAppAccount(in interface{}) Address

GetAppAccount Get the owner Address of the app

func (Address) Empty

func (a Address) Empty() bool

Empty Check where Address is empty

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

MarshalJSON marshal by base64

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) error

UnmarshalJSON UnmarshalJSON

type AdminInfo

type AdminInfo struct {
	App   Hash
	Cost  uint64
	Index uint8
}

AdminInfo register as a admin

type AppInfo

type AppInfo struct {
	Account Address
	LineSum uint64
	Life    uint64
	Flag    uint8
}

AppInfo App info in database

func GetAppInfo

func GetAppInfo(name Hash) *AppInfo

GetAppInfo get app information

type BaseInfo

type BaseInfo struct {
	Key           Hash
	Time          uint64
	Chain         uint64
	ID            uint64
	BaseOpsEnergy uint64
	Producer      Address
	ParentID      uint64
	LeftChildID   uint64
	RightChildID  uint64
}

BaseInfo stat info of last block

type BroadcastInfo

type BroadcastInfo struct {
	BlockKey Hash
	App      Hash
	LFlag    byte
	RFlag    byte
}

BroadcastInfo broadcase info

type DB

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

DB Type definition of a database.

func GetDB

func GetDB(owner interface{}) *DB

GetDB Through the private structure in app, get a DB of app, the parameter must be a structure, not a pointer. such as: owner = tAppInfo{}

func (*DB) Get

func (d *DB) Get(key []byte) ([]byte, uint64)

Get Read data from database

func (*DB) GetInt

func (d *DB) GetInt(key []byte) uint64

GetInt read uint64 data from database

func (*DB) Set

func (d *DB) Set(key, value []byte, life uint64)

Set Storage data. the record will be deleted when life=0 or value=nil

func (*DB) SetInt

func (d *DB) SetInt(key []byte, value uint64, life uint64)

SetInt Storage uint64 data

type DependItem

type DependItem struct {
	Alias   [4]byte
	AppName Hash
}

DependItem App's dependency information

type Hash

type Hash [HashLen]byte

Hash The KEY of the block of transaction

func GetAppName

func GetAppName(in interface{}) Hash

GetAppName Get the app name based on the private object

func GetHash

func GetHash(data []byte) Hash

GetHash get data hash

func (Hash) Empty

func (h Hash) Empty() bool

Empty Check whether Hash is empty

func (Hash) MarshalJSON

func (h Hash) MarshalJSON() ([]byte, error)

MarshalJSON marshal by base64

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(b []byte) error

UnmarshalJSON UnmarshalJSON

type Log

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

Log Type definition of a log. Log data can be read on other chains. Unable to overwrite the existing data.

func GetLog

func GetLog(owner interface{}) *Log

GetLog Through the private structure in app, get a Log of app, the parameter must be a structure, not a pointer.

func (*Log) Read

func (l *Log) Read(chain uint64, key []byte) []byte

Read Read log

func (*Log) Write

func (l *Log) Write(key, value []byte) bool

Write Write log,if exist the key,return false.the key and value can't be nil.

Jump to

Keyboard shortcuts

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