modules

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2020 License: GPL-3.0, GPL-3.0 Imports: 33 Imported by: 2

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

View Source
const (
	UNIT_CREATION_DATE_INITIAL_UINT64  = 1536451200
	UNIT_CREATION_DATE_INITIAL_FORMATE = "2018-09-09 00:00:00"
)
View Source
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"
)
View Source
const (
	ApplyMediator           = "ApplyBecomeMediator"
	IsApproved              = "IsInAgreeList"
	MediatorPayDeposit      = "MediatorPayToDepositContract"
	MediatorList            = "MediatorList"
	GetMediatorDeposit      = "GetMediatorDeposit"
	MediatorApplyQuit       = "MediatorApplyQuit"
	UpdateMediatorInfo      = "UpdateMediatorInfo"
	HandleForAddMediator    = "HandleForAddMediator"
	HandleForRemoveMediator = "HandleForRemoveMediator"
)
View Source
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
)
View Source
const (
	FoundationAddress = "FoundationAddress"
	JuryList          = "JuryList"
	DeveloperList     = "DeveloperList"
	DepositRate       = "DepositRate"
)
View Source
const (
	DesiredSysParamsWithoutVote = "DesiredSysParamsWithoutVote"
	DesiredSysParamsWithVote    = "DesiredSysParamsWithVote"
	DesiredActiveMediatorCount  = "ActiveMediatorCount"
)
View Source
const (
	FIELD_SPLIT_STR     = "^*^"
	FIELD_GENESIS_ASSET = "GenesisAsset"
)
View Source
const (
	U_STATE_NO_GROUPSIGN = 0x20
	U_STATE_NO_CONFIRMED = 0x21
	U_STATE_CONFIRMED    = 0x22
)

unit state

View Source
const GlobalPrefix = "Tokens_"
View Source
const (
	ID_LENGTH = 16
)
View Source
const (
	MaxTxInSequenceNum uint32 = 0xffffffff
)
View Source
const PTN string = "PTN"

Variables

View Source
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'}
)
View Source
var (
	//TXFEE       = big.NewInt(100000000) // transaction fee =1ptn
	TX_MAXSIZE  = 256 * 1024 //256kb
	TX_BASESIZE = 100 * 1024 //100kb
)
View Source
var ContractChainId = "palletone"
View Source
var DAO uint64 = 100000000
View Source
var (
	EmptyRootHash = core.DeriveSha(Transactions{})
)

Functions

func CalcDateSize

func CalcDateSize(data interface{}) common.StorageSize

func FillBytes

func FillBytes(data []byte, lenth uint8) []byte

根据大端规则填充字节 To full fill bytes according bigendian

func FormatUUID

func FormatUUID(buf []byte) string

func LoadCertBytes

func LoadCertBytes(original []byte) ([]byte, error)

func MsgstoAddress

func MsgstoAddress(msgs []*Message) common.Address

func ParseUUID

func ParseUUID(uuid string) ([]byte, error)

func SortTxs added in v1.0.6

func SortTxs(txs map[common.Hash]*Transaction, utxoFunc QueryUtxoFunc) ([]*Transaction, []*Transaction, []*Transaction)

传入一堆交易,按依赖关系进行排序,并根据UTXO的使用情况,分为3类Tx: 1.排序后的正常交易,2.孤儿交易,3.因为双花需要丢弃的交易

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

func VarIntSerializeSize(val uint64) int

VarIntSerializeSize returns the number of bytes it would take to serialize val as a variable length integer.

Types

type AccountInfo

type AccountInfo struct {
	Balance uint64
	//当前账户投票的Mediator
	VotedMediators map[string]bool
}

type AccountStateUpdatePayload

type AccountStateUpdatePayload struct {
	WriteSet []AccountStateWriteSet `json:"write_set"`
}

一个地址对应的个人StateDB空间

type AccountStateWriteSet

type AccountStateWriteSet struct {
	IsDelete bool   `json:"is_delete"`
	Key      string `json:"key"`
	Value    []byte `json:"value"`
}

type ActiveMediatorsUpdatedEvent

type ActiveMediatorsUpdatedEvent struct {
	IsChanged bool // 标记活跃 mediators 是否有改变
}

活跃 mediators 更新事件

