modules

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2019 License: GPL-3.0, GPL-3.0 Imports: 34 Imported by: 2

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

View Source
const (
	UNIT_CREATION_DATE_INITIAL_UINT64  = 1536451200
	UNIT_CREATION_DATE_INITIAL_FORMATE = "2018-09-09 00:00:00"
)
View Source
const (
	ApplyMediator           = "ApplyBecomeMediator"
	IsApproved              = "IsInAgressList"
	MediatorPayDeposit      = "MediatorPayToDepositContract"
	MediatorList            = "MediatorList"
	GetMediatorDeposit      = "GetMediatorDeposit"
	MediatorWithdrawDeposit = "MediatorApplyCashback"
	MediatorApplyQuitList   = "MediatorApplyQuit"
)
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
)

type Hash []byte

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)
	TX_BASESIZE = (100 * 1024) //100kb
)
View Source
var DAO uint64 = 100000000
View Source
var DepositContractLockScript = common.Hex2Bytes("140000000000000000000000000000000000000001c8")
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
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 FormatUUID(buf []byte) string

func HeaderEqual

func HeaderEqual(oldh, newh *Header) bool

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 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 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) 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) 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) 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) 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) 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"`
	//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) Bytes

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

Index 8Bytes + AssetID 16Bytes

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

type ContractDeployRequestPayload

type ContractDeployRequestPayload struct {
	TplId   []byte   `json:"tpl_name"`
	Args    [][]byte `json:"args"`
	Timeout uint32   `json:"timeout"`
}

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

用户钱包发起的合约调用申请

func (*ContractInstallRequestPayload) Equal

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

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

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

type ContractStopRequestPayload

type ContractStopRequestPayload struct {
	ContractId  []byte `json:"contract_id"`
	Txid        string `json:"transaction_id"`
	DeleteImage bool   `json:"delete_image"`
}

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"`
	Memory         uint16        `json:"memory"`
}

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

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 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 ErrUnit

type ErrUnit float64

func (ErrUnit) Error

func (e ErrUnit) Error() string

type FileInfo

type FileInfo struct {
	UnitHash    common.Hash `json:"unit_hash"`
	UintHeight  uint64      `json:"unit_index"`
	ParentsHash common.Hash `json:"parents_hash"`
	Txid        common.Hash `json:"txid"`
	Timestamp   uint64      `json:"timestamp"`
	MainData    string      `json:"main_data"`
	ExtraData   string      `json:"extra_data"`
}

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 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) 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 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 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 CopyHeader(h *Header) *Header

func NewHeader

func NewHeader(parents []common.Hash, used uint64, extra []byte) *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) DecodeRLP

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

func (*Header) EncodeRLP

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

func (*Header) GetAssetId

func (h *Header) GetAssetId() AssetId

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

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 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 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.

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 MediatorCreateOperation

type MediatorCreateOperation struct {
	*core.MediatorInfoBase
	*core.MediatorApplyInfo
}

func (*MediatorCreateOperation) FeePayer

func (mco *MediatorCreateOperation) FeePayer() common.Address

type MediatorInfo

func MediatorToInfo

func MediatorToInfo(md *core.Mediator) *MediatorInfo

func NewMediatorInfo

func NewMediatorInfo() *MediatorInfo

func (*MediatorInfo) InfoToMediator

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

type MediatorSchedule

type MediatorSchedule struct {
	CurrentShuffledMediators []common.Address
}

Mediator调度顺序结构体

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 (msg *Message) CompareMessages(inMsg *Message) bool

func (*Message) CopyMessages

func (msg *Message) CopyMessages(cpyMsg *Message) *Message

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 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) 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() []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 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

func (*PledgeList) Reduce

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

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

type PledgeStatus

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

type ProofOfExistence

type ProofOfExistence struct {
	MainData  []byte         `json:"main_data"`
	ExtraData []byte         `json:"extra_data"`
	Reference []byte         `json:"reference"`
	TxId      common.Hash    `json:"tx_id"`
	UnitHash  common.Hash    `json:"unit_hash"`
	Timestamp uint64         `json:"timestamp"`
	Creator   common.Address `json:"creator"`
}

type QueryUtxoFunc

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

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

func (*SequeueTxPoolTxs) All

func (seqTxs *SequeueTxPoolTxs) All() []*TxPoolTransaction

get all

func (*SequeueTxPoolTxs) Get

func (seqTxs *SequeueTxPoolTxs) Get() *TxPoolTransaction

get

func (*SequeueTxPoolTxs) Len

func (seqTxs *SequeueTxPoolTxs) Len() int

add

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) 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 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     time.Time
	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 {
	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) DecodeRLP

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

func (*Transaction) EncodeRLP

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

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

func (TxByPrice) Len

func (s TxByPrice) Len() int

func (*TxByPrice) Pop

func (s *TxByPrice) Pop() interface{}

func (*TxByPrice) Push

func (s *TxByPrice) Push(x interface{})

func (TxByPrice) Swap

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

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 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 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 TxPoolTxs

type TxPoolTxs []*TxPoolTransaction

type Transactions []*Transaction

type TxPreEvent

type TxPreEvent struct{ Tx *Transaction }

TxPreEvent is posted when a transaction enters the transaction pool.

type UniqueId

type UniqueId [ID_LENGTH]byte

func String2UniqueId

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

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

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

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

func (*Unit) GetAssetId

func (unit *Unit) GetAssetId() AssetId

func (*Unit) GroupPubKey

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

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 (u *Unit) NumberU64() uint64 { return u.Head.Number.Uint64() }

func (*Unit) NumberU64

func (u *Unit) NumberU64() uint64

func (*Unit) ParentHash

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

return unit's parents UnitHash

func (*Unit) SetGroupSign

func (u *Unit) SetGroupSign(sign []byte)

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) 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 // 最近的单元hash
	Index     *ChainIndex // 最近的单元编号(数量)
	Timestamp uint32      // 最近的单元时间
}

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

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