Documentation ¶
Overview ¶
@author PalletOne core developers <dev@pallet.one>
@date 2018
This file is part of go-palletone. go-palletone is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. go-palletone is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with go-palletone. If not, see <http://www.gnu.org/licenses/>.
@author PalletOne core developers <dev@pallet.one> @date 2018
@author PalletOne core developer Albert·Gou <dev@pallet.one>
@date 2018
@brief 主要实现mediator调度相关的功能。implements mediator scheduling related functions.
unit package, unit structure and storage api
This file is part of go-palletone. go-palletone is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. go-palletone is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with go-palletone. If not, see <http://www.gnu.org/licenses/>. @author PalletOne core developers <dev@pallet.one> @date 2018
Unspent Transaction Output module.
Index ¶
- Constants
- Variables
- func CalcDateSize(data interface{}) common.StorageSize
- func FillBytes(data []byte, lenth uint8) []byte
- func FormatUUID(buf []byte) string
- func LoadCertBytes(original []byte) ([]byte, error)
- func MsgstoAddress(msgs []*Message) common.Address
- func ParseUUID(uuid string) ([]byte, error)
- func String2AssetId(str string) (AssetId, UniqueIdType, error)
- func ToPayloadMapValueBytes(data interface{}) []byte
- func UtxoFlags2String(flag txoFlags) string
- func VarIntSerializeSize(val uint64) int
- type AccountInfo
- type AccountStateUpdatePayload
- type AccountStateWriteSet
- type ActiveMediatorsUpdatedEvent
- type Addition
- type AddressAmount
- type AddressRewardAmount
- type AmountAsset
- type Asset
- func (asset *Asset) Bytes() []byte
- func (asset *Asset) DisplayAmount(amount uint64) decimal.Decimal
- func (asset *Asset) Equal(another *Asset) bool
- func (asset *Asset) GetDecimal() byte
- func (asset *Asset) IsEmpty() bool
- func (asset *Asset) IsSameAssetId(another *Asset) bool
- func (asset *Asset) IsSimilar(similar *Asset) bool
- func (asset *Asset) MarshalJSON() ([]byte, error)
- func (asset Asset) MarshalText() ([]byte, error)
- func (asset *Asset) SetBytes(data []byte) error
- func (asset *Asset) SetString(str string) error
- func (asset *Asset) String() string
- func (asset *Asset) Uint64Amount(amt decimal.Decimal) uint64
- func (asset *Asset) UnmarshalJSON(data []byte) error
- type AssetId
- func (it AssetId) Bytes() []byte
- func (asset AssetId) Equal(another AssetId) bool
- func (id AssetId) GetAssetType() AssetType
- func (id AssetId) GetDecimal() byte
- func (id AssetId) GetSymbol() string
- func (assetId AssetId) MarshalJSON() ([]byte, error)
- func (id AssetId) ParseAssetId() (string, AssetType, byte, []byte, UniqueIdType)
- func (it *AssetId) SetBytes(b []byte)
- func (it AssetId) String() string
- func (id AssetId) ToAsset() *Asset
- func (assetId *AssetId) UnmarshalJSON(data []byte) error
- type AssetType
- type Authentifier
- type CertBytesInfo
- type CertHolderInfo
- type CertRawInfo
- type CertState
- type ChainEvent
- type ChainHeadEvent
- type ChainIndex
- type ChainIndexTemp
- type ChainMaintenanceEvent
- type ChainSideEvent
- type Contract
- type ContractDeployPayload
- type ContractDeployPayloadV1
- type ContractDeployPayloadV2
- type ContractDeployRequestPayload
- type ContractError
- type ContractInstallRequestPayload
- type ContractInvokePayload
- type ContractInvokeRequestPayload
- type ContractInvokeResult
- type ContractReadSet
- type ContractStateValue
- type ContractStopPayload
- type ContractStopRequestPayload
- type ContractTemplate
- type ContractTplPayload
- type ContractWriteSet
- type DataPayload
- type DataVersion
- type DbRow
- type DepositBalance
- type DepositBalanceJson
- type DynamicGlobalProperty
- type ElectionInf
- type ElectionNode
- type ErrUnit
- type FileInfo
- type Forfeiture
- type FungibleToken
- type GetAddressFromScriptFunc
- type GetJurorRewardAddFunc
- type GetScriptSignersFunc
- type GlobalPropBase
- type GlobalPropBaseTemp
- type GlobalPropExtra
- type GlobalPropExtraTemp
- type GlobalProperty
- func (gp *GlobalProperty) ActiveMediatorsCount() int
- func (gp *GlobalProperty) ChainThreshold() int
- func (gp *GlobalProperty) DecodeRLP(s *rlp.Stream) error
- func (gp *GlobalProperty) EncodeRLP(w io.Writer) error
- func (gp *GlobalProperty) GetActiveMediatorAddr(index int) common.Address
- func (gp *GlobalProperty) GetActiveMediators() []common.Address
- func (gp *GlobalProperty) IsActiveMediator(add common.Address) bool
- func (gp *GlobalProperty) IsPrecedingMediator(add common.Address) bool
- func (gp *GlobalProperty) PrecedingMediatorsCount() int
- func (gp *GlobalProperty) PrecedingThreshold() int
- type GlobalPropertyTemp
- type GlobalTokenInfo
- type Header
- func (h *Header) Author() common.Address
- func (h *Header) ChainIndex() *ChainIndex
- func (cpy *Header) CopyHeader(h *Header)
- func (h *Header) Cryptolib() []byte
- func (input *Header) DecodeRLP(s *rlp.Stream) error
- func (input *Header) EncodeRLP(w io.Writer) error
- func (h *Header) Extra() []byte
- func (h *Header) GetAssetId() AssetId
- func (h *Header) GetAuthors() Authentifier
- func (h *Header) GetGroupPubKey() (kyber.Point, error)
- func (h *Header) GetGroupPubKeyByte() []byte
- func (h *Header) GetGroupPubkey() []byte
- func (h *Header) GetGroupSign() []byte
- func (h *Header) GetNumber() *ChainIndex
- func (h *Header) GetTxsIllegal() []uint16
- func (h *Header) Hash() common.Hash
- func (h *Header) HashWithOutTxRoot() common.Hash
- func (h *Header) HashWithoutAuthor() common.Hash
- func (h *Header) Index() uint64
- func (input *Header) MarshalJSON() ([]byte, error)
- func (h *Header) NumberU64() uint64
- func (h *Header) ParentHash() []common.Hash
- func (h *Header) ResetHash()
- func (h *Header) SetAuthor(author Authentifier)
- func (h *Header) SetGroupPubkey(key []byte)
- func (h *Header) SetGroupSign(sign []byte)
- func (h *Header) SetTxRoot(txroot common.Hash)
- func (h *Header) SetTxsIllegal(txsillegal []uint16)
- func (h *Header) Size() common.StorageSize
- func (h *Header) Timestamp() int64
- func (h *Header) TxRoot() common.Hash
- func (input *Header) UnmarshalJSON(b []byte) error
- type ICloneable
- type Input
- type InvokeInfo
- type InvokeTokens
- type JurorDeposit
- type JuryDepositJson
- type KeyValue
- type Log
- type LogForStorage
- type MainChain
- type MediatorCreateArgs
- type MediatorDeposit
- type MediatorDepositExtra
- type MediatorDepositJson
- type MediatorInfo
- type MediatorSchedule
- type MediatorUpdateArgs
- type Member
- type MemdagInfos
- type MemdagStatus
- type Message
- type MessageType
- type NonFungibleMetaData
- type NonFungibleToken
- type NorNodBal
- type OutPoint
- func (outpoint *OutPoint) Bytes() []byte
- func (outpoint *OutPoint) Clone() *OutPoint
- func (outpoint *OutPoint) Hash() common.Hash
- func (outpoint *OutPoint) IsEmpty() bool
- func (outpoint *OutPoint) SetString(data string) error
- func (outpoint *OutPoint) String() string
- func (outpoint *OutPoint) ToKey() []byte
- type Output
- type PartitionChain
- type PayValue
- type PaymentPayload
- type PendingLogsEvent
- type PledgeList
- type PledgeRecordJson
- type PledgeStatus
- type PledgeStatusJson
- type ProofOfExistence
- type QueryStateByVersionFunc
- type QueryUtxoFunc
- type QuitNode
- type RemovedLogsEvent
- type RemovedTransactionEvent
- type SignaturePayload
- type SignatureSet
- type SpendProof
- type StateVersion
- type Stxo
- type SysContractStateChangeEvent
- type SysSupportResult
- type SysTokenIDInfo
- type SysVoteResult
- type ToGroupSignEvent
- type TokenDefine
- type TokenPayOut
- type TokenSupply
- type Transaction
- func (tx *Transaction) AddMessage(msg *Message)
- func (tx *Transaction) Asset() *Asset
- func (tx *Transaction) CertId() []byte
- func (tx *Transaction) Clone() *Transaction
- func (tx *Transaction) CopyFrTransaction(cpy *Transaction)
- func (tx *Transaction) DataPayloadSize() int
- func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
- func (tx *Transaction) EncodeRLP(w io.Writer) error
- func (tx *Transaction) GetCoinbaseReward(versionFunc QueryStateByVersionFunc, scriptFunc GetAddressFromScriptFunc) (*AmountAsset, error)
- func (tx *Transaction) GetContractId() []byte
- func (tx *Transaction) GetContractInvokeReqMsgIdx() int
- func (tx *Transaction) GetContractTxSignatureAddress() []common.Address
- func (tx *Transaction) GetFromAddrs(queryUtxoFunc QueryUtxoFunc, getAddrFunc GetAddressFromScriptFunc) ([]common.Address, error)
- func (tx *Transaction) GetNewUtxos() map[OutPoint]*Utxo
- func (tx *Transaction) GetRequestMsgIndex() int
- func (tx *Transaction) GetRequestTx() *Transaction
- func (tx *Transaction) GetRequesterAddr(queryUtxoFunc QueryUtxoFunc, getAddrFunc GetAddressFromScriptFunc) (common.Address, error)
- func (tx *Transaction) GetResultRawTx() *Transaction
- func (tx *Transaction) GetResultTx() *Transaction
- func (tx *Transaction) GetSpendOutpoints() []*OutPoint
- func (tx *Transaction) GetTxFee(queryUtxoFunc QueryUtxoFunc) (*AmountAsset, error)
- func (tx *Transaction) GetTxFeeAllocate(queryUtxoFunc QueryUtxoFunc, getSignerFunc GetScriptSignersFunc, ...) ([]*Addition, error)
- func (tx *Transaction) GetTxFeeAllocateLegacyV1(queryUtxoFunc QueryUtxoFunc, getSignerFunc GetScriptSignersFunc, ...) ([]*Addition, error)
- func (tx *Transaction) HasContractPayoutMsg() (bool, int, *Message)
- func (tx *Transaction) Hash() common.Hash
- func (tx *Transaction) Illegal() bool
- func (tx *Transaction) IsContractTx() bool
- func (tx *Transaction) IsNewContractInvokeRequest() bool
- func (tx *Transaction) IsSystemContract() bool
- func (tx *Transaction) MarshalJSON() ([]byte, error)
- func (tx *Transaction) Messages() []*Message
- func (tx *Transaction) ModifiedMsg(index int, msg *Message)
- func (tx *Transaction) RequestHash() common.Hash
- func (msg *Transaction) SerializeSize() int
- func (tx *Transaction) SerializeSizeStripped() int
- func (tx *Transaction) SetCertId(certid []byte)
- func (tx *Transaction) SetIllegal(illegal bool)
- func (tx *Transaction) SetMessages(msgs []*Message)
- func (tx *Transaction) Size() common.StorageSize
- func (tx *Transaction) TxMessages() []*Message
- func (tx *Transaction) UnmarshalJSON(data []byte) error
- type TransactionWithUnitInfo
- type Transactions
- type TxIn
- type TxLookupEntry
- type TxOut
- type TxPreEvent
- type UniqueId
- type UniqueIdType
- type Unit
- func (unit *Unit) Author() common.Address
- func (u *Unit) ContainsParent(pHash common.Hash) bool
- func (u *Unit) CopyBody(txs Transactions) Transactions
- func (input *Unit) DecodeRLP(s *rlp.Stream) error
- func (u *Unit) DisplayId() string
- func (input *Unit) EncodeRLP(w io.Writer) error
- func (unit *Unit) GetAssetId() AssetId
- func (unit *Unit) GetGroupPubKey() (kyber.Point, error)
- func (unit *Unit) GetGroupPubKeyByte() []byte
- func (u *Unit) GetGroupPubkey() []byte
- func (u *Unit) GetGroupSign() []byte
- func (u *Unit) Hash() common.Hash
- func (u *Unit) Header() *Header
- func (unit *Unit) IsEmpty() bool
- func (u *Unit) Number() *ChainIndex
- func (u *Unit) NumberU64() uint64
- func (u *Unit) ParentHash() []common.Hash
- func (u *Unit) Size() common.StorageSize
- func (unit *Unit) String4Log() string
- func (u *Unit) Timestamp() int64
- func (u *Unit) Transaction(hash common.Hash) *Transaction
- func (u *Unit) Transactions() []*Transaction
- func (b *Unit) WithBody(transactions []*Transaction) *Unit
- type UnitNonce
- type UnitProperty
- type Units
- type UnstableRepositoryUpdatedEvent
- type Utxo
- func (u *Utxo) Bytes() []byte
- func (utxo *Utxo) Clone() *Utxo
- func (utxo *Utxo) Flag2Str() string
- func (utxo *Utxo) GetCoinDays() uint64
- func (u *Utxo) GetTimestamp() int64
- func (utxo *Utxo) IsCoinBase() bool
- func (utxo *Utxo) IsEmpty() bool
- func (utxo *Utxo) IsModified() bool
- func (utxo *Utxo) IsSpent() bool
- func (utxo *Utxo) SetCoinBase()
- func (utxo *Utxo) Spend()
- func (utxo *Utxo) StrPkScript() string
- type UtxoIndex
- type UtxoIndexValue
- type UtxoWithOutPoint
- type VoteToken
- type WriteCounter
Constants ¶
const ( UNIT_CREATION_DATE_INITIAL_UINT64 = 1536451200 UNIT_CREATION_DATE_INITIAL_FORMATE = "2018-09-09 00:00:00" )
const ( ListForApplyBecomeMediator = "ListForApplyBecomeMediator" ListForAgreeBecomeMediator = "ListForAgreeBecomeMediator" ListForQuit = "ListForQuit" ListForForfeiture = "ListForForfeiture" JuryApplyQuit = "JuryApplyQuit" DeveloperApplyQuit = "DeveloperApplyQuit" Developer = "Developer" Jury = "Jury" Mediator = "Mediator" Ok = "ok" No = "no" //获取候选列表 GetListForMediatorCandidate = "GetListForMediatorCandidate" GetListForJuryCandidate = "GetListForJuryCandidate" GetListForDeveloper = "GetListForDeveloper" //查看是否在候选列表中 IsInMediatorCandidateList = "IsInMediatorCandidateList" IsInJuryCandidateList = "IsInJuryCandidateList" IsInDeveloperList = "IsInDeveloperList" // 是否在相应列表中 IsInBecomeList = "IsInBecomeList" //IsInAgressList = "IsInAgressList" IsInQuitList = "IsInQuitList" IsInForfeitureList = "IsInForfeitureList" //获取列表 GetBecomeMediatorApplyList = "GetBecomeMediatorApplyList" GetAgreeForBecomeMediatorList = "GetAgreeForBecomeMediatorList" GetQuitApplyList = "GetQuitApplyList" GetListForForfeitureApplication = "GetListForForfeitureApplication" //申请 ApplyForForfeitureDeposit = "ApplyForForfeitureDeposit" DeveloperPayToDepositContract = "DeveloperPayToDepositContract" JuryPayToDepositContract = "JuryPayToDepositContract" //基金会处理 HandleForForfeitureApplication = "HandleForForfeitureApplication" HandleForApplyQuitMediator = "HandleForApplyQuitMediator" HandleForApplyBecomeMediator = "HandleForApplyBecomeMediator" HandleForApplyQuitJury = "HandleForApplyQuitJury" HandleForApplyQuitDev = "HandleForApplyQuitDev" HanldeNodeRemoveFromAgreeList = "HanldeNodeRemoveFromAgreeList" GetDeposit = "GetNodeBalance" GetJuryDeposit = "GetJuryDeposit" // 质押相关 PledgeDeposit = "PledgeDeposit" PledgeWithdraw = "PledgeWithdraw" QueryPledgeStatusByAddr = "QueryPledgeStatusByAddr" QueryAllPledgeHistory = "QueryAllPledgeHistory" QueryPledgeHistoryByAddr = "QueryPledgeHistoryByAddr" HandlePledgeReward = "HandlePledgeReward" AllPledgeVotes = "allPledgeVotes" QueryPledgeList = "QueryPledgeList" QueryPledgeWithdraw = "QueryPledgeWithdraw" QueryPledgeListByDate = "QueryPledgeListByDate" // mediator状态 Apply = "Applying" Agree = "Approved" Quitting = "Quitting" Quited = "Quited" // 时间格式 // Layout1 = "2006-01-02 15" // Layout2 = "2006-01-02 15:04" // Layout3 = "2006-01-02 15:04:05" // 目前使用 time.Now().UTC().Format(Layout) 返回字符串 Layout2 = "2006-01-02 15:04:05 MST" HandleMediatorInCandidateList = "HandleMediatorInCandidateList" HandleJuryInCandidateList = "HandleJuryInCandidateList" HandleDevInList = "HandleDevInList" GetAllMediator = "GetAllMediator" GetAllNode = "GetAllNode" GetAllJury = "GetAllJury" UpdateJuryInfo = "UpdateJuryInfo" )
const ( ApplyMediator = "ApplyBecomeMediator" IsApproved = "IsInAgreeList" MediatorPayDeposit = "MediatorPayToDepositContract" MediatorList = "MediatorList" GetMediatorDeposit = "GetMediatorDeposit" MediatorApplyQuit = "MediatorApplyQuit" UpdateMediatorInfo = "UpdateMediatorInfo" )
const ( APP_PAYMENT MessageType = iota APP_CONTRACT_TPL APP_CONTRACT_DEPLOY APP_CONTRACT_INVOKE APP_CONTRACT_STOP APP_SIGNATURE APP_DATA APP_ACCOUNT_UPDATE APP_UNKNOW = 99 APP_CONTRACT_TPL_REQUEST = 100 APP_CONTRACT_DEPLOY_REQUEST = 101 APP_CONTRACT_INVOKE_REQUEST = 102 APP_CONTRACT_STOP_REQUEST = 103 )
const ( FoundationAddress = "FoundationAddress" JuryList = "JuryList" DeveloperList = "DeveloperList" DepositRate = "DepositRate" )
const ( DesiredSysParamsWithoutVote = "desiredSysParamsWithoutVote" DesiredSysParamsWithVote = "desiredSysParamsWithVote" DesiredActiveMediatorCount = "ActiveMediatorCount" )
const ( FIELD_SPLIT_STR = "^*^" FIELD_GENESIS_ASSET = "GenesisAsset" )
const ( U_STATE_NO_GROUPSIGN = 0x20 U_STATE_NO_CONFIRMED = 0x21 U_STATE_CONFIRMED = 0x22 )
unit state
const GlobalPrefix = "Tokens_"
const (
ID_LENGTH = 16
)
const PTN string = "PTN"
Variables ¶
var ( TimeFormatString = "2006/01/02 15:04:05" PTNCOIN = AssetId{0x40, 0x00, 0x82, 0xBB, 0x08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00} BTCCOIN = AssetId{'b', 't', 'c', 'c', 'o', 'i', 'n'} )
var ( //TXFEE = big.NewInt(100000000) // transaction fee =1ptn TX_MAXSIZE = 256 * 1024 //256kb TX_BASESIZE = 100 * 1024 //100kb )
var DAO uint64 = 100000000
var (
EmptyRootHash = core.DeriveSha(Transactions{})
)
Functions ¶
func CalcDateSize ¶
func CalcDateSize(data interface{}) common.StorageSize
func FormatUUID ¶
func LoadCertBytes ¶
func MsgstoAddress ¶
func String2AssetId ¶
func String2AssetId(str string) (AssetId, UniqueIdType, error)
func ToPayloadMapValueBytes ¶
func ToPayloadMapValueBytes(data interface{}) []byte
func UtxoFlags2String ¶
func UtxoFlags2String(flag txoFlags) string
func VarIntSerializeSize ¶
VarIntSerializeSize returns the number of bytes it would take to serialize val as a variable length integer.
Types ¶
type AccountInfo ¶
type AccountStateUpdatePayload ¶
type AccountStateUpdatePayload struct {
WriteSet []AccountStateWriteSet `json:"write_set"`
}
一个地址对应的个人StateDB空间
type AccountStateWriteSet ¶
type ActiveMediatorsUpdatedEvent ¶
type ActiveMediatorsUpdatedEvent struct {
IsChanged bool // 标记活跃 mediators 是否有改变
}
活跃 mediators 更新事件
type Addition ¶
type AddressAmount ¶
账户质押情况
func NewAddressAmount ¶
func NewAddressAmount(addr string, amt uint64) *AddressAmount
type AddressRewardAmount ¶ added in v1.0.2
type AddressRewardAmount struct { Address string `json:"address"` Amount uint64 `json:"amount"` Reward uint64 `json:"reward"` }
账户质押情况
type AmountAsset ¶
金额和资产
func BytesToAmountAsset ¶
func BytesToAmountAsset(b []byte) *AmountAsset
func NewAmountAsset ¶
func NewAmountAsset(amount uint64, asset *Asset) *AmountAsset
func (*AmountAsset) Bytes ¶
func (aa *AmountAsset) Bytes() []byte
func (*AmountAsset) SetBytes ¶
func (aa *AmountAsset) SetBytes(data []byte) error
func (*AmountAsset) String ¶
func (aa *AmountAsset) String() string
type Asset ¶
type Asset struct { AssetId AssetId `json:"asset_id"` UniqueId UniqueId `json:"unique_id"` // every token has its unique id }
Asset to identify token By default, system asset id=0,UniqueId=0 默认的PTN资产,则AssetId=0,UniqueId=0
func NewPTNAsset ¶
func NewPTNAsset() *Asset
func StringToAsset ¶
func (*Asset) GetDecimal ¶
func (*Asset) IsSameAssetId ¶
func (*Asset) MarshalJSON ¶
func (Asset) MarshalText ¶ added in v1.0.3
func (*Asset) Uint64Amount ¶ added in v1.0.5
func (*Asset) UnmarshalJSON ¶
type AssetId ¶
AssetId 资产类别,前26bit是symbol的base36编码,27-29是Symbol编码后字节长度,30-32bit为AssetType,剩下的是Txid的前12字节
func NewAssetId ¶
func NewPTNIdType ¶
func NewPTNIdType() AssetId
func SetIdTypeByHex ¶
func ZeroIdType16 ¶
func ZeroIdType16() AssetId
func (AssetId) GetAssetType ¶
func (AssetId) GetDecimal ¶
func (AssetId) MarshalJSON ¶
func (AssetId) ParseAssetId ¶
func (*AssetId) UnmarshalJSON ¶
type Authentifier ¶
func (*Authentifier) Address ¶
func (au *Authentifier) Address() common.Address
func (*Authentifier) Empty ¶
func (au *Authentifier) Empty() bool
type CertBytesInfo ¶
type CertHolderInfo ¶
func (*CertHolderInfo) Bytes ¶
func (certHolderInfo *CertHolderInfo) Bytes() []byte
func (*CertHolderInfo) SetBytes ¶
func (certHolderInfo *CertHolderInfo) SetBytes(data []byte) error
type CertRawInfo ¶
type CertRawInfo struct { Issuer string Holder string Nonce int // 不断加1的数,可以表示当前issuer发布的第几个证书。 Cert *x509.Certificate }
type ChainEvent ¶
type ChainHeadEvent ¶
type ChainHeadEvent struct{ Unit *Unit }
type ChainIndex ¶
出于DAG和基于Token的分区共识的考虑,设计了该ChainIndex,
func NewChainIndex ¶
func NewChainIndex(assetId AssetId, idx uint64) *ChainIndex
func (*ChainIndex) DecodeRLP ¶ added in v1.0.4
func (input *ChainIndex) DecodeRLP(s *rlp.Stream) error
func (*ChainIndex) EncodeRLP ¶ added in v1.0.4
func (input *ChainIndex) EncodeRLP(w io.Writer) error
func (*ChainIndex) Equal ¶
func (height *ChainIndex) Equal(in *ChainIndex) bool
func (*ChainIndex) SetBytes ¶
func (height *ChainIndex) SetBytes(data []byte)
func (*ChainIndex) String ¶
func (height *ChainIndex) String() string
type ChainIndexTemp ¶ added in v1.0.4
type ChainMaintenanceEvent ¶
type ChainMaintenanceEvent struct { }
type ChainSideEvent ¶
type ChainSideEvent struct {
Unit *Unit
}
type Contract ¶
type Contract struct { // 根据用户创建合约实例申请的RequestId截取其后20字节生成 ContractId []byte TemplateId []byte Name string Status byte // 合约状态 Creator []byte // address 20bytes CreationTime uint64 // creation date DuringTime uint64 //合约部署持续时间,单位秒 Version string }
func NewContract ¶
type ContractDeployPayload ¶
type ContractDeployPayload struct { TemplateId []byte `json:"template_id"` // delete-- ContractId []byte `json:"contract_id"` // contract id Name string `json:"name"` // the name for contract Args [][]byte `json:"args"` // delete-- EleNode ElectionNode `json:"election_node"` // contract jurors node info ReadSet []ContractReadSet `json:"read_set"` // the set data of read, and value could be any type WriteSet []ContractWriteSet `json:"write_set"` // the set data of write, and value could be any type DuringTime uint64 `json:"during_time"` ErrMsg ContractError `json:"contract_error"` // contract error message }
func NewContractDeployPayload ¶
func NewContractDeployPayload(templateid []byte, contractid []byte, name string, args [][]byte, ele *ElectionNode, readset []ContractReadSet, writeset []ContractWriteSet, err ContractError) *ContractDeployPayload
func (*ContractDeployPayload) EncodeRLP ¶ added in v1.0.3
func (input *ContractDeployPayload) EncodeRLP(w io.Writer) error
func (*ContractDeployPayload) Equal ¶
func (a *ContractDeployPayload) Equal(b *ContractDeployPayload) bool
type ContractDeployPayloadV1 ¶ added in v1.0.3
type ContractDeployPayloadV1 struct { TemplateId []byte `json:"template_id"` // contract template id ContractId []byte `json:"contract_id"` // contract id Name string `json:"name"` // the name for contract Args [][]byte `json:"args"` // contract arguments list EleList []ElectionInf `json:"election_list"` // contract jurors list ReadSet []ContractReadSet `json:"read_set"` // the set data of read, and value could be any type WriteSet []ContractWriteSet `json:"write_set"` // the set data of write, and value could be any type ErrMsg ContractError `json:"contract_error"` // contract error message }
type ContractDeployPayloadV2 ¶ added in v1.0.3
type ContractDeployPayloadV2 struct { TemplateId []byte `json:"template_id"` // delete-- ContractId []byte `json:"contract_id"` // contract id Name string `json:"name"` // the name for contract Args [][]byte `json:"args"` // delete-- EleNode ElectionNode `json:"election_node"` // contract jurors node info ReadSet []ContractReadSet `json:"read_set"` // the set data of read, and value could be any type WriteSet []ContractWriteSet `json:"write_set"` // the set data of write, and value could be any type DuringTime uint64 `json:"during_time"` ErrMsg ContractError `json:"contract_error"` // contract error message }
type ContractDeployRequestPayload ¶
type ContractDeployRequestPayload struct { TemplateId []byte `json:"template_id"` Args [][]byte `json:"args"` ExtData []byte `json:"extend_data"` Timeout uint32 `json:"timeout"` }
App: contract_deploy
func (*ContractDeployRequestPayload) Equal ¶
func (a *ContractDeployRequestPayload) Equal(b *ContractDeployRequestPayload) bool
type ContractError ¶
type ContractInstallRequestPayload ¶
type ContractInstallRequestPayload struct { TplName string `json:"tpl_name"` TplDescription string `json:"tpl_description"` Path string `json:"install_path"` Version string `json:"tpl_version"` Abi string `json:"abi"` Language string `json:"language"` AddrHash []common.Hash `json:"addr_hash"` Creator string `json:"creator"` }
用户钱包发起的合约调用申请
func (*ContractInstallRequestPayload) Equal ¶
func (a *ContractInstallRequestPayload) Equal(b *ContractInstallRequestPayload) bool
type ContractInvokePayload ¶
type ContractInvokePayload struct { ContractId []byte `json:"contract_id"` // contract id Args [][]byte `json:"args"` // delete-- ReadSet []ContractReadSet `json:"read_set"` // the set data of read, and value could be any type WriteSet []ContractWriteSet `json:"write_set"` // the set data of write, and value could be any type Payload []byte `json:"payload"` // the contract execution result ErrMsg ContractError `json:"contract_error"` // contract error message }
如果是用户想修改自己的State信息,那么ContractId可以为空或�?0字节
func NewContractInvokePayload ¶
func NewContractInvokePayload(contractid []byte, readset []ContractReadSet, writeset []ContractWriteSet, payload []byte, err ContractError) *ContractInvokePayload
func (*ContractInvokePayload) Equal ¶
func (a *ContractInvokePayload) Equal(b *ContractInvokePayload) bool
type ContractInvokeRequestPayload ¶
type ContractInvokeRequestPayload struct { ContractId []byte `json:"contract_id"` // contract id Args [][]byte `json:"args"` // contract arguments list Timeout uint32 `json:"timeout"` }
Contract invoke message App: contract_invoke
func (*ContractInvokeRequestPayload) Equal ¶
func (a *ContractInvokeRequestPayload) Equal(b *ContractInvokeRequestPayload) bool
type ContractInvokeResult ¶
type ContractInvokeResult struct { ContractId []byte `json:"contract_id"` // contract id RequestId common.Hash `json:"request_id"` Args [][]byte `json:"args"` // contract arguments list ReadSet []ContractReadSet `json:"read_set"` // the set data of read, and value could be any type WriteSet []ContractWriteSet `json:"write_set"` // the set data of write, and value could be any type Payload []byte `json:"payload"` // the contract execution result TokenPayOut []*TokenPayOut `json:"token_payout"` //从合约地址付出Token TokenSupply []*TokenSupply `json:"token_supply"` //增发Token请求产生的结果 TokenDefine *TokenDefine `json:"token_define"` //定义新Token ErrMsg ContractError `json:"contract_error"` // contract error message }
contract invoke result
type ContractReadSet ¶
type ContractReadSet struct { Key string `json:"key"` Version *StateVersion `json:"version" rlp:"nil"` ContractId []byte `json:"contract_id"` }
func (*ContractReadSet) Equal ¶
func (a *ContractReadSet) Equal(b *ContractReadSet) bool
type ContractStateValue ¶
type ContractStateValue struct { Value []byte `json:"value"` Version *StateVersion `json:"version"` }
type ContractStopPayload ¶
type ContractStopPayload struct { ContractId []byte `json:"contract_id"` // contract id ReadSet []ContractReadSet `json:"read_set"` // the set data of read, and value could be any type WriteSet []ContractWriteSet `json:"write_set"` // the set data of write, and value could be any type ErrMsg ContractError `json:"contract_error"` // contract error message }
func NewContractStopPayload ¶
func NewContractStopPayload(contractid []byte, readset []ContractReadSet, writeset []ContractWriteSet, err ContractError) *ContractStopPayload
func (*ContractStopPayload) Equal ¶
func (a *ContractStopPayload) Equal(b *ContractStopPayload) bool
type ContractStopRequestPayload ¶
type ContractStopRequestPayload struct { ContractId []byte `json:"contract_id"` Txid string `json:"transaction_id"` DeleteImage bool `json:"delete_image"` }
App: contract_stop
func (*ContractStopRequestPayload) Equal ¶
func (a *ContractStopRequestPayload) Equal(b *ContractStopRequestPayload) bool
type ContractTemplate ¶
type ContractTemplate struct { TplId []byte `json:"tpl_id"` TplName string `json:"tpl_name"` TplDescription string `json:"tpl_description"` Path string `json:"install_path"` Version string `json:"tpl_version"` Abi string `json:"abi"` Language string `json:"language"` AddrHash []common.Hash `json:"addr_hash" rlp:"nil"` Size uint16 `json:"size"` Creator string `json:"creator"` }
func NewContractTemplate ¶
func NewContractTemplate(req *ContractInstallRequestPayload, tpl *ContractTplPayload) *ContractTemplate
type ContractTplPayload ¶
type ContractTplPayload struct { TemplateId []byte `json:"template_id"` // contract template id Size uint16 `json:"size"` // contract template bytecode size(Byte), use to compute transaction fee ByteCode []byte `json:"byte_code"` // contract bytecode ErrMsg ContractError `json:"contract_error"` // contract error message }
Contract template deploy message App: contract_template
func NewContractTplPayload ¶
func NewContractTplPayload(templateId []byte, memory uint16, bytecode []byte, err ContractError) *ContractTplPayload
func (*ContractTplPayload) Equal ¶
func (a *ContractTplPayload) Equal(b *ContractTplPayload) bool
type ContractWriteSet ¶
type ContractWriteSet struct { IsDelete bool `json:"is_delete"` Key string `json:"key"` Value []byte `json:"value"` ContractId []byte `json:"contract_id"` }
func NewWriteSet ¶
func NewWriteSet(key string, value []byte) *ContractWriteSet
func (*ContractWriteSet) Equal ¶
func (a *ContractWriteSet) Equal(b *ContractWriteSet) bool
type DataPayload ¶
type DataPayload struct { MainData []byte `json:"main_data"` ExtraData []byte `json:"extra_data"` Reference []byte `json:"reference"` }
Token exchange message and verify message App: text
type DataVersion ¶
type DepositBalance ¶ added in v1.0.3
type DepositBalance struct { Balance uint64 `json:"balance"` // 保证金余额 EnterTime string `json:"enter_time"` // 交保证金的时间 Role string `json:"role"` // 角色,包括mediator、jury和developer }
保证金信息
type DepositBalanceJson ¶ added in v1.0.3
type DynamicGlobalProperty ¶
type DynamicGlobalProperty struct { // 防止同一个mediator连续生产单元导致分叉 LastMediator common.Address `json:"lastMediator"` // 最新单元的生产 mediator IsShuffledSchedule bool `json:"isShuffledSchedule"` // 标记 mediator 的调度顺序是否刚被打乱 NextMaintenanceTime uint32 `json:"nextMaintenanceTime"` // 下一次系统维护时间 LastMaintenanceTime uint32 `json:"lastMaintenanceTime"` // 上一次系统维护时间 // 当前的绝对时间槽数量,== 从创世开始所有的时间槽数量 == UnitNum + 丢失的槽数量 CurrentAbsoluteSlot uint64 `json:"currentAbsoluteSlot"` // 记录每个生产slot的unit生产情况,用于计算mediator的参与率。 // 每一位表示一个生产slot,mediator正常生产unit则值为1,否则为0。 // 最低位表示最近一个slot, 初始值全为1。 RecentSlotsFilled uint128.Uint128 `json:"recentSlotsFilled"` // If MaintenanceFlag is true, then the head unit is a maintenance unit. // This means GetTimeSlot(1) - HeadBlockTime() will have a gap due to maintenance duration. // // This flag answers the question, "Was maintenance performed in the last call to ApplyUnit()?" MaintenanceFlag bool `json:"maintenanceFlag"` }
动态全局属性的结构体定义
func InitDynGlobalProp ¶
func InitDynGlobalProp() *DynamicGlobalProperty
func NewDynGlobalProp ¶
func NewDynGlobalProp() *DynamicGlobalProperty
type ElectionInf ¶
type ElectionInf struct { EType byte `json:"election_type"` //vrf type, if set to 1, it is the assignation node AddrHash common.Hash `json:"addr_hash"` //common.Address将地址hash后,返回给请求节点 Proof []byte `json:"proof"` //vrf proof PublicKey []byte `json:"public_key"` //alg.PublicKey, rlp not support }
node election
func (*ElectionInf) Equal ¶
func (a *ElectionInf) Equal(b *ElectionInf) bool
type ElectionNode ¶ added in v1.0.2
type ElectionNode struct { JuryCount uint64 `json:"jury_count"` // EleList []ElectionInf `json:"ele_list"` // }
type FileInfo ¶
type FileInfo struct { UnitHash common.Hash `json:"unit_hash"` UintHeight uint64 `json:"unit_index"` ParentsHash common.Hash `json:"parents_hash"` Txid common.Hash `json:"txid"` Timestamp uint64 `json:"timestamp"` MainData string `json:"main_data"` ExtraData string `json:"extra_data"` Reference string `json:"reference"` }
type Forfeiture ¶ added in v1.0.3
type Forfeiture struct { ApplyAddress string `json:"apply_address"` //谁发起的 //ForfeitureAddress string `json:"forfeiture_address"` //没收节点地址 ForfeitureRole string `json:"forfeiture_role"` //没收角色 Extra string `json:"extra"` //备注 ApplyTime string `json:"apply_time"` //请求时间 }
申请没收保证金
type FungibleToken ¶
type FungibleToken struct { Name string `json:"name"` Symbol string `json:"symbol"` Decimals byte `json:"decimals"` //总发行量 TotalSupply uint64 `json:"total_supply"` //如果允许增发,那么允许哪个地址进行增发,如果为空则不允许增发 SupplyAddress string `json:"supply_address"` }
同质化通证,比如ERC20
type GetJurorRewardAddFunc ¶ added in v1.0.4
type GetScriptSignersFunc ¶
type GetScriptSignersFunc func(tx *Transaction, msgIdx, inputIndex int) ([]common.Address, error)
type GlobalPropBase ¶
type GlobalPropBase struct { ImmutableParameters core.ImmutableChainParameters `json:"immutableParameters"` // 不可改变的区块链网络参数 ChainParameters core.ChainParameters `json:"chainParameters"` // 区块链网络参数 }
func NewGlobalPropBase ¶
func NewGlobalPropBase() GlobalPropBase
type GlobalPropBaseTemp ¶ added in v1.0.4
type GlobalPropBaseTemp struct { ImmutableParameters core.ImmutableChainParameters ChainParametersTemp core.ChainParametersTemp }
type GlobalPropExtra ¶ added in v1.0.4
type GlobalPropExtra struct { // todo albert 待重构为数组,提高效率 //ActiveJuries map[common.Address]bool `json:"activeJuries"` // 当前活跃Jury集合 ActiveMediators map[common.Address]bool `json:"activeMediators"` // 当前活跃 mediator 集合;每个维护间隔更新一次 PrecedingMediators map[common.Address]bool `json:"precedingMediators"` // 上一届 mediator }
func NewGlobalPropExtra ¶ added in v1.0.4
func NewGlobalPropExtra() GlobalPropExtra
type GlobalPropExtraTemp ¶ added in v1.0.4
type GlobalProperty ¶
type GlobalProperty struct { GlobalPropBase GlobalPropExtra }
全局属性的结构体定义
func InitGlobalProp ¶
func InitGlobalProp(genesis *core.Genesis) *GlobalProperty
func NewGlobalProp ¶
func NewGlobalProp() *GlobalProperty
func (*GlobalProperty) ActiveMediatorsCount ¶
func (gp *GlobalProperty) ActiveMediatorsCount() int
func (*GlobalProperty) ChainThreshold ¶
func (gp *GlobalProperty) ChainThreshold() int
func (*GlobalProperty) GetActiveMediatorAddr ¶
func (gp *GlobalProperty) GetActiveMediatorAddr(index int) common.Address
func (*GlobalProperty) GetActiveMediators ¶
func (gp *GlobalProperty) GetActiveMediators() []common.Address
GetActiveMediators, return the list of active mediators, and the order of the list from small to large
func (*GlobalProperty) IsActiveMediator ¶
func (gp *GlobalProperty) IsActiveMediator(add common.Address) bool
func (*GlobalProperty) IsPrecedingMediator ¶
func (gp *GlobalProperty) IsPrecedingMediator(add common.Address) bool
func (*GlobalProperty) PrecedingMediatorsCount ¶
func (gp *GlobalProperty) PrecedingMediatorsCount() int
func (*GlobalProperty) PrecedingThreshold ¶
func (gp *GlobalProperty) PrecedingThreshold() int
type GlobalPropertyTemp ¶ added in v1.0.1
type GlobalPropertyTemp struct { GlobalPropBaseTemp GlobalPropExtraTemp }
only for serialization(storage/p2p)
type GlobalTokenInfo ¶
type GlobalTokenInfo struct { Symbol string Name string TokenType uint8 //1:prc20 2:prc721 3:vote 4:SysVote Status uint8 CreateAddr string TotalSupply uint64 SupplyAddr string AssetID AssetId }
定义所有Token的基本信息
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
func CopyHeader ¶
func (*Header) ChainIndex ¶
func (h *Header) ChainIndex() *ChainIndex
func (*Header) CopyHeader ¶
func (*Header) GetAssetId ¶
func (*Header) GetAuthors ¶ added in v1.0.5
func (h *Header) GetAuthors() Authentifier
func (*Header) GetGroupPubKey ¶ added in v1.0.1
func (*Header) GetGroupPubKeyByte ¶ added in v1.0.1
func (*Header) GetGroupPubkey ¶ added in v1.0.5
func (*Header) GetGroupSign ¶ added in v1.0.2
func (*Header) GetNumber ¶ added in v1.0.2
func (h *Header) GetNumber() *ChainIndex
func (*Header) GetTxsIllegal ¶ added in v1.0.5
func (*Header) HashWithOutTxRoot ¶
HashWithOutTxRoot return header's hash without txs root.
func (*Header) HashWithoutAuthor ¶
func (*Header) MarshalJSON ¶ added in v1.0.5
func (*Header) ParentHash ¶ added in v1.0.2
func (*Header) SetAuthor ¶ added in v1.0.5
func (h *Header) SetAuthor(author Authentifier)
func (*Header) SetGroupPubkey ¶ added in v1.0.5
func (*Header) SetGroupSign ¶ added in v1.0.5
func (*Header) SetTxsIllegal ¶ added in v1.0.5
func (*Header) Size ¶
func (h *Header) Size() common.StorageSize
func (*Header) UnmarshalJSON ¶ added in v1.0.5
type ICloneable ¶
type ICloneable interface {
Clone() interface{}
}
type Input ¶
type Input struct { SignatureScript []byte `json:"signature_script"` // if user creating a new asset, this field should be it's config data. Otherwise it is null. Extra []byte `json:"extra" rlp:"nil"` PreviousOutPoint *OutPoint `json:"pre_outpoint"` }
func NewTxIn ¶
NewTxIn returns a new ptn transaction input with the provided previous outpoint point and signature script with a default sequence of MaxTxInSequenceNum.
func (*Input) SerializeSize ¶
type InvokeInfo ¶
type InvokeInfo struct { InvokeAddress common.Address `json:"invoke_address"` //请求地址 InvokeTokens []*InvokeTokens `json:"invoke_tokens"` //请求数量 InvokeFees *AmountAsset `json:"invoke_fees"` //请求交易�? }
请求合约信息
type InvokeTokens ¶
type InvokeTokens struct { Amount uint64 `json:"amount"` //数量 Asset *Asset `json:"asset"` //资产 Address string `json:"address"` //接收地址 }
请求的数量
func (*InvokeTokens) String ¶
func (i *InvokeTokens) String() string
type JurorDeposit ¶ added in v1.0.3
type JurorDeposit struct { DepositBalance core.JurorDepositExtra Address string `json:"address"` // juror地址 }
juror保证金信息
func (*JurorDeposit) GetRewardAdd ¶ added in v1.0.4
func (jd *JurorDeposit) GetRewardAdd() common.Address
type JuryDepositJson ¶ added in v1.0.3
type JuryDepositJson struct { DepositBalanceJson core.JurorDepositExtraJson Address string `json:"address"` }
juror保证金信息
type Log ¶
type Log struct { // Consensus fields: // address of the contract that generated the event Address common.Address `json:"address" gencodec:"required"` // list of topics provided by the contract. Topics []common.Hash `json:"topics" gencodec:"required"` // supplied by the contract, usually ABI-encoded Data []byte `json:"data" gencodec:"required"` // Derived fields. These fields are filled in by the node // but not secured by consensus. // block in which the transaction was included UnitNumber uint64 `json:"unitNumber"` // UnitHash of the transaction TxHash common.Hash `json:"transactionHash" gencodec:"required"` // index of the transaction in the block TxIndex uint `json:"transactionIndex" gencodec:"required"` // UnitHash of the block in which the transaction was included UnitHash common.Hash `json:"unitHash"` // index of the log in the receipt Index uint `json:"logIndex" gencodec:"required"` // The Removed field is true if this log was reverted due to a chain reorganization. // You must pay attention to this field if you receive logs through a filter query. Removed bool `json:"removed"` }
Log represents a contract log event. These events are generated by the LOG opcode and stored/indexed by the node.
type LogForStorage ¶
type LogForStorage Log
LogForStorage is a wrapper around a Log that flattens and parses the entire content of a log including non-consensus fields.
type MainChain ¶
type MainChain struct { GenesisHeaderRlp []byte Status byte //Active:1 ,Terminated:0,Suspended:2 SyncModel byte //Push:1 , Pull:2, Push+Pull:0 GasToken AssetId NetworkId uint64 Version uint64 StableThreshold uint32 //需要多少个签名才能是稳定单元 Peers []string // pnode://publickey@IP:port format string CrossChainTokens []AssetId // 哪些Token可以跨链转移 }
作为一个分区,我会维护我链接到的主链
func (*MainChain) GetGenesisHeader ¶
type MediatorCreateArgs ¶ added in v1.0.1
type MediatorCreateArgs struct { *core.MediatorInfoBase *core.MediatorApplyInfo core.JurorDepositExtraJson }
创建 mediator 所需的参数
func NewMediatorCreateArgs ¶ added in v1.0.1
func NewMediatorCreateArgs() *MediatorCreateArgs
func (*MediatorCreateArgs) Validate ¶ added in v1.0.3
func (mco *MediatorCreateArgs) Validate() (common.Address, core.JurorDepositExtra, error)
type MediatorDeposit ¶ added in v1.0.3
type MediatorDeposit struct { MediatorDepositExtra DepositBalance }
mediator保证金信息
func NewMediatorDeposit ¶ added in v1.0.3
func NewMediatorDeposit() *MediatorDeposit
type MediatorDepositExtra ¶ added in v1.0.3
type MediatorDepositExtra struct { ApplyEnterTime string `json:"apply_enter_time"` // 申请加入时间 ApplyQuitTime string `json:"apply_quit_time"` // 申请退出时间 Status string `json:"status"` // 申请状态 申请、同意、退出 AgreeTime string `json:"agree_time"` // 基金会同意申请时间' }
mediator保证金額外信息
type MediatorDepositJson ¶ added in v1.0.3
type MediatorDepositJson struct { MediatorDepositExtra DepositBalanceJson }
type MediatorInfo ¶
type MediatorInfo struct { *core.MediatorInfoBase *core.MediatorApplyInfo *core.MediatorInfoExpand }
mediator 信息
func MediatorToInfo ¶
func MediatorToInfo(md *core.Mediator) *MediatorInfo
func NewMediatorInfo ¶
func NewMediatorInfo() *MediatorInfo
func (*MediatorInfo) InfoToMediator ¶
func (mi *MediatorInfo) InfoToMediator() *core.Mediator
type MediatorSchedule ¶
Mediator调度顺序结构体
func InitMediatorSchl ¶
func InitMediatorSchl(gp *GlobalProperty, dgp *DynamicGlobalProperty) *MediatorSchedule
func NewMediatorSchl ¶
func NewMediatorSchl() *MediatorSchedule
func (*MediatorSchedule) String ¶
func (ms *MediatorSchedule) String() string
type MediatorUpdateArgs ¶ added in v1.0.1
type MediatorUpdateArgs struct { AddStr string `json:"account"` // 要更新的mediator地址 RewardAdd *string `json:"rewardAdd" rlp:"nil"` // mediator奖励地址,主要用于接收产块奖励 InitPubKey *string `json:"initPubKey" rlp:"nil"` // mediator的群签名初始公钥 Node *string `json:"node" rlp:"nil"` // 节点网络信息,包括ip和端口等 Logo *string `json:"logo" rlp:"nil"` // 节点图标url Name *string `json:"name" rlp:"nil"` // 节点名称 Location *string `json:"loc" rlp:"nil"` // 节点所在地区 Url *string `json:"url" rlp:"nil"` // 节点宣传网站 Description *string `json:"applyInfo" rlp:"nil"` // 节点详细信息描述 }
更新 mediator 信息所需参数
type MemdagInfos ¶ added in v1.0.4
type MemdagInfos struct {
MemStatus map[string]*MemdagStatus `json:"memdag_status"`
}
type MemdagStatus ¶ added in v1.0.4
type MemdagStatus struct { Token AssetId `json:"token"` StableHeader *Header `json:"stable_header"` // 最新稳定单元header FastHeader *Header `json:"fast_header"` // 最新不稳定单元header Forks map[uint64][]common.Hash `json:"forks"` // 分叉单元 UnstableUnits []common.Hash `json:"unstable_units"` // 不稳定单元 OrphanUnits []common.Hash `json:"orphan_units"` // 孤儿单元 }
type Message ¶
type Message struct { App MessageType `json:"app"` // message type Payload interface{} `json:"payload"` // the true transaction data }
key: message.UnitHash(message+timestamp)
func NewMessage ¶
func NewMessage(app MessageType, payload interface{}) *Message
return message struct
func (*Message) CompareMessages ¶
func (*Message) GetApp ¶ added in v1.0.5
func (m *Message) GetApp() MessageType
func (*Message) GetPayload ¶ added in v1.0.5
func (m *Message) GetPayload() interface{}
func (*Message) GetPaymentPayLoad ¶ added in v1.0.5
func (m *Message) GetPaymentPayLoad() *PaymentPayload
type MessageType ¶
type MessageType byte
func (MessageType) IsRequest ¶
func (mt MessageType) IsRequest() bool
type NonFungibleMetaData ¶
type NonFungibleMetaData struct {
UniqueBytes []byte `json:"UniqueBytes"`
}
type NonFungibleToken ¶
type NonFungibleToken struct { Name string `json:"name"` Symbol string `json:"symbol"` Type byte `json:"type"` //总发行量 TotalSupply uint64 `json:"total_supply"` NonFungibleData []NonFungibleMetaData `json:"NonFungibleData"` SupplyAddress string `json:"supply_address"` }
非同质化通证,比如ERC721
type NorNodBal ¶ added in v1.0.3
type NorNodBal struct { AmountAsset *AmountAsset `json:"amount_asset"` MediatorAddr string `json:"mediator_address"` }
type OutPoint ¶
type OutPoint struct { TxHash common.Hash `json:"txhash"` // reference Utxo struct key field MessageIndex uint32 `json:"message_index"` // message index in transaction OutIndex uint32 `json:"out_index"` }
func KeyToOutpoint ¶
func NewOutPoint ¶
type Output ¶
type Output struct { Value uint64 `json:"value,string"` PkScript []byte `json:"pk_script"` Asset *Asset `json:"asset"` }
func NewTxOut ¶
NewTxOut returns a new bitcoin transaction output with the provided transaction value and public key script.
func (*Output) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the the transaction output.
type PartitionChain ¶
type PartitionChain struct { GenesisHeaderRlp []byte //GenesisHeight uint64 ForkUnitHash common.Hash ForkUnitHeight uint64 GasToken AssetId Status byte //Active:1 ,Terminated:0,Suspended:2 SyncModel byte //Push:1 , Pull:2, Push+Pull:3 NetworkId uint64 Version uint64 StableThreshold uint32 //需要多少个签名才能是稳定单元 Peers []string //pnode://publickey@IP:port format string CrossChainTokens []AssetId // 哪些Token可以跨链转移 }
作为主链,我会维护我上面支持的分区
func (*PartitionChain) GetGenesisHeader ¶
func (p *PartitionChain) GetGenesisHeader() *Header
type PayValue ¶ added in v1.0.3
type PayValue struct { PayTokens *AmountAsset `json:"pay_tokens"` //数量和资产 PayTime string `json:"pay_time"` //发生时间 }
交易的内容
type PaymentPayload ¶
type PaymentPayload struct { Inputs []*Input `json:"inputs"` Outputs []*Output `json:"outputs"` LockTime uint32 `json:"lock_time"` }
Token exchange message and verify message App: payment
func NewPaymentPayload ¶
func NewPaymentPayload(inputs []*Input, outputs []*Output) *PaymentPayload
func (*PaymentPayload) AddTxIn ¶
func (pld *PaymentPayload) AddTxIn(ti *Input)
AddTxIn adds a transaction input to the message.
func (*PaymentPayload) AddTxOut ¶
func (pld *PaymentPayload) AddTxOut(to *Output)
AddTxOut adds a transaction output to the message.
func (*PaymentPayload) IsCoinbase ¶
func (pay *PaymentPayload) IsCoinbase() bool
func (*PaymentPayload) SerializeNoWitness ¶
func (msg *PaymentPayload) SerializeNoWitness(w io.Writer) error
SerializeNoWitness encodes the transaction to w in an identical manner to Serialize, however even if the source transaction has inputs with witness data, the old serialization format will still be used.
type PendingLogsEvent ¶
type PendingLogsEvent struct {
Logs []*Log
}
PendingLogsEvent is posted pre mining and notifies of pending logs.
type PledgeList ¶
type PledgeList struct { TotalAmount uint64 `json:"total_amount"` Date string `json:"date"` //质押列表所在的日期yyyyMMdd Members addressRewardAmount `json:"members"` }
质押列表
func (*PledgeList) Add ¶
func (pl *PledgeList) Add(addr string, amount, reward uint64)
func (*PledgeList) GetAmount ¶
func (pl *PledgeList) GetAmount(addr string) uint64
type PledgeRecordJson ¶ added in v1.0.4
type PledgeStatus ¶
type PledgeStatusJson ¶ added in v1.0.3
type ProofOfExistence ¶
type ProofOfExistence struct { MainData []byte `json:"main_data"` ExtraData []byte `json:"extra_data"` Reference []byte `json:"reference"` UintHeight uint64 `json:"unit_index"` TxId common.Hash `json:"tx_id"` UnitHash common.Hash `json:"unit_hash"` Timestamp uint64 `json:"timestamp"` Creator common.Address `json:"creator"` }
type QueryStateByVersionFunc ¶ added in v1.0.4
type QueryStateByVersionFunc func(id []byte, field string, version *StateVersion) ([]byte, error)
type QueryUtxoFunc ¶
type QuitNode ¶ added in v1.0.3
type QuitNode struct { //Address string `json:"address"` //请求地址 Role string `json:"role"` //请求角色 Time string `json:"time"` //请求时间 }
申请退出
type RemovedLogsEvent ¶
type RemovedLogsEvent struct{ Logs []*Log }
RemovedLogsEvent is posted when a reorg happens
type RemovedTransactionEvent ¶
type RemovedTransactionEvent struct{ Txs Transactions }
RemovedTransactionEvent is posted when a reorg happens
type SignaturePayload ¶
type SignaturePayload struct {
Signatures []SignatureSet `json:"signature_set"` // the array of signature
}
type SignatureSet ¶
type SignatureSet struct { PubKey []byte `json:"public_key"` //compress public key Signature []byte `json:"signature"` // }
func (SignatureSet) String ¶
func (ss SignatureSet) String() string
type SpendProof ¶
type SpendProof struct {
Unit string `json:"unit"`
}
type StateVersion ¶
type StateVersion struct { Height *ChainIndex `json:"height"` TxIndex uint32 `json:"tx_index"` }
func (*StateVersion) Equal ¶
func (version *StateVersion) Equal(in *StateVersion) bool
func (*StateVersion) ParseStringKey ¶
func (version *StateVersion) ParseStringKey(key string) bool
func (*StateVersion) SetBytes ¶
func (version *StateVersion) SetBytes(b []byte)
func (*StateVersion) String ¶
func (version *StateVersion) String() string
type Stxo ¶ added in v1.0.1
type Stxo struct { Amount uint64 `json:"amount"` // 数量 Asset *Asset `json:"asset"` // 资产类别 PkScript []byte `json:"pk_script"` // 锁定脚本 LockTime uint32 `json:"lock_time"` // flags contains additional info about output such as whether it is spent, and whether is has // been modified since is was loaded. Timestamp uint64 `json:"timestamp"` // unit's Timestamp SpentByTxId common.Hash `json:"spent_by_tx_id"` SpentTime uint64 `json:"spent_time"` }
Spent Transaction Output
type SysContractStateChangeEvent ¶
type SysContractStateChangeEvent struct { ContractId []byte WriteSet []ContractWriteSet }
系统合约被调用,导致状态数据库改变
type SysSupportResult ¶
type SysSupportResult struct { TopicIndex uint64 TopicTitle string VoteResults []*SysVoteResult }
type SysTokenIDInfo ¶
type SysVoteResult ¶
type ToGroupSignEvent ¶
type ToGroupSignEvent struct { }
type TokenDefine ¶
type TokenDefine struct { TokenDefineJson []byte `json:"token_define_json"` TokenType int `json:"token_type"` //0 ERC20 1 ERC721 2 VoteToken Creator common.Address `json:"creator"` }
定义一种全新的Token
type TokenPayOut ¶
type TokenSupply ¶
增发一种已经定义好的Token
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func NewTransaction ¶
func NewTransaction(msg []*Message) *Transaction
func (*Transaction) AddMessage ¶
func (tx *Transaction) AddMessage(msg *Message)
AddTxIn adds a transaction input to the message.
func (*Transaction) Asset ¶
func (tx *Transaction) Asset() *Asset
func (*Transaction) CertId ¶
func (tx *Transaction) CertId() []byte
func (*Transaction) Clone ¶
func (tx *Transaction) Clone() *Transaction
Deep copy transaction to a new object
func (*Transaction) CopyFrTransaction ¶
func (tx *Transaction) CopyFrTransaction(cpy *Transaction)
func (*Transaction) DataPayloadSize ¶ added in v1.0.3
func (tx *Transaction) DataPayloadSize() int
func (*Transaction) GetCoinbaseReward ¶ added in v1.0.4
func (tx *Transaction) GetCoinbaseReward(versionFunc QueryStateByVersionFunc, scriptFunc GetAddressFromScriptFunc) (*AmountAsset, error)
func (*Transaction) GetContractId ¶ added in v1.0.5
func (tx *Transaction) GetContractId() []byte
func (*Transaction) GetContractInvokeReqMsgIdx ¶
func (tx *Transaction) GetContractInvokeReqMsgIdx() int
获得合约请求Msg的Index
func (*Transaction) GetContractTxSignatureAddress ¶
func (tx *Transaction) GetContractTxSignatureAddress() []common.Address
获得合约交易的签名对应的陪审员地址
func (*Transaction) GetFromAddrs ¶
func (tx *Transaction) GetFromAddrs(queryUtxoFunc QueryUtxoFunc, getAddrFunc GetAddressFromScriptFunc) ( []common.Address, error)
获取该交易的所有From地址
func (*Transaction) GetNewUtxos ¶
func (tx *Transaction) GetNewUtxos() map[OutPoint]*Utxo
该Tx如果保存后,会产生的新的Utxo
func (*Transaction) GetRequestMsgIndex ¶
func (tx *Transaction) GetRequestMsgIndex() int
Request 这条Message的Index是多少
func (*Transaction) GetRequestTx ¶
func (tx *Transaction) GetRequestTx() *Transaction
如果是合约调用交易,Copy其中的Msg0到ContractRequest的部分,如果不是请求,那么返回完整Tx
func (*Transaction) GetRequesterAddr ¶
func (tx *Transaction) GetRequesterAddr(queryUtxoFunc QueryUtxoFunc, getAddrFunc GetAddressFromScriptFunc) ( common.Address, error)
获取该交易的发起人地址
func (*Transaction) GetResultRawTx ¶
func (tx *Transaction) GetResultRawTx() *Transaction
获取一个被Jury执行完成后,但是还没有进行陪审员签名的交易
func (*Transaction) GetResultTx ¶
func (tx *Transaction) GetResultTx() *Transaction
func (*Transaction) GetSpendOutpoints ¶ added in v1.0.1
func (tx *Transaction) GetSpendOutpoints() []*OutPoint
获取一个交易中花费了哪些OutPoint
func (*Transaction) GetTxFee ¶
func (tx *Transaction) GetTxFee(queryUtxoFunc QueryUtxoFunc) (*AmountAsset, error)
计算该交易的手续费,基于UTXO,所以传入查询UTXO的函数指针
func (*Transaction) GetTxFeeAllocate ¶
func (tx *Transaction) GetTxFeeAllocate(queryUtxoFunc QueryUtxoFunc, getSignerFunc GetScriptSignersFunc, mediatorReward common.Address, getJurorRewardFunc GetJurorRewardAddFunc) ([]*Addition, error)
获得一笔交易的手续费分配情况,包括Mediator的打包费,Juror的合约执行费
func (*Transaction) GetTxFeeAllocateLegacyV1 ¶ added in v1.0.3
func (tx *Transaction) GetTxFeeAllocateLegacyV1(queryUtxoFunc QueryUtxoFunc, getSignerFunc GetScriptSignersFunc, mediatorReward common.Address) ([]*Addition, error)
之前的费用分配有Bug,在ContractInstall的时候会分配错误。在V2中解决了这个问题,但是由于测试网已经有历史数据了,所以需要保留历史计算方法。
func (*Transaction) HasContractPayoutMsg ¶
func (tx *Transaction) HasContractPayoutMsg() (bool, int, *Message)
这个交易是否包含了从合约付款出去的结果,有则返回该Payment
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() common.Hash
Hash hashes the RLP encoding of tx. It uniquely identifies the transaction.
func (*Transaction) Illegal ¶
func (tx *Transaction) Illegal() bool
func (*Transaction) IsContractTx ¶
func (tx *Transaction) IsContractTx() bool
func (*Transaction) IsNewContractInvokeRequest ¶
func (tx *Transaction) IsNewContractInvokeRequest() bool
判断一个交易是否是一个合约请求交易,并且还没有被执行
func (*Transaction) IsSystemContract ¶
func (tx *Transaction) IsSystemContract() bool
func (*Transaction) MarshalJSON ¶
func (tx *Transaction) MarshalJSON() ([]byte, error)
func (*Transaction) ModifiedMsg ¶ added in v1.0.5
func (tx *Transaction) ModifiedMsg(index int, msg *Message)
func (*Transaction) RequestHash ¶
func (tx *Transaction) RequestHash() common.Hash
func (*Transaction) SerializeSize ¶
func (msg *Transaction) SerializeSize() int
func (*Transaction) SerializeSizeStripped ¶
func (tx *Transaction) SerializeSizeStripped() int
SerializeSizeStripped returns the number of bytes it would take to serialize the transaction, excluding any included witness data.
func (*Transaction) SetCertId ¶ added in v1.0.5
func (tx *Transaction) SetCertId(certid []byte)
func (*Transaction) SetIllegal ¶ added in v1.0.5
func (tx *Transaction) SetIllegal(illegal bool)
func (*Transaction) SetMessages ¶ added in v1.0.5
func (tx *Transaction) SetMessages(msgs []*Message)
func (*Transaction) Size ¶
func (tx *Transaction) Size() common.StorageSize
Size returns the true RLP encoded storage UnitSize of the transaction, either by encoding and returning it, or returning a previsouly cached value.
func (*Transaction) UnmarshalJSON ¶
func (tx *Transaction) UnmarshalJSON(data []byte) error
type TransactionWithUnitInfo ¶
type Transactions ¶
type Transactions []*Transaction
func CopyTransactions ¶
func CopyTransactions(txs Transactions) Transactions
func (Transactions) GetRlp ¶
func (s Transactions) GetRlp(i int) []byte
GetRlp implements Rlpable and returns the i'th element of s in rlp.
func (Transactions) GetTxIds ¶
func (txs Transactions) GetTxIds() []common.Hash
func (Transactions) Swap ¶
func (s Transactions) Swap(i, j int)
Swap swaps the i'th and the j'th element in s.
type TxIn ¶
type TxIn struct { PreviousOutPoint *OutPoint `json:"pre_outpoint"` SignatureScript []byte `json:"signature_script"` Sequence uint32 `json:"sequence"` }
TxIn defines a bitcoin transaction input.
type TxLookupEntry ¶
type TxOut ¶
type TxOut struct { Value int64 `json:"value"` PkScript []byte `json:"pk_script"` Asset *Asset `json:"asset_info"` }
TxOut defines a bitcoin transaction output.
type TxPreEvent ¶
type TxPreEvent struct{ Tx *Transaction }
TxPreEvent is posted when a transaction enters the transaction pool.
type UniqueId ¶
func String2UniqueId ¶
func String2UniqueId(str string, t UniqueIdType) (UniqueId, error)
func ZeroUniqueId ¶ added in v1.0.2
func ZeroUniqueId() UniqueId
func (*UniqueId) StringFriendly ¶
func (it *UniqueId) StringFriendly(t UniqueIdType) string
type UniqueIdType ¶
type UniqueIdType byte
const ( UniqueIdType_Null UniqueIdType = iota UniqueIdType_Sequence UniqueIdType = 1 UniqueIdType_Uuid UniqueIdType = 2 UniqueIdType_UserDefine UniqueIdType = 3 UniqueIdType_Ascii UniqueIdType = 4 )
type Unit ¶
type Unit struct { UnitHeader *Header `json:"unit_header"` // unit header Txs Transactions `json:"transactions"` // transaction list // These fields are used by package ptn to track // inter-peer block relay. ReceivedAt time.Time `json:"received_at"` ReceivedFrom interface{} `json:"received_from"` // contains filtered or unexported fields }
key: unit.UnitHash(unit)
func NewUnit ¶
func NewUnit(header *Header, txs Transactions) *Unit
func NewUnitWithHeader ¶
NewBlockWithHeader creates a block with the given header data. The header data is copied, changes to header and to the field values will not affect the block.
func (*Unit) CopyBody ¶
func (u *Unit) CopyBody(txs Transactions) Transactions
func (*Unit) GetAssetId ¶
func (*Unit) GetGroupPubKey ¶ added in v1.0.1
func (*Unit) GetGroupPubKeyByte ¶ added in v1.0.1
func (*Unit) GetGroupPubkey ¶ added in v1.0.5
func (*Unit) GetGroupSign ¶ added in v1.0.1
func (*Unit) Number ¶
func (u *Unit) Number() *ChainIndex
func (*Unit) Size ¶
func (u *Unit) Size() common.StorageSize
function Size, return the unit's StorageSize.
func (*Unit) String4Log ¶
func (*Unit) Transaction ¶
func (u *Unit) Transaction(hash common.Hash) *Transaction
return transaction
func (*Unit) WithBody ¶
func (b *Unit) WithBody(transactions []*Transaction) *Unit
WithBody returns a new block with the given transaction and uncle contents.
type UnitProperty ¶
type UnitProperty struct { Hash common.Hash `json:"hash"` // 最近的单元hash ChainIndex *ChainIndex `json:"chain_Index"` // 最近的单元编号(数量) Timestamp uint32 `json:"timestamp"` // 最近的单元时间 }
type UnstableRepositoryUpdatedEvent ¶ added in v1.0.4
type UnstableRepositoryUpdatedEvent struct { }
type Utxo ¶
type Utxo struct { Amount uint64 `json:"amount"` // 数量 Asset *Asset `json:"asset"` // 资产类别 PkScript []byte `json:"pk_script"` // 锁定脚本 LockTime uint32 `json:"lock_time"` // flags contains additional info about output such as whether it is spent, and whether is has // been modified since is was loaded. Timestamp uint64 `json:"timestamp"` // unit's Timestamp Flags txoFlags }
Unspent Transaction Output
func (*Utxo) GetCoinDays ¶
func (*Utxo) GetTimestamp ¶
func (*Utxo) IsCoinBase ¶
func (*Utxo) IsModified ¶
func (*Utxo) SetCoinBase ¶
func (utxo *Utxo) SetCoinBase()
func (*Utxo) StrPkScript ¶
type UtxoIndex ¶
type UtxoIndex struct { AccountAddr common.Address `json:"account_id"` // 所属人id Asset *Asset OutPoint *OutPoint }
UtxoIndex is key utxo index db value: amount
func (*UtxoIndex) AccountKey ¶
func (*UtxoIndex) QueryFields ¶
type UtxoIndexValue ¶
type UtxoWithOutPoint ¶
func NewUtxoWithOutPoint ¶
func NewUtxoWithOutPoint(utxo *Utxo, o OutPoint) *UtxoWithOutPoint
func (*UtxoWithOutPoint) GetAmount ¶
func (u *UtxoWithOutPoint) GetAmount() uint64
func (*UtxoWithOutPoint) Set ¶
func (u *UtxoWithOutPoint) Set(utxo *Utxo, o *OutPoint)
type VoteToken ¶
type VoteToken struct { Name string `json:"name"` Symbol string `json:"symbol"` //该投票是否允许改投 VoteType byte `json:"vote_type"` //投票结束时间 VoteEndTime time.Time `json:"vote_end_time"` //投票内容,JSON格式的表单 VoteContent []byte `json:"vote_content"` //总发行量 TotalSupply uint64 `json:"total_supply"` SupplyAddress string `json:"supply_address"` }
为投票而创建的Token
type WriteCounter ¶
type WriteCounter common.StorageSize
Source Files ¶
- account.go
- amount_asset.go
- asset.go
- assetId.go
- cert.go
- contract.go
- contract_tpl.go
- data_version.go
- define.go
- deposit.go
- events.go
- global_property.go
- global_property_rlp.go
- header_json.go
- interface.go
- log.go
- mediator.go
- mediator_schedule.go
- memdag_info.go
- message.go
- message_rlp.go
- partition.go
- payment.go
- pledge.go
- proof_of_existence.go
- token.go
- transaction.go
- transaction_json.go
- transaction_rlp.go
- uniqueId.go
- unit.go
- unit_rlp.go
- utxo.go