type Addition

type Addition struct {
	Addr   common.Address `json:"address"`
	Amount uint64         `json:"amount"`
	Asset  *Asset         `json:"asset"`
}

func (*Addition) IsEqualStyle

func (a *Addition) IsEqualStyle(b *Addition) (bool, error)

func (*Addition) Key

func (a *Addition) Key() string

type AddressAmount

type AddressAmount struct {
	Address string `json:"address"`
	Amount  uint64 `json:"amount"`
}

账户质押情况

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

type AmountAsset struct {
	Amount uint64 `json:"amount"`
	Asset  *Asset `json:"asset"`
}

金额和资产

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) GetFloatdec added in v1.0.8

func (aa *AmountAsset) GetFloatdec() float64

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 NewAsset

func NewAsset(symbol string, assetType AssetType, decimal byte, requestId []byte,
	uidType UniqueIdType, uniqueId UniqueId) (*Asset, error)

func NewPTNAsset

func NewPTNAsset() *Asset

func StringToAsset

func StringToAsset(str string) (*Asset, error)

func (*Asset) Bytes

func (asset *Asset) Bytes() []byte

func (*Asset) DisplayAmount

func (asset *Asset) DisplayAmount(amount uint64) decimal.Decimal

func (*Asset) Equal

func (asset *Asset) Equal(another *Asset) bool

func (*Asset) GetDecimal

func (asset *Asset) GetDecimal() byte

func (*Asset) IsEmpty

func (asset *Asset) IsEmpty() bool

func (*Asset) IsSameAssetId

func (asset *Asset) IsSameAssetId(another *Asset) bool

func (*Asset) IsSimilar

func (asset *Asset) IsSimilar(similar *Asset) bool

func (*Asset) MarshalJSON

func (asset *Asset) MarshalJSON() ([]byte, error)

func (Asset) MarshalText added in v1.0.3

func (asset Asset) MarshalText() ([]byte, error)

func (*Asset) SetBytes

func (asset *Asset) SetBytes(data []byte) error

func (*Asset) SetString

func (asset *Asset) SetString(str string) error

func (*Asset) String

func (asset *Asset) String() string

func (*Asset) Uint64Amount added in v1.0.5

func (asset *Asset) Uint64Amount(amt decimal.Decimal) uint64

func (*Asset) UnmarshalJSON

func (asset *Asset) UnmarshalJSON(data []byte) error

type AssetId

type AssetId [ID_LENGTH]byte

AssetId 资产类别,前26bit是symbol的base36编码,27-29是Symbol编码后字节长度,30-32bit为AssetType,剩下的是Txid的前12字节

func NewAssetId

func NewAssetId(symbol string, assetType AssetType, decimal byte, requestId []byte,
	uniqueIdType UniqueIdType) (AssetId, error)

func NewPTNIdType

func NewPTNIdType() AssetId

func SetIdTypeByHex

func SetIdTypeByHex(id string) (AssetId, error)

func ZeroIdType16

func ZeroIdType16() AssetId

func (AssetId) Bytes

func (it AssetId) Bytes() []byte

func (AssetId) DisplayAmount added in v1.0.6

func (asset AssetId) DisplayAmount(amount uint64) decimal.Decimal

func (AssetId) Equal

func (asset AssetId) Equal(another AssetId) bool

func (AssetId) GetAssetType

func (id AssetId) GetAssetType() AssetType

func (AssetId) GetDecimal

func (id AssetId) GetDecimal() byte

func (AssetId) GetSymbol

func (id AssetId) GetSymbol() string

func (AssetId) MarshalJSON

func (assetId AssetId) MarshalJSON() ([]byte, error)

func (AssetId) ParseAssetId

func (id AssetId) ParseAssetId() (string, AssetType, byte, []byte, UniqueIdType)

func (*AssetId) SetBytes

func (it *AssetId) SetBytes(b []byte)

func (AssetId) String

func (it AssetId) String() string

func (AssetId) ToAsset

func (id AssetId) ToAsset() *Asset

func (AssetId) Uint64Amount added in v1.0.6

func (asset AssetId) Uint64Amount(amt decimal.Decimal) uint64

func (*AssetId) UnmarshalJSON

