Documentation ¶
Overview ¶
@author PalletOne core developers <dev@pallet.one>
@date 2018
@author PalletOne core developers <dev@pallet.one>
@date 2018
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 HeaderEqual(oldh, newh *Header) bool
- 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 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) SetBytes(data []byte) error
- func (asset *Asset) SetString(str string) error
- func (asset *Asset) String() string
- 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 ChainMaintenanceEvent
- type ChainSideEvent
- type Contract
- type ContractDeployPayload
- 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 DynamicGlobalProperty
- type ElectionInf
- type ErrUnit
- type FileInfo
- type FungibleToken
- type GetAddressFromScriptFunc
- type GetScriptSignersFunc
- type GlobalPropBase
- 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 GlobalPropertyHistory
- type GlobalTokenInfo
- type Header
- func (h *Header) Author() common.Address
- func (h *Header) ChainIndex() *ChainIndex
- func (cpy *Header) CopyHeader(h *Header)
- func (input *Header) DecodeRLP(s *rlp.Stream) error
- func (input *Header) EncodeRLP(w io.Writer) error
- func (h *Header) GetAssetId() AssetId
- func (h *Header) Hash() common.Hash
- func (h *Header) HashWithOutTxRoot() common.Hash
- func (h *Header) HashWithoutAuthor() common.Hash
- func (h *Header) Index() uint64
- func (h *Header) Size() common.StorageSize
- type ICloneable
- type Input
- type InvokeInfo
- type InvokeTokens
- type KeyValue
- type Log
- type LogForStorage
- type MainChain
- type MediatorCreateOperation
- type MediatorInfo
- type MediatorSchedule
- type Message
- type MessageType
- type NonFungibleMetaData
- type NonFungibleToken
- type OutPoint
- type Output
- type PartitionChain
- type PaymentPayload
- type PendingLogsEvent
- type PledgeList
- type PledgeStatus
- type ProofOfExistence
- type QueryUtxoFunc
- type RemovedLogsEvent
- type RemovedTransactionEvent
- type SequeueTxPoolTxs
- type SignaturePayload
- type SignatureSet
- type SpendProof
- type StateVersion
- 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) Clone() Transaction
- func (tx *Transaction) ContractIdBytes() []byte
- func (tx *Transaction) CopyFrTransaction(cpy *Transaction)
- func (tx *Transaction) CreateDate() string
- func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
- func (tx *Transaction) EncodeRLP(w io.Writer) error
- 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) GetTxFee(queryUtxoFunc QueryUtxoFunc, unitTime int64) (*AmountAsset, error)
- func (tx *Transaction) GetTxFeeAllocate(queryUtxoFunc QueryUtxoFunc, unitTime int64, ...) ([]*Addition, error)
- func (tx *Transaction) HasContractPayoutMsg() (bool, *PaymentPayload)
- func (tx *Transaction) Hash() common.Hash
- func (tx *Transaction) InvokeContractId() []byte
- 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) RequestHash() common.Hash
- func (msg *Transaction) SerializeSize() int
- func (tx *Transaction) SerializeSizeStripped() int
- func (tx *Transaction) Size() common.StorageSize
- func (tx *Transaction) UnmarshalJSON(data []byte) error
- type TransactionWithUnitInfo
- type Transactions
- type TxByCreationDate
- type TxByPrice
- type TxByPriority
- type TxIn
- type TxLookupEntry
- type TxOut
- type TxPoolTransaction
- type TxPoolTxs
- 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 (input *Unit) EncodeRLP(w io.Writer) error
- func (unit *Unit) GetAssetId() AssetId
- func (unit *Unit) GroupPubKey() (kyber.Point, error)
- 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) SetGroupSign(sign []byte)
- 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 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 Wallet
- type WriteCounter
Constants ¶
const ( UNIT_CREATION_DATE_INITIAL_UINT64 = 1536451200 UNIT_CREATION_DATE_INITIAL_FORMATE = "2018-09-09 00:00:00" )
const ( ApplyMediator = "ApplyBecomeMediator" IsApproved = "IsInAgressList" MediatorPayDeposit = "MediatorPayToDepositContract" MediatorList = "MediatorList" GetMediatorDeposit = "GetMediatorDeposit" MediatorWithdrawDeposit = "MediatorApplyCashback" MediatorApplyQuitList = "MediatorApplyQuit" )
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
)
type Hash []byte
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) TX_BASESIZE = (100 * 1024) //100kb )
var DAO uint64 = 100000000
var DepositContractLockScript = common.Hex2Bytes("140000000000000000000000000000000000000001c8")
var (
EmptyRootHash = core.DeriveSha(Transactions{})
)
Functions ¶
func CalcDateSize ¶
func CalcDateSize(data interface{}) common.StorageSize
func FillBytes ¶
func RSVtoPublicKey(hash, r, s, v []byte) (*ecdsa.PublicKey, error) { sig := make([]byte, 65) copy(sig[32-len(r):32], r) copy(sig[64-len(s):64], s) copy(sig[64:], v) return crypto.SigToPub(hash, sig) }
* 根据大端规则填充字节 To full fill bytes according bigendian
func FormatUUID ¶
func HeaderEqual ¶
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 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) 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 ¶
type ChainIndex struct { AssetID AssetId `json:"asset_id"` //IsMain bool `json:"is_main"` Index uint64 `json:"index"` }
type Transaction struct { TxHash common.Hash `json:"txhash"` TxMessages []Message `json:"messages"` Locktime uint32 `json:"lock_time"` }
出于DAG和基于Token的分区共识的考虑,设计了该ChainIndex,
func CopyChainIndex ¶
func CopyChainIndex(index *ChainIndex) *ChainIndex
CopyHeader creates a deep copy of a block header to prevent side effects from modifying a header variable.
func NewChainIndex ¶
func NewChainIndex(assetId AssetId, idx uint64) *ChainIndex
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 ChainMaintenanceEvent ¶
type ChainMaintenanceEvent struct { }
type ChainSideEvent ¶
type ChainSideEvent struct {
Unit *Unit
}
type Contract ¶
type Contract struct { //Contract Id 即Address,[20]byte, // 根据用户创建合约实例申请的RequestId截取其后20字节生成 ContractId []byte TemplateId []byte Name string //1Active 0Stopped Status byte // 合约状态 Creator []byte //address 20bytes CreationTime uint64 // creation date }
func NewContract ¶
func NewContract(deploy *ContractDeployPayload, creator common.Address, unitTime uint64) *Contract
type ContractDeployPayload ¶
type ContractDeployPayload 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 }
App: contract_deploy
func NewContractDeployPayload ¶
func NewContractDeployPayload(templateid []byte, contractid []byte, name string, args [][]byte, elf []ElectionInf, readset []ContractReadSet, writeset []ContractWriteSet, err ContractError) *ContractDeployPayload
func (*ContractDeployPayload) Equal ¶
func (a *ContractDeployPayload) Equal(b *ContractDeployPayload) bool
type ContractDeployRequestPayload ¶
type ContractDeployRequestPayload struct { TplId []byte `json:"tpl_name"` Args [][]byte `json:"args"` Timeout uint32 `json:"timeout"` }
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"` }
用户钱包发起的合约调用申请
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"` // 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 ErrMsg ContractError `json:"contract_error"` // contract error message }
Contract invoke message App: contract_invoke 如果是用户想修改自己的State信息,那么ContractId可以为空或�?0字节
func NewContractInvokePayload ¶
func NewContractInvokePayload(contractid []byte, args [][]byte, excutiontime time.Duration, 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"` }
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"` 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 }
App: contract_deploy
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"` }
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"` Memory uint16 `json:"memory"` }
func NewContractTemplate ¶
func NewContractTemplate(req *ContractInstallRequestPayload, tpl *ContractTplPayload) *ContractTemplate
type ContractTplPayload ¶
type ContractTplPayload struct { TemplateId []byte `json:"template_id"` // contract template id Memory uint16 `json:"memory"` // contract template bytecode memory 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 DynamicGlobalProperty ¶
type DynamicGlobalProperty struct { // 防止同一个mediator连续生产单元导致分叉 LastMediator common.Address // 最新单元的生产 mediator IsShuffledSchedule bool // 标记 mediator 的调度顺序是否刚被打乱 NextMaintenanceTime uint32 // 下一次系统维护时间 LastMaintenanceTime uint32 // 上一次系统维护时间 // 当前的绝对时间槽数量,== 从创世开始所有的时间槽数量 == UnitNum + 丢失的槽数量 CurrentASlot uint64 // 记录每个生产slot的unit生产情况,用于计算mediator的参与率。 // 每一位表示一个生产slot,mediator正常生产unit则值为1,否则为0。 // 最低位表示最近一个slot, 初始值全为1。 RecentSlotsFilled uint64 // 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 }
动态全局属性的结构体定义
func InitDynGlobalProp ¶
func InitDynGlobalProp(genesis *Unit) *DynamicGlobalProperty
func NewDynGlobalProp ¶
func NewDynGlobalProp() *DynamicGlobalProperty
type ElectionInf ¶
type ElectionInf struct { Etype byte `json:"etype"` //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 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 GetScriptSignersFunc ¶
type GetScriptSignersFunc func(tx *Transaction, msgIdx, inputIndex int) ([]common.Address, error)
type GlobalPropBase ¶
type GlobalPropBase struct { ImmutableParameters core.ImmutableChainParameters // 不可改变的区块链网络参数 ChainParameters core.ChainParameters // 区块链网络参数 }
func NewGlobalPropBase ¶
func NewGlobalPropBase() GlobalPropBase
type GlobalProperty ¶
type GlobalProperty struct { GlobalPropBase ActiveJuries map[common.Address]bool // 当前活跃Jury集合 ActiveMediators map[common.Address]bool // 当前活跃 mediator 集合;每个维护间隔更新一次 PrecedingMediators map[common.Address]bool // 上一届 mediator }
全局属性的结构体定义
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 GlobalPropertyHistory ¶
type GlobalPropertyHistory struct { // unit生产之间的间隔时间,以秒为单元。 interval in seconds between Units MediatorInterval uint8 `json:"mediatorInterval"` // 区块链维护事件之间的间隔,以秒为单元。 interval in sections between unit maintenance events MaintenanceInterval uint32 `json:"maintenanceInterval"` // 在维护时跳过的MediatorInterval数量。 number of MediatorInterval to skip at maintenance time MaintenanceSkipSlots uint8 `json:"maintenanceSkipSlots"` ActiveJuries []common.Address //当前活跃Jury集合 ActiveMediators []common.Address // 当前活跃 mediator 集合;每个维护间隔更新一次 EffectiveTime uint64 //生效时间 EffectiveHeight uint64 //生效高度 ExpiredTime uint64 //失效时间 }
type GlobalTokenInfo ¶
type GlobalTokenInfo struct { Symbol 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 { ParentsHash []common.Hash `json:"parents_hash"` Authors Authentifier `json:"mediator"` // the unit creation authors GroupSign []byte `json:"group_sign"` // 群签名, 用于加快单元确认速度 GroupPubKey []byte `json:"group_pubKey"` // 群公钥, 用于验证群签名 TxRoot common.Hash `json:"root"` TxsIllegal []uint16 `json:"txs_illegal"` //Unit中非法交易索引 Number *ChainIndex `json:"index"` Extra []byte `json:"extra"` Time int64 `json:"creation_time"` // unit create time CryptoLib []byte `json:"crypto_lib"` //该区块使用的加解密算法和哈希算法,0位表示非对称加密算法,1位表示Hash算法 }
func CopyHeader ¶
func (*Header) ChainIndex ¶
func (h *Header) ChainIndex() *ChainIndex
func (*Header) CopyHeader ¶
func (*Header) GetAssetId ¶
func (*Header) HashWithOutTxRoot ¶
HashWithOutTxRoot return header's hash without txs root.
func (*Header) HashWithoutAuthor ¶
func (*Header) Size ¶
func (h *Header) Size() common.StorageSize
type ICloneable ¶
type ICloneable interface {
Clone() interface{}
}
type Input ¶
type Input struct { SignatureScript []byte `json:"signature_script"` Extra []byte `json:"extra" rlp:"nil"` // if user creating a new asset, this field should be it's config data. Otherwise it is null. 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 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 reorganisation. // 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 MediatorCreateOperation ¶
type MediatorCreateOperation struct { *core.MediatorInfoBase *core.MediatorApplyInfo }
func (*MediatorCreateOperation) FeePayer ¶
func (mco *MediatorCreateOperation) FeePayer() common.Address
type MediatorInfo ¶
type MediatorInfo struct { *core.MediatorInfoBase *core.MediatorApplyInfo *core.MediatorInfoExpand }
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 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) CopyMessages ¶
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 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 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 []*AddressAmount `json:"members"` }
质押列表
func (*PledgeList) Add ¶
func (pl *PledgeList) Add(addr string, amount uint64)
func (*PledgeList) GetAmount ¶
func (pl *PledgeList) GetAmount(addr string) uint64
type PledgeStatus ¶
type ProofOfExistence ¶
type QueryUtxoFunc ¶
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 SequeueTxPoolTxs ¶
type SequeueTxPoolTxs struct {
// contains filtered or unexported fields
}
func (*SequeueTxPoolTxs) Add ¶
func (seqTxs *SequeueTxPoolTxs) Add(newPoolTx *TxPoolTransaction)
func (*SequeueTxPoolTxs) AddPriority ¶
func (seqTxs *SequeueTxPoolTxs) AddPriority(newPoolTx *TxPoolTransaction)
add priority
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 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 { TxMessages []*Message `json:"messages"` CertId []byte `json:"cert_id"` // should be big.Int byte Illegal bool `json:"Illegal"` // not hash, 1:no valid, 0:ok }
func NewContractCreation ¶
func NewContractCreation(msg []*Message) *Transaction
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
address return the tx's original address of from and to
func (tx *Transaction) GetAddressInfo() ([]*OutPoint, [][]byte) { froms := make([]*OutPoint, 0) tos := make([][]byte, 0) if len(tx.Messages()) > 0 { msg := tx.Messages()[0] if msg.App == APP_PAYMENT { payment, ok := msg.Payload.(*PaymentPayload) if ok { for _, input := range payment.Inputs { if input.PreviousOutPoint != nil { froms = append(froms, input.PreviousOutPoint) } } for _, out := range payment.Outputs { tos = append(tos, out.PkScript[:]) } } } } return froms, tos }
func (*Transaction) Clone ¶
func (tx *Transaction) Clone() Transaction
Deep copy transaction to a new object
func (*Transaction) ContractIdBytes ¶
func (tx *Transaction) ContractIdBytes() []byte
func (*Transaction) CopyFrTransaction ¶
func (tx *Transaction) CopyFrTransaction(cpy *Transaction)
func (*Transaction) CreateDate ¶
func (tx *Transaction) CreateDate() string
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) GetTxFee ¶
func (tx *Transaction) GetTxFee(queryUtxoFunc QueryUtxoFunc, unitTime int64) (*AmountAsset, error)
计算该交易的手续费,基于UTXO,所以传入查询UTXO的函数指针
func (*Transaction) GetTxFeeAllocate ¶
func (tx *Transaction) GetTxFeeAllocate(queryUtxoFunc QueryUtxoFunc, unitTime int64, getSignerFunc GetScriptSignersFunc, mediatorAddr common.Address) ([]*Addition, error)
func (*Transaction) HasContractPayoutMsg ¶
func (tx *Transaction) HasContractPayoutMsg() (bool, *PaymentPayload)
这个交易是否包含了从合约付款出去的结果,有则返回该Payment
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() common.Hash
Hash hashes the RLP encoding of tx. It uniquely identifies the transaction.
func (*Transaction) InvokeContractId ¶
func (tx *Transaction) InvokeContractId() []byte
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) Messages ¶
func (tx *Transaction) Messages() []*Message
func (*Transaction) RequestHash ¶
func (tx *Transaction) RequestHash() common.Hash
func (*Transaction) SerializeSize ¶
func (msg *Transaction) SerializeSize() int
func (msg *PaymentPayload) SerializeSize() int { n := msg.baseSize() return n }
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) 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 TxDifference ¶
func TxDifference(a, b Transactions) (keep Transactions)
TxDifference returns a new set t which is the difference between a to b.
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) Hash ¶
func (s Transactions) Hash() 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 TxByCreationDate ¶
type TxByCreationDate []*TxPoolTransaction
func (TxByCreationDate) Len ¶
func (tc TxByCreationDate) Len() int
func (TxByCreationDate) Less ¶
func (tc TxByCreationDate) Less(i, j int) bool
func (TxByCreationDate) Swap ¶
func (tc TxByCreationDate) Swap(i, j int)
type TxByPrice ¶
type TxByPrice TxPoolTxs
TxByPrice implements both the sort and the heap interface, making it useful for all at once sorting as well as individually adding and removing elements.
type TxByPriority ¶
type TxByPriority []*TxPoolTransaction
func (TxByPriority) Len ¶
func (s TxByPriority) Len() int
func (TxByPriority) Less ¶
func (s TxByPriority) Less(i, j int) bool
func (*TxByPriority) Pop ¶
func (s *TxByPriority) Pop() interface{}
func (*TxByPriority) Push ¶
func (s *TxByPriority) Push(x interface{})
func (TxByPriority) Swap ¶
func (s TxByPriority) Swap(i, j int)
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 TxPoolTransaction ¶
type TxPoolTransaction struct { Tx *Transaction From []*OutPoint CreationDate time.Time `json:"creation_date"` Priority_lvl string `json:"priority_lvl"` // 打包的优先级 UnitHash common.Hash UnitIndex uint64 Pending bool Confirmed bool IsOrphan bool Discarded bool // will remove //TxFee *AmountAsset `json:"tx_fee"` TxFee []*Addition `json:"tx_fee"` Index uint64 `json:"index"` // index 是该Unit位置。 Extra []byte Tag uint64 Expiration time.Time //该Tx依赖于哪些TxId作为先决条件 DependOnTxs []common.Hash }
func (*TxPoolTransaction) GetPriorityLvl ¶
func (tx *TxPoolTransaction) GetPriorityLvl() string
func (*TxPoolTransaction) GetPriorityfloat64 ¶
func (tx *TxPoolTransaction) GetPriorityfloat64() float64
func (*TxPoolTransaction) GetTxFee ¶
func (tx *TxPoolTransaction) GetTxFee() *big.Int
func (*TxPoolTransaction) Less ¶
func (tx *TxPoolTransaction) Less(otherTx interface{}) bool
func (*TxPoolTransaction) SetPriorityLvl ¶
func (tx *TxPoolTransaction) SetPriorityLvl(priority float64)
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 (*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 UnitHash common.Hash `json:"unit_hash"` // unit hash UnitSize common.StorageSize `json:"unit_size"` // unit size // These fields are used by package ptn to track // inter-peer block relay. ReceivedAt time.Time ReceivedFrom interface{} }
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) GroupPubKey ¶
func (*Unit) Number ¶
func (u *Unit) Number() *ChainIndex
func (u *Unit) NumberU64() uint64 { return u.Head.Number.Uint64() }
func (*Unit) SetGroupSign ¶
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 // 最近的单元hash Index *ChainIndex // 最近的单元编号(数量) Timestamp uint32 // 最近的单元时间 }
type Utxo ¶
type Utxo struct { Amount uint64 `json:"amount"` // 数量 Asset *Asset `json:"asset"` // 资产类别 PkScript []byte `json:"pk_script"` // 锁定脚本 LockTime uint32 `json:"lock_time"` //VoteResult common.Address `json:"vote_info"` //这个字段删掉 // 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 }
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 Wallet ¶
type Wallet struct { Wallet string `json:"wallet"` Address string `json:"address"` Amount int `json:"amount"` DefinitionTemplate map[string]interface{} `json:"definition_template"` CreationDate time.Time `json:"creation_date"` FullApprovalDate time.Time `json:"full_approval_date"` ReadyDate time.Time `json:"ready_date"` }
key: wallet.UnitHash(wallet+create_date)
type WriteCounter ¶
type WriteCounter common.StorageSize
Source Files ¶
- account.go
- amount_asset.go
- asset.go
- assetId.go
- author.go
- cert.go
- contract.go
- contract_rlp.go
- contract_tpl.go
- data_version.go
- define.go
- events.go
- global_property.go
- global_property_rlp.go
- interface.go
- log.go
- mediator.go
- mediator_schedule.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
- transaction_sign.go
- uniqueId.go
- unit.go
- unit_rlp.go
- utxo.go
- wallet.go