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 DeleteTransaction(chain uint64, key []byte) error
- func GetBlockInterval(chain uint64) uint64
- func GetBlockSizeLimit(chain uint64) uint64
- func GetBlockTime(chain uint64) uint64
- func GetHashPowerLimit(chain uint64) uint64
- func GetLastBlockIndex(chain uint64) uint64
- func GetTheBlockKey(chain, index uint64) []byte
- func GetUserCoin(chain uint64, addr []byte) uint64
- func InitDefaultDbMgr(addrType, address string, number int)
- func IsAdmin(chain uint64, user []byte) bool
- func IsExistBlock(chain uint64, key []byte) bool
- func IsExistTransaction(chain uint64, key []byte) bool
- func IsMiner(chain uint64, user []byte) bool
- func ProcessBlockOfChain(chain uint64, key []byte) (err error)
- func ReadBlockData(chain uint64, key []byte) []byte
- func ReadTransList(chain uint64, key []byte) []byte
- func ReadTransactionData(chain uint64, key []byte) []byte
- func TransListExist(chain uint64, key []byte) bool
- func TransListToBytes(in []Hash) []byte
- func WriteBlock(chain uint64, data []byte) error
- func WriteTransList(chain uint64, transList []Hash) 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 DBNWProxyMgr
- type DependItem
- type Hash
- type Log
- type RewardInfo
- 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) 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) RegisterAdmin(cost uint64)
- func (t *StTrans) RegisterMiner(chain, cost uint64, peer []byte)
- func (t *StTrans) SetSign(in []byte) error
- func (t *StTrans) VoteAdmin(cost uint64, admin []byte)
- type StatSwitch
- type TransInfo
- type Transaction
- type TransactionHead
- type UpdateInfo
- type VoteInfo
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 // AdminNum admin number, DPOS vote AdminNum = 23 )
const ( StatBaseInfo = uint8(iota) StatTransKey StatGuerdon StatBlockSizeLimit StatAvgBlockSize StatHashPower StatBlockInterval StatSyncInfo StatFirstBlockKey StatChangingConfig StatBroadcast StatParentKey StatUser StatAdmin StatTotalVotes StatLastRewarID StatTotalCoins )
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 // OpsRegisterAdmin Registered as a admin OpsRegisterAdmin // OpsVote vote admin OpsVote // OpsUnvote unvote OpsUnvote // OpsReportError error block OpsReportError // OpsConfig config OpsConfig )
const ( EncBinary = uint8(iota) EncJSON EncGob )
encoding type
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 )
ops of sync
const MaxGuerdon = maxGuerdon
MaxGuerdon MaxGuerdon
Variables ¶
This section is empty.
Functions ¶
func BlockOnTheChain ¶
BlockOnTheChain return true if the block is on the chain
func CheckTransList ¶
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 DeleteTransaction ¶
DeleteTransaction delete Transaction
func GetBlockInterval ¶
GetBlockInterval get the interval time of between blocks
func GetBlockSizeLimit ¶
GetBlockSizeLimit get the limit size of block
func GetHashPowerLimit ¶
GetHashPowerLimit ge hash power limit
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 InitDefaultDbMgr ¶ added in v0.5.11
InitDefaultDbMgr init default db proxy, not write data to database
func IsExistBlock ¶
IsExistBlock Determine whether block exists
func IsExistTransaction ¶
IsExistTransaction Determine whether transaction exists
func ProcessBlockOfChain ¶
ProcessBlockOfChain process block
func ReadBlockData ¶
ReadBlockData read block data
func ReadTransList ¶
ReadTransList read trans list from db
func ReadTransactionData ¶
ReadTransactionData read transaction data
func TransListExist ¶
TransListExist return true when transList exist
func WriteBlock ¶
WriteBlock write block data to database
func WriteTransList ¶
WriteTransList write transList to db
func WriteTransaction ¶
WriteTransaction write transaction data to database
Types ¶
type Address ¶
type Address [AddressLen]byte
Address the wallet address
func (Address) MarshalJSON ¶
MarshalJSON marshal by base64
func (*Address) UnmarshalJSON ¶
UnmarshalJSON UnmarshalJSON
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 }
Block Block structure
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 DBNWProxyMgr ¶ added in v0.5.11
type DBNWProxyMgr struct {
// contains filtered or unexported fields
}
DBNWProxyMgr db server, proxy and cache, not write data to database
func NewDbProxyMgr ¶ added in v0.5.11
func NewDbProxyMgr(addrType, address string, number int) *DBNWProxyMgr
NewDbProxyMgr new db proxy manager
type DependItem ¶
DependItem App's dependency information
type Hash ¶
Hash The KEY of the block of transaction
func GetHashOfTransList ¶
GetHashOfTransList get hash of transaction list
func GetParentBlockOfChain ¶
GetParentBlockOfChain get parent block of chain
func (*Hash) UnmarshalJSON ¶
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.
type RewardInfo ¶
RewardInfo reward
type StBlock ¶
type StBlock struct { Block Key Hash HashpowerLimit uint64 // contains filtered or unexported fields }
StBlock StBlock
func DecodeBlock ¶
DecodeBlock decode data and check sign, check hash
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) CreateRunApp ¶
CreateRunApp run app
func (*StTrans) CreateTransfer ¶
CreateTransfer 创建转账交易
func (*StTrans) CreateUpdateAppLife ¶
CreateUpdateAppLife update app life
func (*StTrans) RegisterAdmin ¶
RegisterAdmin RegisterAdmin(candidates)
func (*StTrans) RegisterMiner ¶
RegisterMiner RegisterMiner
type StatSwitch ¶
type StatSwitch struct { SWMiningCount bool SWTransferOut bool SWTransferIn bool SWAPPRun bool SWMove bool }
StatSwitch define switch of govm status
var Switch StatSwitch = StatSwitch{ true, true, true, true, true, }
Switch switch of status
type TransInfo ¶
TransInfo the transaction info
func GetTransInfo ¶
GetTransInfo get info of transaction
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