func (assetId *AssetId) UnmarshalJSON(data []byte) error

type AssetType

type AssetType byte
const (
	AssetType_FungibleToken AssetType = iota
	AssetType_NonFungibleToken
	AssetType_VoteToken
)

type Authentifier

type Authentifier struct {
	PubKey    []byte `json:"pubkey"`
	Signature []byte `json:"signature"`
}

func (*Authentifier) Address

func (au *Authentifier) Address() common.Address

func (*Authentifier) Empty

func (au *Authentifier) Empty() bool

type CertBytesInfo

type CertBytesInfo struct {
	Holder string
	Raw    []byte // 可以直接使用x509.ParseCertificate()接口获取证书信息
}

type CertHolderInfo

type CertHolderInfo struct {
	Holder   string
	IsServer bool // 是否是中间证书
	CertID   string
}

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 CertState

type CertState struct {
	CertID         string
	RecovationTime string
}

type ChainEvent

type ChainEvent struct {
	Unit *Unit
	Hash common.Hash
}

type ChainHeadEvent

type ChainHeadEvent struct{ Unit *Unit }

type ChainIndex

type ChainIndex struct {
	AssetID AssetId `json:"asset_id"`
	Index   uint64  `json:"index"`
}

出于DAG和基于Token的分区共识的考虑,设计了该ChainIndex,

func NewChainIndex

func NewChainIndex(assetId AssetId, idx uint64) *ChainIndex

func (*ChainIndex) Bytes

func (height *ChainIndex) Bytes() []byte

Index 8Bytes + AssetID 16Bytes

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 ChainIndexTemp struct {
	AssetID AssetId `json:"asset_id"`
	Index   uint64  `json:"index"`
}

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

func NewContract(templateId []byte, deploy *ContractDeployPayload, creator common.Address, unitTime uint64, version string) *Contract

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

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

type ContractError

type ContractError struct {
	Code    uint32 `json:"error_code"`    // error code
	Message string `json:"error_message"` // error data
}

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

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

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

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

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

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"`
}

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

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 DataVersion struct {
	Name    string
	Version string
}

type DbRow

type DbRow struct {
	Key   []byte
	Value []byte
}

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 DepositBalanceJson struct {
	Balance   decimal.Decimal `json:"balance"`
	EnterTime string          `json:"enter_time"`
	Role      string          `json:"role"`
}

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 ErrUnit

type ErrUnit float64

func (ErrUnit) Error

func (e ErrUnit) Error() string

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 GetAddressFromScriptFunc

type GetAddressFromScriptFunc func(lockScript []byte) (common.Address, error)

type GetJurorRewardAddFunc added in v1.0.4

type GetJurorRewardAddFunc func(jurorAdd common.Address) common.Address

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 GlobalPropExtraTemp struct {
	//ActiveJuries       []common.Address
	ActiveMediators    []common.Address
	PrecedingMediators []common.Address
}

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) DecodeRLP

func (gp *GlobalProperty) DecodeRLP(s *rlp.Stream) error

func (*GlobalProperty) EncodeRLP

func (gp *GlobalProperty) EncodeRLP(w io.Writer) error

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 struct {
	// contains filtered or unexported fields
}

func CopyHeader

func CopyHeader(h *Header) *Header

func NewEmptyHeader added in v1.0.6

func NewEmptyHeader() *Header

func NewHeader

func NewHeader(parents []common.Hash, tx_root common.Hash, pubkey, sig, extra, crypto_lib []byte,
	txs_illgal []uint16, asset_id AssetId, index uint64, t int64) *Header

func (*Header) Author

func (h *Header) Author() common.Address

func (*Header) ChainIndex

func (h *Header) ChainIndex() *ChainIndex

func (*Header) CopyHeader

func (cpy *Header) CopyHeader(h *Header)

func (*Header) Cryptolib added in v1.0.5

func (h *Header) Cryptolib() []byte

func (*Header) DecodeRLP

func (input *Header) DecodeRLP(s *rlp.Stream) error

func (*Header) EncodeRLP

func (input *Header) EncodeRLP(w io.Writer) error

func (*Header) Extra

func (h *Header) Extra() []byte

func (*Header) GetAssetId

func (h *Header) GetAssetId() AssetId

