Documentation ¶
Index ¶
- Constants
- func BlockOnTheChain(chain uint64, key []byte) bool
- func CheckTransList(chain uint64, factory func(uint64) Hash) (err error)
- func CheckTransaction(chain uint64, tKey []byte) (err error)
- func CreateAppFromSourceCode(fileName string, flag byte) ([]byte, uint64)
- func CreateBiosTrans(chain uint64)
- func DecodeOpsDataOfTrans(ops uint8, data []byte) map[string]interface{}
- func DeleteBlock(chain uint64, key []byte) error
- func DeleteBlockReliability(chain uint64, key []byte)
- func DeleteTransaction(chain uint64, key []byte) error
- func Exit()
- func GetBlockInterval(chain uint64) uint64
- func GetBlockSizeLimit(chain uint64) uint64
- func GetBlockTime(chain uint64) uint64
- func GetLastBlockIndex(chain uint64) uint64
- func GetTheBlockKey(chain, index uint64) []byte
- func GetUserCoin(chain uint64, addr []byte) uint64
- func Init()
- func IsExistBlock(chain uint64, key []byte) bool
- func IsExistTransaction(chain uint64, key []byte) bool
- func IsMiner(chain, index uint64, user []byte) bool
- func ProcessBlockOfChain(chain uint64, key []byte) (err error)
- func ReadBlockData(chain uint64, key []byte) []byte
- func ReadTransactionData(chain uint64, key []byte) []byte
- func SaveBlockReliability(chain uint64, key []byte, rb TReliability)
- func WriteBlock(chain uint64, data []byte) error
- func WriteTransaction(chain uint64, data []byte) error
- type Address
- type AdminInfo
- type AppInfo
- type BaseInfo
- type Block
- type BlockInfo
- type BroadcastInfo
- type DB
- type DependItem
- type Hash
- type Log
- type Miner
- type RegMiner
- type StBlock
- type StTrans
- func (t *StTrans) CreateMove(dstChain, value uint64)
- func (t *StTrans) CreateNewApp(code []byte, lineNum uint64)
- func (t *StTrans) CreateNewChain(chain, value uint64)
- func (t *StTrans) CreateRegisterMiner(chain, index, cost uint64)
- func (t *StTrans) CreateRunApp(app Hash, cost uint64, data []byte)
- func (t *StTrans) CreateTransfer(payee Address, value uint64)
- func (t *StTrans) CreateUpdateAppLife(app Hash, life uint64)
- func (t *StTrans) GetSignData() []byte
- func (t *StTrans) Output() []byte
- func (t *StTrans) SetSign(in []byte) error
- type TReliability
- type TransInfo
- type TransProc
- type Transaction
- type TransactionHead
- type UpdateInfo
Constants ¶
const ( TimeMillisecond = 1 TimeSecond = 1000 * TimeMillisecond TimeMinute = 60 * TimeSecond TimeHour = 60 * TimeMinute TimeDay = 24 * TimeHour TimeYear = 31558150 * TimeSecond TimeMonth = TimeYear / 12 )
time
const ( // HashLen the byte length of Hash HashLen = 32 // AddressLen the byte length of Address AddressLen = 24 )
const ( StatBaseInfo = uint8(iota) StatTransKey StatGuerdon StatBlockSizeLimit StatAvgBlockSize StatHashPower StatBlockInterval StatSyncInfo StatFirstBlockKey StatChangingConfig StatBroadcast StatHateRatio StatParentKey StatSyncTime )
Key of the running state
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 )
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 )
const ( SyncOpsMoveCoin = iota SyncOpsNewChain SyncOpsMiner SyncOpsBroadcast SyncOpsBroadcastAck SyncOpsHateRatio )
ops of sync
const (
// BaseRelia base reliability
BaseRelia = 1000
)
const (
// MinerNum number of miner pre block
MinerNum = 11
)
Variables ¶
This section is empty.
Functions ¶
func BlockOnTheChain ¶ added in v0.3.2
BlockOnTheChain return true if the block is on the chain
func CheckTransList ¶ added in v0.3.2
CheckTransList check trans list for mine
func CheckTransaction ¶
CheckTransaction check trans for mine
func CreateAppFromSourceCode ¶
CreateAppFromSourceCode create app
func DecodeOpsDataOfTrans ¶
DecodeOpsDataOfTrans decode ops data
func DeleteBlockReliability ¶
DeleteBlockReliability delete reliability of block
func DeleteTransaction ¶ added in v0.3.5
DeleteTransaction delete Transaction
func GetBlockInterval ¶
GetBlockInterval get the interval time of between blocks
func GetBlockSizeLimit ¶
GetBlockSizeLimit get the limit size of block
func GetLastBlockIndex ¶
GetLastBlockIndex get the index of last block
func GetTheBlockKey ¶
GetTheBlockKey get block key,if index==0,return last key
func GetUserCoin ¶
GetUserCoin get user coin number
func IsExistBlock ¶
IsExistBlock Determine whether block exists
func IsExistTransaction ¶
IsExistTransaction Determine whether transaction exists
func ProcessBlockOfChain ¶ added in v0.3.2
ProcessBlockOfChain process block
func ReadBlockData ¶
ReadBlockData read block data
func ReadTransactionData ¶
ReadTransactionData read transaction data
func SaveBlockReliability ¶
func SaveBlockReliability(chain uint64, key []byte, rb TReliability)
SaveBlockReliability save block reliability
func WriteBlock ¶
WriteBlock write block data to database
func WriteTransaction ¶
WriteTransaction write transaction data to database
Types ¶
type AppInfo ¶
type AppInfo struct { Account Address `json:"account,omitempty"` LineSum uint64 `json:"line_sum,omitempty"` Life uint64 `json:"life,omitempty"` Flag uint8 `json:"flag"` }
AppInfo App info in database
func GetAppInfoOfChain ¶
GetAppInfoOfChain 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 Block ¶
type Block struct { //signLen uint8 //sign []byte Time uint64 Previous Hash Parent Hash LeftChild Hash RightChild Hash TransListHash Hash Producer Address Chain uint64 Index uint64 Nonce uint64 Size uint32 }
Block Block structure, full block data need +(Sign []byte) + (TransList []Hash)
type BlockInfo ¶
type BlockInfo struct { Parent Hash LeftChild Hash RightChild Hash Index uint64 ParentID uint64 LeftChildID uint64 RightChildID uint64 Time uint64 Producer Address }
BlockInfo the block info in database
type BroadcastInfo ¶
BroadcastInfo broadcase info
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB Type definition of a database.
type DependItem ¶
DependItem App's dependency information
type Hash ¶
Hash The KEY of the block of transaction
func GetParentBlockOfChain ¶
GetParentBlockOfChain get parent block of chain
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.
type StBlock ¶
type StBlock struct { Block Key Hash TransList []Hash HashpowerLimit uint64 // contains filtered or unexported fields }
StBlock StBlock
func DecodeBlock ¶
DecodeBlock decode data and check sign, check hash
func NewBlock ¶
NewBlock new block
- NewBlock
- SetTransList
- update StBlock.Size,PreCheckSum,HashPower,Parent...
- GetSignData
- SetSign
- Output
func (*StBlock) GetReliability ¶
func (b *StBlock) GetReliability() TReliability
GetReliability get block reliability
func (*StBlock) SetTransList ¶
SetTransList SetTransList
type StTrans ¶
type StTrans struct { TransactionHead Sign []byte Data []byte Key []byte }
StTrans 交易的结构体
func NewTransaction ¶
NewTransaction create a new transaction struct
- NewTransaction
- Create*:CreateTransfer,CreateMove...
- update energy,time...
- GetSignData
- SetSign
- Output
func (*StTrans) CreateMove ¶
CreateMove 转出货币到其他相邻链
func (*StTrans) CreateNewApp ¶
CreateNewApp new app
func (*StTrans) CreateNewChain ¶
CreateNewChain 创建新链
func (*StTrans) CreateRegisterMiner ¶
CreateRegisterMiner RegisterMiner
func (*StTrans) CreateRunApp ¶
CreateRunApp run app
func (*StTrans) CreateTransfer ¶
CreateTransfer 创建转账交易
func (*StTrans) CreateUpdateAppLife ¶
CreateUpdateAppLife update app life
type TReliability ¶
type TReliability struct { Key Hash `json:"key,omitempty"` Previous Hash `json:"previous,omitempty"` Parent Hash `json:"parent,omitempty"` LeftChild Hash `json:"left_child,omitempty"` RightChild Hash `json:"right_child,omitempty"` Producer Address `json:"producer,omitempty"` Time uint64 `json:"time,omitempty"` Index uint64 `json:"index,omitempty"` HashPower uint64 `json:"hash_power,omitempty"` Miner bool `json:"miner,omitempty"` Ready bool `json:"ready,omitempty"` }
TReliability Reliability of block
func ReadBlockReliability ¶
func ReadBlockReliability(chain uint64, key []byte) (cl TReliability)
ReadBlockReliability get Reliability of block from db
func (TReliability) Cmp ¶
func (r TReliability) Cmp(y TReliability) int
Cmp compares x and y and returns:
+1 if x > y -1 if x < y 0 if x = y
func (*TReliability) Recalculation ¶
func (r *TReliability) Recalculation(chain uint64)
Recalculation recalculation
type TransInfo ¶
TransInfo the transaction info
func GetTransInfo ¶
GetTransInfo get info of transaction
type TransProc ¶ added in v0.4.1
type TransProc struct {
// contains filtered or unexported fields
}
TransProc transaction processer for miner
func NewTransProc ¶ added in v0.4.1
NewTransProc new process for miner
type Transaction ¶
type Transaction struct { TransactionHead // contains filtered or unexported fields }
Transaction the transaction data
type TransactionHead ¶
type TransactionHead struct { //signLen uint8 //sing []byte Time uint64 User Address Chain uint64 Energy uint64 Cost uint64 Ops uint8 }
TransactionHead transaction = sign + head + data
type UpdateInfo ¶
UpdateInfo Information of update app life