Documentation
¶
Index ¶
- Constants
- Variables
- func Bytes2Hex(d []byte) string
- func CopyBytes(b []byte) (copiedBytes []byte)
- func FromHex(s string) []byte
- func Hex2Bytes(str string) []byte
- func Hex2BytesFixed(str string, flen int) []byte
- func IsValidName(s string) bool
- func ToHex(b []byte) stringdeprecated
- type Account
- type AccountAuthor
- type AccountAuthorAction
- type ActionResult
- type ActionType
- type Address
- func (a Address) Big() *big.Int
- func (a Address) Bytes() []byte
- func (a Address) Compare(x Address) int
- func (a Address) Format(s fmt.State, c rune)
- func (a Address) Hash() Hash
- func (a Address) Hex() string
- func (a Address) MarshalText() ([]byte, error)
- func (a *Address) SetBytes(b []byte)
- func (a Address) String() string
- func (a *Address) UnmarshalJSON(input []byte) error
- func (a *Address) UnmarshalText(input []byte) error
- type AssetBalance
- type AssetFee
- type AssetObject
- type Author
- type AuthorAction
- type AuthorActionType
- type AuthorJSON
- type AuthorType
- type BlockAndResult
- type Bloom
- type ChainConfig
- type ChargeConfig
- type CreateAccountAction
- type DetailTx
- type DposConfig
- type DposIrreversible
- type DposKickedCandidate
- type DposRegisterCandidate
- type DposUpdateCandidate
- type DposUpdateCandidatePubKey
- type DposVoteCandidate
- type ForkID
- type FrokedConfig
- type GasDistribution
- type Genesis
- type GenesisAccount
- type GenesisAsset
- type GenesisCandidate
- type Hash
- func (h Hash) Big() *big.Int
- func (h Hash) Bytes() []byte
- func (h Hash) Format(s fmt.State, c rune)
- func (h Hash) Hex() string
- func (h Hash) MarshalText() ([]byte, error)
- func (h *Hash) SetBytes(b []byte)
- func (h Hash) String() string
- func (h Hash) TerminalString() string
- func (h *Hash) UnmarshalJSON(input []byte) error
- func (h *Hash) UnmarshalText(input []byte) error
- type IncAssetObject
- type InternalAction
- type InternalLog
- type IssueAssetObject
- type Name
- type NameConfig
- type ObjectFee
- type ObjectFeeResult
- type Owner
- type PubKey
- func (p PubKey) Big() *big.Int
- func (p PubKey) Bytes() []byte
- func (p PubKey) Compare(x PubKey) int
- func (p PubKey) Hex() string
- func (p PubKey) MarshalText() ([]byte, error)
- func (p *PubKey) SetBytes(key []byte)
- func (p PubKey) String() string
- func (p *PubKey) UnmarshalJSON(input []byte) error
- func (p *PubKey) UnmarshalText(input []byte) error
- type RPCAction
- type RPCTransaction
- type Receipt
- type RpcBlock
- type StorageAuthor
- type UpdateAccountAction
- type UpdateAssetContractObject
- type UpdateAssetObject
- type UpdateAssetOwnerObject
- type WithdrawAsset
- type WithdrawInfo
Constants ¶
const ( // ReceiptStatusFailed is the status code of a action if execution failed. ReceiptStatusFailed = 0 // ReceiptStatusSuccessful is the status code of a action if execution succeeded. ReceiptStatusSuccessful = 1 )
const AddressLength = 20
const BloomByteLength = 256
const HashLength = 32
const PubKeyLength = 65
Variables ¶
var ( Big1 = big.NewInt(1) Big2 = big.NewInt(2) Big3 = big.NewInt(3) Big0 = big.NewInt(0) Big32 = big.NewInt(32) Big256 = big.NewInt(256) Big257 = big.NewInt(257) Big20 = big.NewInt(20) Big80 = big.NewInt(80) Big100 = big.NewInt(100) )
var ActionTypeToString map[ActionType]string = map[ActionType]string{ CallContract: "CallContract", CreateContract: "CreateContract", CreateAccount: "CreateAccount", UpdateAccount: "UpdateAccount", IncreaseAsset: "IncreaseAsset", IssueAsset: "IssueAsset", DestroyAsset: "DestroyAsset", SetAssetOwner: "SetAssetOwner", Transfer: "Transfer", UpdateAccountAuthor: "UpdateAccountAuthor", UpdateCandidate: "UpdateCandidate", UnregCandidate: "UnregCandidate", RefundCandidate: "RefundCandidate", VoteCandidate: "VoteCandidate", WithdrawFee: "WithdrawFee", UpdateAsset: "UpdateAsset", RegCandidate: "RegCandidate", KickedCandidate: "KickedCandidate", ExitTakeOver: "ExitTakeOver", UpdateAssetContract: "UpdateAssetContract", UpdateCandidatePubKey: "UpdateCandidatePubKey", }
var ( AuthorTypeToString map[AuthorType]string = map[AuthorType]string{ AccountNameType: "account", PubKeyType: "pubKey", AddressType: "address", } )
Functions ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func Hex2BytesFixed ¶
Hex2BytesFixed returns bytes of a specified fixed length flen.
func IsValidName ¶
IsValidName verifies whether a string can represent a valid name or not.
Types ¶
type Account ¶
type Account struct {
AcctName Name `json:"accountName"`
Founder Name `json:"founder"`
AccountID uint64 `json:"accountID"`
Number uint64 `json:"number"`
Nonce uint64 `json:"nonce"`
Code hexutil.Bytes `json:"code"`
CodeHash Hash `json:"codeHash"`
CodeSize uint64 `json:"codeSize"`
Threshold uint64 `json:"threshold"`
UpdateAuthorThreshold uint64 `json:"updateAuthorThreshold"`
AuthorVersion Hash `json:"authorVersion"`
Balances []*AssetBalance `json:"balances"`
Authors []*Author `json:"authors"`
Suicide bool `json:"suicide"`
Destroy bool `json:"destroy"`
Description string `json:"description"`
}
type AccountAuthor ¶
type AccountAuthor struct {
AuthorType AuthorType
Author string
Weight uint64
}
type AccountAuthorAction ¶
type AccountAuthorAction struct {
Threshold uint64 `json:"threshold,omitempty"`
UpdateAuthorThreshold uint64 `json:"updateAuthorThreshold,omitempty"`
AuthorActions []*AuthorAction `json:"authorActions,omitempty"`
}
type ActionResult ¶
type ActionResult struct {
GasAllot []*GasDistribution `json:"GasAllot"`
Status uint64 `json:"Status"`
GasUsed uint64 `json:"GasUsed"`
Error string `json:"Error"`
}
ActionResult represents the results the transaction action.
type ActionType ¶
type ActionType uint64
ActionType type of Action.
const ( // CallContract represents the call contract action. CallContract ActionType = iota // CreateContract repesents the create contract action. CreateContract )
const ( //CreateAccount repesents the create account. CreateAccount ActionType = 0x100 + iota //UpdateAccount repesents update account. UpdateAccount // DeleteAccount repesents the delete account action. DeleteAccount //UpdateAccountAuthor represents the update account author. UpdateAccountAuthor )
const ( // IncreaseAsset Asset operation IncreaseAsset ActionType = 0x200 + iota // IssueAsset repesents Issue asset action. IssueAsset //DestroyAsset destroy asset DestroyAsset // SetAssetOwner repesents set asset new owner action. SetAssetOwner //SetAssetFounder set asset founder //SetAssetFounder UpdateAsset //Transfer repesents transfer asset action. Transfer UpdateAssetContract )
const ( // RegCandidate repesents register candidate action. RegCandidate ActionType = 0x300 + iota // UpdateCandidate repesents update candidate action. UpdateCandidate // UnregCandidate repesents unregister candidate action. UnregCandidate // RefundCandidate repesents unregister candidate action. RefundCandidate // VoteCandidate repesents voter vote candidate action. VoteCandidate // UpdateCandidatePubKey repesents update candidate action. UpdateCandidatePubKey )
const ( // KickedCandidate kicked KickedCandidate ActionType = 0x400 + iota // ExitTakeOver exit ExitTakeOver )
const ( // WithdrawFee WithdrawFee ActionType = 0x500 + iota )
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address of an account.
func BytesToAddress ¶
func (Address) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Address) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.
func (*Address) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Address) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type AssetBalance ¶
type AssetFee ¶
type AssetFee struct {
AssetID uint64 `json:"assetID”` //资产ID
TotalFee *big.Int `json:"totalFee”` //收到过的手续费数量
}
AssetFee asset fee
type AssetObject ¶
type AssetObject struct {
AssetId uint64 `json:"assetId,omitempty"`
Number uint64 `json:"number,omitempty"`
AssetName string `json:"assetName"`
Symbol string `json:"symbol"`
Amount *big.Int `json:"amount"`
Decimals uint64 `json:"decimals"`
Founder Name `json:"founder"`
Owner Name `json:"owner"`
AddIssue *big.Int `json:"addIssue"`
UpperLimit *big.Int `json:"upperLimit"`
Contract Name `json:"contract"`
Detail string `json:"detail"`
}
type AuthorAction ¶
type AuthorAction struct {
ActionType AuthorActionType
Author *Author
}
type AuthorActionType ¶
type AuthorActionType uint64
const ( AddAuthor AuthorActionType = iota UpdateAuthor DeleteAuthor )
type AuthorJSON ¶
type AuthorType ¶
type AuthorType uint8
const ( AccountNameType AuthorType = iota PubKeyType AddressType )
type BlockAndResult ¶
type Bloom ¶
type Bloom [BloomByteLength]byte
func (Bloom) MarshalText ¶
MarshalText encodes b as a hex string with 0x prefix.
func (*Bloom) UnmarshalText ¶
UnmarshalText b as a hex string with 0x prefix.
type ChainConfig ¶
type ChainConfig struct {
BootNodes []string `json:"bootnodes,omitempty"` // enode URLs of the P2P bootstrap nodes
ChainID *big.Int `json:"chainId,omitempty"` // chainId identifies the current chain and is used for replay protection
ChainName string `json:"chainName,omitempty"` // chain name
ChainURL string `json:"chainUrl,omitempty"` // chain url
AccountNameCfg *NameConfig `json:"accountParams,omitempty"`
AssetNameCfg *NameConfig `json:"assetParams,omitempty"`
ChargeCfg *ChargeConfig `json:"chargeParams,omitempty"`
ForkedCfg *FrokedConfig `json:"upgradeParams,omitempty"`
DposCfg *DposConfig `json:"dposParams,omitempty"`
SysName string `json:"systemName,omitempty"` // system name
AccountName string `json:"accountName,omitempty"` // account name
AssetName string `json:"assetName,omitempty"` // asset name
DposName string `json:"dposName,omitempty"` // system name
SnapshotInterval uint64 `json:"snapshotInterval,omitempty"`
FeeName string `json:"feeName,omitempty"` //fee name
SysToken string `json:"systemToken,omitempty"` // system token
SysTokenID uint64 `json:"sysTokenID,omitempty"`
SysTokenDecimals uint64 `json:"sysTokenDecimal,omitempty"`
ReferenceTime uint64 `json:"referenceTime,omitempty"`
}
ChainConfig is the core config which determines the blockchain settings.
type ChargeConfig ¶
type CreateAccountAction ¶
type DetailTx ¶
type DetailTx struct {
TxHash Hash `json:"txhash"`
InternalActions []*InternalAction `json:"actions"`
}
type DposConfig ¶
type DposConfig struct {
MaxURLLen uint64 `json:"maxURLLen,omitempty"` // url length
UnitStake *big.Int `json:"unitStake,omitempty"` // state unit
CandidateMinQuantity *big.Int `json:"candidateMinQuantity,omitempty"` // min quantity
VoterMinQuantity *big.Int `json:"voterMinQuantity,omitempty"` // min quantity
ActivatedMinQuantity *big.Int `json:"activatedMinQuantity,omitempty"` // min active quantity
BlockInterval uint64 `json:"blockInterval,omitempty"`
BlockFrequency uint64 `json:"blockFrequency,omitempty"`
CandidateScheduleSize uint64 `json:"candidateScheduleSize,omitempty"`
BackupScheduleSize uint64 `json:"backupScheduleSize,omitempty"`
EpchoInterval uint64 `json:"epchoInterval,omitempty"`
FreezeEpchoSize uint64 `json:"freezeEpchoSize,omitempty"`
ExtraBlockReward *big.Int `json:"extraBlockReward,omitempty"`
BlockReward *big.Int `json:"blockReward,omitempty"`
}
type DposIrreversible ¶
type DposKickedCandidate ¶
type DposKickedCandidate struct {
Candidates []string
}
type DposRegisterCandidate ¶
type DposRegisterCandidate struct {
URL string
}
type DposUpdateCandidate ¶
type DposUpdateCandidate struct {
URL string
}
type DposUpdateCandidatePubKey ¶
type DposUpdateCandidatePubKey struct {
PubKey PubKey
}
type DposVoteCandidate ¶
type FrokedConfig ¶
type GasDistribution ¶
type GasDistribution struct {
Account Name `json:"name"`
Gas uint64 `json:"gas"`
Reason uint64 `json:"typeId"`
}
Reason 0 asset 1 contract 2 produce
func (*GasDistribution) NewRpcAction ¶
func (g *GasDistribution) NewRpcAction() *RPCAction
type Genesis ¶
type Genesis struct {
Config *ChainConfig `json:"config"`
//Dpos *DposConfig `json:"dpos"`
Timestamp uint64 `json:"timestamp"`
//ExtraData []byte `json:"extraData"`
GasLimit uint64 `json:"gasLimit" `
Difficulty *big.Int `json:"difficulty" `
//Coinbase Name `json:"coinbase"`
//AllocAccounts []*GenesisAccount `json:"allocAccounts"`
//AllocAssets []*AssetObject `json:"allocAssets"`
AllocAccounts []*GenesisAccount `json:"allocAccounts,omitempty"`
AllocCandidates []*GenesisCandidate `json:"allocCandidates,omitempty"`
AllocAssets []*GenesisAsset `json:"allocAssets,omitempty"`
}
Genesis specifies the header fields, state of a genesis block.
func (*Genesis) UnmarshalJSON ¶
type GenesisAccount ¶
type GenesisAccount struct {
Name Name `json:"name,omitempty"`
PubKey PubKey `json:"pubKey,omitempty"`
}
GenesisAccount is an account in the state of the genesis block.
type GenesisAsset ¶
type GenesisAsset struct {
Name string `json:"name,omitempty"`
Symbol string `json:"symbol,omitempty"`
Amount *big.Int `json:"amount,omitempty"`
Decimals uint64 `json:"decimals,omitempty"`
Founder string `json:"founder,omitempty"`
Owner string `json:"owner,omitempty"`
UpperLimit *big.Int `json:"upperLimit,omitempty"`
}
GenesisAsset is an asset in the state of the genesis block.
type GenesisCandidate ¶
type GenesisCandidate struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Stake *big.Int `json:"stake,omitempty"`
}
GenesisCandidate is an cadicate in the state of the genesis block.
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
func BigToHash ¶
BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func (Hash) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Hash) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Hash) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Hash) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type IncAssetObject ¶
type InternalAction ¶
type InternalAction struct {
InternalLogs []*InternalLog `json:"internalActions"`
}
type InternalLog ¶
type IssueAssetObject ¶
type IssueAssetObject struct {
AssetName string `json:"assetName"`
Symbol string `json:"symbol"`
Amount *big.Int `json:"amount"`
Decimals uint64 `json:"decimals"`
Founder Name `json:"founder"`
Owner Name `json:"owner"`
UpperLimit *big.Int `json:"upperLimit"`
Contract Name `json:"contract"`
Description string `json:"description"`
}
type Name ¶
type Name string
Name represents the account name
func (*Name) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Name) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type NameConfig ¶
type ObjectFeeResult ¶
type Owner ¶
type Owner interface {
String() string
}
func GenerateOwner ¶
func GenerateOwner(author string, at AuthorType) Owner
type PubKey ¶
type PubKey [PubKeyLength]byte
func HexToPubKey ¶
HexToPubKey returns PubKey with byte values of s.
func (PubKey) Compare ¶
Compare returns an integer comparing two byte slices lexicographically. The result will be 0 if a==b, -1 if a < b, and +1 if a > b. A nil argument is equivalent to an empty slice.
func (PubKey) MarshalText ¶
MarshalText returns the hex representation of a.
func (*PubKey) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*PubKey) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type RPCAction ¶
type RPCAction struct {
Type ActionType `json:"type"`
Nonce uint64 `json:"nonce"`
From Name `json:"from"`
To Name `json:"to"`
AssetID uint64 `json:"assetID"`
GasLimit uint64 `json:"gas"`
Amount *big.Int `json:"value"`
Remark hexutil.Bytes `json:"remark"`
Payload hexutil.Bytes `json:"payload"`
ActionHash Hash `json:"actionHash"`
ActionIndex uint64 `json:"actionIndex"`
Payer Name `json:"payer"`
PayerGasPrice *big.Int `json:"payerGasPrice"`
ParentIndex uint64 `json:"parentIndex"`
PayerParentIndex uint64 `json:"payerParentIndex"`
}
type RPCTransaction ¶
type RPCTransaction struct {
BlockHash Hash `json:"blockHash"`
BlockNumber uint64 `json:"blockNumber"`
Hash Hash `json:"txHash"`
TransactionIndex uint64 `json:"transactionIndex"`
RPCActions []*RPCAction `json:"actions"`
GasAssetID uint64 `json:"gasAssetID"`
GasPrice *big.Int `json:"gasPrice"`
GasCost *big.Int `json:"gasCost"`
}
type Receipt ¶
type Receipt struct {
//PostState []byte `json:"PostState"`
ActionResults []*ActionResult `json:"ActionResults"`
//CumulativeGasUsed uint64 `json:"CumulativeGasUsed"`
TxHash Hash `json:"TxHash"`
TotalGasUsed uint64 `json:"TotalGasUsed"`
}
Receipt represents the results of a transaction.
type RpcBlock ¶
type RpcBlock struct {
Number *big.Int `json:"number"`
Hash Hash `json:"hash"`
//ProposedIrreversible uint64 `json:"proposedIrreversible"`
ParentHash Hash `json:"parentHash"`
//Bloom Bloom `json:"logsBloom"`
//Root Hash `json:"stateRoot"`
CoinBase Name `json:"miner"`
Difficulty *big.Int `json:"difficulty"`
Extra hexutil.Bytes `json:"extraData"`
//Size uint64 `json:"size"`
GasLimit uint64 `json:"gasLimit"`
GasUsed uint64 `json:"gasUsed"`
Time uint64 `json:"timestamp"`
//TxsRoot Hash `json:"transactionsRoot"`
//ReceiptsRoot Hash `json:"receiptsRoot"`
//ForkID ForkID `json:"forkID"`
TotalDifficulty *big.Int `json:"totalDifficulty"`
Txs []*RPCTransaction `json:"transactions"`
}
type StorageAuthor ¶
type StorageAuthor struct {
Type AuthorType
DataRaw rlp.RawValue
Weight uint64
}
type UpdateAccountAction ¶
type UpdateAccountAction struct {
Founder Name `json:"founder,omitempty"`
}
type UpdateAssetObject ¶
type UpdateAssetOwnerObject ¶
type WithdrawAsset ¶
WithdrawAsset withdraw asset info
type WithdrawInfo ¶
type WithdrawInfo struct {
ObjectName string
ObjectType uint64
Founder Name
AssetInfo []*WithdrawAsset
}
WithdrawInfo record withdraw info