func (*Header) GetAuthors added in v1.0.5

func (h *Header) GetAuthors() Authentifier

func (*Header) GetGroupPubKey added in v1.0.1

func (h *Header) GetGroupPubKey() (kyber.Point, error)

func (*Header) GetGroupPubKeyByte added in v1.0.1

func (h *Header) GetGroupPubKeyByte() []byte

func (*Header) GetGroupPubkey added in v1.0.5

func (h *Header) GetGroupPubkey() []byte

func (*Header) GetGroupSign added in v1.0.2

func (h *Header) GetGroupSign() []byte

func (*Header) GetNumber added in v1.0.2

func (h *Header) GetNumber() *ChainIndex

func (*Header) GetTxsIllegal added in v1.0.5

func (h *Header) GetTxsIllegal() []uint16

func (*Header) Hash

func (h *Header) Hash() common.Hash

func (*Header) HashWithOutTxRoot

func (h *Header) HashWithOutTxRoot() common.Hash

HashWithOutTxRoot return header's hash without txs root.

func (*Header) HashWithoutAuthor

func (h *Header) HashWithoutAuthor() common.Hash

func (*Header) Index

func (h *Header) Index() uint64

func (*Header) MarshalJSON added in v1.0.5

func (input *Header) MarshalJSON() ([]byte, error)

func (*Header) NumberU64 added in v1.0.1

func (h *Header) NumberU64() uint64

func (*Header) ParentHash added in v1.0.2

func (h *Header) ParentHash() []common.Hash

func (*Header) ResetHash added in v1.0.5

func (h *Header) ResetHash()

func (*Header) SetAuthor added in v1.0.5

func (h *Header) SetAuthor(author Authentifier)

func (*Header) SetGroupPubkey added in v1.0.5

func (h *Header) SetGroupPubkey(key []byte)

func (*Header) SetGroupSign added in v1.0.5

func (h *Header) SetGroupSign(sign []byte)

func (*Header) SetHeight added in v1.0.6

func (h *Header) SetHeight(assetId AssetId, index uint64)

func (*Header) SetTimestamp added in v1.0.6

func (h *Header) SetTimestamp(timestamp int64)

func (*Header) SetTxRoot added in v1.0.5

func (h *Header) SetTxRoot(txroot common.Hash)

func (*Header) SetTxsIllegal added in v1.0.5

func (h *Header) SetTxsIllegal(txsillegal []uint16)

func (*Header) Size

func (h *Header) Size() common.StorageSize

func (*Header) Timestamp added in v1.0.2

func (h *Header) Timestamp() int64

func (*Header) TxRoot

func (h *Header) TxRoot() common.Hash

func (*Header) UnmarshalJSON added in v1.0.5

func (input *Header) UnmarshalJSON(b []byte) error

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"`
	Sequence         uint32
}

func NewTxIn

func NewTxIn(prevOut *OutPoint, signatureScript []byte) *Input

NewTxIn returns a new ptn transaction input with the provided previous outpoint point and signature script with a default sequence of MaxTxInSequenceNum.

func (*Input) DecodeRLP

func (input *Input) DecodeRLP(s *rlp.Stream) error

func (*Input) EncodeRLP

func (input *Input) EncodeRLP(w io.Writer) error

func (*Input) SerializeSize

func (t *Input) SerializeSize() int

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 KeyValue

type KeyValue struct {
	Key   string
	Value []byte
}

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.

func (*Log) DecodeRLP

func (l *Log) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder.

func (*Log) EncodeRLP

func (l *Log) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder.

func (*Log) String

func (l *Log) String() string

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.

func (*LogForStorage) DecodeRLP

func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder.

func (*LogForStorage) EncodeRLP

func (l *LogForStorage) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder.

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

func (p *MainChain) GetGenesisHeader() *Header

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

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

mediator 信息

func MediatorToInfo

func MediatorToInfo(md *core.Mediator) *MediatorInfo

func NewMediatorInfo

func NewMediatorInfo() *MediatorInfo

func (*MediatorInfo) InfoToMediator

func (mi *MediatorInfo) InfoToMediator() *core.Mediator

type MediatorInfo2 added in v1.0.7

type MediatorInfo2 struct {
	MediatorInfo
	Version string
}

type MediatorSchedule

type MediatorSchedule struct {
	CurrentShuffledMediators []common.Address
}

Mediator调度顺序结构体

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和端口等
	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 信息所需参数

func (*MediatorUpdateArgs) Validate added in v1.0.2

func (mua *MediatorUpdateArgs) Validate() (common.Address, error)

type Member added in v1.0.3

type Member struct {
	Key   string `json:"key"`
	Value []byte `json:"value"`
}

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 CopyMessage added in v1.0.5

func CopyMessage(cpyMsg *Message) *Message

message深拷贝

func NewMessage

func NewMessage(app MessageType, payload interface{}) *Message

return message struct

func (*Message) CompareMessages

func (msg *Message) CompareMessages(inMsg *Message) bool

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 KeyToOutpoint(key []byte) *OutPoint

func NewOutPoint

func NewOutPoint(hash common.Hash, messageindex uint32, outindex uint32) *OutPoint

func (*OutPoint) Bytes

func (outpoint *OutPoint) Bytes() []byte

func (*OutPoint) Clone added in v1.0.1

func (outpoint *OutPoint) Clone() *OutPoint

func (*OutPoint) Hash

func (outpoint *OutPoint) Hash() common.Hash

func (*OutPoint) IsEmpty

func (outpoint *OutPoint) IsEmpty() bool

func (*OutPoint) SetString

func (outpoint *OutPoint) SetString(data string) error

func (*OutPoint) String

func (outpoint *OutPoint) String() string

func (*OutPoint) ToKey

func (outpoint *OutPoint) ToKey(prefix []byte) []byte

type Output

type Output struct {
	Value    uint64 `json:"value,string"`
	PkScript []byte `json:"pk_script"`
	Asset    *Asset `json:"asset"`
}

func NewTxOut

func NewTxOut(value uint64, pkScript []byte, asset *Asset) *Output

NewTxOut returns a new bitcoin transaction output with the provided transaction value and public key script.

func (*Output) SerializeSize

func (t *Output) SerializeSize() int

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

func (*PledgeList) Reduce

func (pl *PledgeList) Reduce(addr string, amount uint64) (uint64, error)

从质押列表中提币,Amount =MaxUint64表示全部提取

type PledgeRecordJson added in v1.0.4

type PledgeRecordJson struct {
	Date    string          `json:"date"`
	Address string          `json:"address"`
	Amount  decimal.Decimal `json:"amount"`
	Reward  decimal.Decimal `json:"reward"`
}

type PledgeStatus

type PledgeStatus struct {
	NewDepositAmount    uint64
	PledgeAmount        uint64
	WithdrawApplyAmount uint64
	OtherAmount         uint64
}

type PledgeStatusJson added in v1.0.3

type PledgeStatusJson struct {
	NewDepositAmount    decimal.Decimal
	PledgeAmount        decimal.Decimal
	WithdrawApplyAmount string
	OtherAmount         decimal.Decimal
}

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 ProofOfExistencesInfo added in v1.0.7

type ProofOfExistencesInfo 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 QueryStateByVersionFunc added in v1.0.4

type QueryStateByVersionFunc func(id []byte, field string, version *StateVersion) ([]byte, error)

type QueryUtxoFunc

type QueryUtxoFunc func(outpoint *OutPoint) (*Utxo, error)

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 RollbackUnitEvent added in v1.0.7

type RollbackUnitEvent struct{ Unit *Unit }

type SaveUnitEvent added in v1.0.6

type SaveUnitEvent struct{ Unit *Unit }

type SignaturePayload

type SignaturePayload struct {
	Signatures []SignatureSet `json:"signature_set"` // the array of signature
}

func NewSignaturePayload added in v1.0.8

func NewSignaturePayload(pubKey, signature []byte) *SignaturePayload

func (*SignaturePayload) SignAddress added in v1.0.8

func (s *SignaturePayload) SignAddress() []common.Address

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) Bytes

func (version *StateVersion) Bytes() []byte

(16+8)+4=28

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

func NewStxo added in v1.0.1

func NewStxo(utxo *Utxo, spentTxId common.Hash, spentTime uint64) *Stxo

type SysContractStateChangeEvent

type SysContractStateChangeEvent struct {
	ContractId []byte
	WriteSet   []ContractWriteSet
}

系统合约被调用,导致状态数据库改变

type SysSupportResult

type SysSupportResult struct {
	TopicIndex  uint64
	TopicTitle  string
	VoteResults []*SysVoteResult
}

type SysTokenIDInfo

type SysTokenIDInfo struct {
	CreateAddr     string
	TotalSupply    uint64
	LeastNum       uint64
	AssetID        string
	CreateTime     int64
	IsVoteEnd      bool
	SupportResults []*SysSupportResult
}

type SysVoteResult

type SysVoteResult struct {
	SelectOption string
	Num          uint64
}

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 TokenPayOut struct {
	Asset    *Asset
	Amount   uint64
	PayTo    common.Address
	LockTime uint32
}

type TokenSupply

type TokenSupply struct {
	UniqueId []byte
	AssetId  []byte
	Amount   uint64
	Creator  common.Address
}

增发一种已经定义好的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) CopyPartTx added in v1.0.8

func (tx *Transaction) CopyPartTx(msgIdx int) *Transaction

复制一个只包含前面几条Message的Tx,包括msgIdx本身这条

func (*Transaction) DataPayloadSize added in v1.0.3

func (tx *Transaction) DataPayloadSize() int

func (*Transaction) DecodeRLP

func (tx *Transaction) DecodeRLP(s *rlp.Stream) error

func (*Transaction) EncodeRLP

func (tx *Transaction) EncodeRLP(w io.Writer) error

func (*Transaction) ErrorResult added in v1.0.6

func (tx *Transaction) ErrorResult() string

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) GetContractTxType added in v1.0.6

func (tx *Transaction) GetContractTxType() MessageType

func (*Transaction) GetFromAddrs

func (tx *Transaction) GetFromAddrs(queryUtxoFunc QueryUtxoFunc, getAddrFunc GetAddressFromScriptFunc) ([]common.Address, error)

获取该交易的所有From地址

func (*Transaction) GetLocktime added in v1.0.6

func (tx *Transaction) GetLocktime() int64

获取locktime

func (*Transaction) GetNewTxUtxoAndReqUtxos added in v1.0.6

func (tx *Transaction) GetNewTxUtxoAndReqUtxos() map[OutPoint]*Utxo

该Tx如果保存后,会产生的新的Utxo包括ReqUtxo

func (*Transaction) GetNewUtxos

func (tx *Transaction) GetNewUtxos() map[OutPoint]*Utxo

该Tx如果保存后,会产生的新的Utxo

func (*Transaction) GetPrecusorTxs added in v1.0.6

func (tx *Transaction) GetPrecusorTxs(poolTxs map[common.Hash]*Transaction) []*Transaction

func (*Transaction) GetRequestMsgCount added in v1.0.8

func (tx *Transaction) GetRequestMsgCount() int

判断一个交易的请求部分有多少个Message,如果不是一个请求,则返回全部Message数量

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) GetResultSignaturePayload added in v1.0.8

func (tx *Transaction) GetResultSignaturePayload() (*SignaturePayload, int)

获得一个交易中执行结果的签名Payload和所在的MessageIndex,如果没有执行结果,则返回nil

func (*Transaction) GetSignatureAddr added in v1.0.8

func (tx *Transaction) GetSignatureAddr() (common.Address, error)

根据Tx中的第一个SignaturePayload,计算签名者地址

func (*Transaction) GetSpendOutpoints added in v1.0.1

func (tx *Transaction) GetSpendOutpoints() []*OutPoint

获取一个交易中花费了哪些OutPoint

func (*Transaction) GetToAddrs added in v1.0.7

func (tx *Transaction) GetToAddrs(getAddrFunc GetAddressFromScriptFunc) ([]common.Address, error)

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) IsOnlyContractRequest added in v1.0.7

func (tx *Transaction) IsOnlyContractRequest() bool

判断一个交易是否是一个合约请求交易,并且还没有被执行

func (*Transaction) IsSystemContract

func (tx *Transaction) IsSystemContract() bool

是否是系统合约调用,只有在具有InvokeRequest或者TemplateRequest的时候才算系统合约

func (*Transaction) IsUserContract added in v1.0.7

func (tx *Transaction) IsUserContract() bool

是否是一个用户合约的交易

func (*Transaction) MarshalJSON

func (tx *Transaction) MarshalJSON() ([]byte, error)

func (*Transaction) Messages

func (tx *Transaction) Messages() []*Message

浅拷贝

func (*Transaction) ModifiedMsg added in v1.0.5

func (tx *Transaction) ModifiedMsg(index int, msg *Message)

func (*Transaction) NeedRequestSignature added in v1.0.8

func (tx *Transaction) NeedRequestSignature() bool

判断一个Tx是否有请求的SignaturePayload

func (*Transaction) Nonce added in v1.0.8

func (tx *Transaction) Nonce() uint64

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) SetNonce added in v1.0.8

func (tx *Transaction) SetNonce(nonce uint64)

func (*Transaction) SetVersion added in v1.0.8

func (tx *Transaction) SetVersion(v uint32)

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) String added in v1.0.6

func (tx *Transaction) String() string

func (*Transaction) TxMessages

func (tx *Transaction) TxMessages() []*Message

深拷贝

func (*Transaction) UnmarshalJSON

func (tx *Transaction) UnmarshalJSON(data []byte) error

func (*Transaction) Version added in v1.0.8

func (tx *Transaction) Version() uint32

type TransactionWithUnitInfo

type TransactionWithUnitInfo struct {
	*Transaction
	UnitHash  common.Hash
	UnitIndex uint64
	Timestamp uint64
	TxIndex   uint64
}

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) Len

func (s Transactions) Len() int

Len returns the length of s.

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 TxLookupEntry struct {
	UnitHash  common.Hash `json:"unit_hash"`
	UnitIndex uint64      `json:"unit_index"`
	Index     uint64      `json:"index"`
	Timestamp uint64      `json:"timestamp"`
}

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 TxPackInfo added in v1.0.6

type TxPackInfo struct {
	TxHash      common.Hash
	RequestHash common.Hash
	UnitHash    common.Hash
	UnitIndex   uint64
	Timestamp   uint64
	TxIndex     uint64
	Error       string
}

type TxPreEvent

type TxPreEvent struct {
	Tx       *Transaction
	IsOrphan bool
}

TxPreEvent is posted when a transaction enters the transaction pool.

type TxStatus added in v1.0.6

type TxStatus byte

一个交易的状态

const (
	TxStatus_NotFound TxStatus = iota //找不到该交易
	TxStatus_InPool                   //未打包
	TxStatus_Unstable                 //已打包未稳定
	TxStatus_Stable                   //已打包,已稳定
)

func (TxStatus) String added in v1.0.6

func (s TxStatus) String() string

type UniqueId

type UniqueId [ID_LENGTH]byte

func String2UniqueId

func String2UniqueId(str string, t UniqueIdType) (UniqueId, error)

func ZeroUniqueId added in v1.0.2

func ZeroUniqueId() UniqueId

func (*UniqueId) Bytes

func (it *UniqueId) Bytes() []byte

func (*UniqueId) SetBytes

func (it *UniqueId) SetBytes(b []byte)

func (*UniqueId) String

func (it *UniqueId) String() string

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

func NewUnitWithHeader(header *Header) *Unit

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) Author

func (unit *Unit) Author() common.Address

func (*Unit) ContainsParent

func (u *Unit) ContainsParent(pHash common.Hash) bool

func (*Unit) CopyBody

func (u *Unit) CopyBody(txs Transactions) Transactions

func (*Unit) DecodeRLP

func (input *Unit) DecodeRLP(s *rlp.Stream) error

func (*Unit) DisplayId added in v1.0.4

func (u *Unit) DisplayId() string

func (*Unit) EncodeRLP

func (input *Unit) EncodeRLP(w io.Writer) error

func (*Unit) GetAssetId

func (unit *Unit) GetAssetId() AssetId

func (*Unit) GetGroupPubKey added in v1.0.1

func (unit *Unit) GetGroupPubKey() (kyber.Point, error)

func (*Unit) GetGroupPubKeyByte added in v1.0.1

func (unit *Unit) GetGroupPubKeyByte() []byte

func (*Unit) GetGroupPubkey added in v1.0.5

func (u *Unit) GetGroupPubkey() []byte

func (*Unit) GetGroupSign added in v1.0.1

func (u *Unit) GetGroupSign() []byte

func (*Unit) Hash

func (u *Unit) Hash() common.Hash

function Hash, return the unit's hash.

func (*Unit) Header

func (u *Unit) Header() *Header

************************* Unit Members ****************************

func (*Unit) IsEmpty

func (unit *Unit) IsEmpty() bool

func (*Unit) Number

func (u *Unit) Number() *ChainIndex

func (*Unit) NumberString added in v1.0.6

func (u *Unit) NumberString() string

func (*Unit) NumberU64

func (u *Unit) NumberU64() uint64

func (*Unit) ParentHash

func (u *Unit) ParentHash() []common.Hash

return unit's parents UnitHash

func (*Unit) Size

func (u *Unit) Size() common.StorageSize

function Size, return the unit's StorageSize.

func (*Unit) String4Log

func (unit *Unit) String4Log() string

func (*Unit) Timestamp

func (u *Unit) Timestamp() int64

func (*Unit) Transaction

func (u *Unit) Transaction(hash common.Hash) *Transaction

return transaction

func (*Unit) Transactions

func (u *Unit) Transactions() []*Transaction

transactions

func (*Unit) TransactionsWithoutCoinbase added in v1.0.7

func (u *Unit) TransactionsWithoutCoinbase() []*Transaction

除了Coinbase以外的其他所有普通交易

func (*Unit) TxHashes added in v1.0.7

func (u *Unit) TxHashes() []common.Hash

func (*Unit) WithBody

func (b *Unit) WithBody(transactions []*Transaction) *Unit

WithBody returns a new block with the given transaction and uncle contents.

type UnitNonce

type UnitNonce [8]byte

type UnitProperty

type UnitProperty struct {
	Hash       common.Hash `json:"hash"`        // 最近的单元hash
	ChainIndex *ChainIndex `json:"chain_Index"` // 最近的单元编号(数量)
	Timestamp  uint32      `json:"timestamp"`   // 最近的单元时间
}

type Units

type Units []*Unit

wangjiyou add for ptn/fetcher.go

func (Units) Len

func (s Units) Len() int

func (Units) Less

func (s Units) Less(i, j int) bool

func (Units) Swap

func (s Units) Swap(i, j int)

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 NewUtxo

func NewUtxo(output *Output, lockTime uint32, timestamp int64) *Utxo

func (*Utxo) Bytes

func (u *Utxo) Bytes() []byte

func (*Utxo) Clone

func (utxo *Utxo) Clone() *Utxo

func (*Utxo) Flag2Str

func (utxo *Utxo) Flag2Str() string

func (*Utxo) GetCoinDays

func (utxo *Utxo) GetCoinDays() uint64

func (*Utxo) GetTimestamp

func (u *Utxo) GetTimestamp() int64

func (*Utxo) IsCoinBase

func (utxo *Utxo) IsCoinBase() bool

func (*Utxo) IsEmpty

func (utxo *Utxo) IsEmpty() bool

func (*Utxo) IsModified

func (utxo *Utxo) IsModified() bool

func (*Utxo) IsSpent

func (utxo *Utxo) IsSpent() bool

func (*Utxo) SetCoinBase

func (utxo *Utxo) SetCoinBase()

func (*Utxo) Spend

func (utxo *Utxo) Spend()

func (*Utxo) StrPkScript

func (utxo *Utxo) StrPkScript() string

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 *UtxoIndex) AccountKey() []byte

func (*UtxoIndex) AssetKey

func (utxoIndex *UtxoIndex) AssetKey() []byte

func (*UtxoIndex) QueryFields

func (utxoIndex *UtxoIndex) QueryFields(key []byte) error

func (*UtxoIndex) ToKey

func (utxoIndex *UtxoIndex) ToKey() []byte

type UtxoIndexValue

type UtxoIndexValue struct {
	Amount   uint64 `json:"amount"`
	LockTime uint32 `json:"lock_time"`
}

type UtxoWithOutPoint

type UtxoWithOutPoint struct {
	*Utxo
	OutPoint
}

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

func (*WriteCounter) Write

func (c *WriteCounter) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL