common

package
v0.0.0-...-84a2c7a 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: 28 Imported by: 0

Documentation

Overview

* @author PalletOne core developers <dev@pallet.one> * @date 2018

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeGenerateUnitReward

func ComputeGenerateUnitReward() uint64

* 计算Mediator的出块奖励 To compute mediator interest for packaging one unit

func GenGenesisConfigPayload

func GenGenesisConfigPayload(genesisConf *core.Genesis, asset *modules.Asset) (
	[]*modules.ContractInvokePayload, error)

* 为创世单元生成ConfigPayload To generate config payload for genesis unit

func GetUnitWithSig

func GetUnitWithSig(unit *modules.Unit, ks *keystore.KeyStore, signer common.Address) (*modules.Unit, error)

WithSignature, returns a new unit with the given signature. @author Albert·Gou

func NewGenesisUnit

func NewGenesisUnit(txs modules.Transactions, time int64, asset *modules.Asset, parentUnitHeight int64,
	parentUnitHash common.Hash) *modules.Unit

* 生成创世单元,需要传入创世单元的配置信息以及coinbase交易 generate genesis unit, need genesis unit configure fields and transactions list parentUnitHeight=-1,means don't have parent unit

Types

type AfterChainMaintenanceEventFunc

type AfterChainMaintenanceEventFunc func(event *modules.ChainMaintenanceEvent)

type AfterSysContractStateChangeEventFunc

type AfterSysContractStateChangeEventFunc func(event *modules.SysContractStateChangeEvent)
type Observer interface {
	//更新事件
	AfterSysContractStateChangeEvent(event *modules.SysContractStateChangeEvent)
}

type IPropRepository

type IPropRepository interface {
	StoreGlobalProp(gp *modules.GlobalProperty) error
	RetrieveGlobalProp() (*modules.GlobalProperty, error)
	StoreDynGlobalProp(dgp *modules.DynamicGlobalProperty) error
	RetrieveDynGlobalProp() (*modules.DynamicGlobalProperty, error)
	StoreMediatorSchl(ms *modules.MediatorSchedule) error
	RetrieveMediatorSchl() (*modules.MediatorSchedule, error)

	// SetLastStableUnit(hash common.Hash, index *modules.ChainIndex) error
	// GetLastStableUnit(token modules.AssetId) (common.Hash, *modules.ChainIndex, error)
	SetNewestUnit(header *modules.Header) error
	GetNewestUnit(token modules.AssetId) (common.Hash, *modules.ChainIndex, error)
	GetNewestUnitTimestamp(token modules.AssetId) (int64, error)
	GetHeadUnitProperty(asset modules.AssetId) (*modules.UnitProperty, error)

	GetScheduledMediator(slotNum uint32) common.Address
	UpdateMediatorSchedule() bool
	GetSlotTime(slotNum uint32) time.Time
	GetSlotAtTime(when time.Time) uint32

	GetChainThreshold() (int, error)
	GetChainParameters() *core.ChainParameters
}

type IStateRepository

type IStateRepository interface {
	GetContractState(id []byte, field string) ([]byte, *modules.StateVersion, error)
	GetContractStateByVersion(id []byte, field string, version *modules.StateVersion) ([]byte, error)

	SaveContract(contract *modules.Contract) error
	SaveContractState(id []byte, w *modules.ContractWriteSet, version *modules.StateVersion) error
	GetContractStatesById(id []byte) (map[string]*modules.ContractStateValue, error)
	GetContractStatesByPrefix(id []byte, prefix string) (map[string]*modules.ContractStateValue, error)

	GetContract(id []byte) (*modules.Contract, error)
	GetAllContracts() ([]*modules.Contract, error)
	GetContractsByTpl(tplId []byte) ([]*modules.Contract, error)
	GetContractTpl(tplId []byte) (*modules.ContractTemplate, error)
	GetContractTplCode(tplId []byte) ([]byte, error)
	GetContractDeploy(tempId, contractId []byte, name string) (*modules.ContractDeployPayload, error)

	GetAllAccountStates(address common.Address) (map[string]*modules.ContractStateValue, error)
	GetAccountState(address common.Address, statekey string) (*modules.ContractStateValue, error)
	GetAccountBalance(address common.Address) uint64
	LookupAccount() map[common.Address]*modules.AccountInfo

	GetPledgeList() (*modules.PledgeList, error)
	GetMediatorVotedResults() (map[string]uint64, error)
	GetAccountVotedMediators(addr common.Address) map[string]bool
	GetVotingForMediator(addStr string) (map[string]uint64, error)

	GetMediator(add common.Address) *core.Mediator
	RetrieveMediator(address common.Address) (*core.Mediator, error)
	UpdateMediatorInfoExpand(med *core.Mediator) error
	GetMediators() map[common.Address]bool
	LookupMediatorInfo() []*modules.MediatorInfo
	IsMediator(address common.Address) bool
	RetrieveMediatorInfo(address common.Address) (*modules.MediatorInfo, error)
	StoreMediatorInfo(add common.Address, mi *modules.MediatorInfo) error

	GetJuryCandidateList() (map[string]bool, error)
	IsJury(address common.Address) bool
	GetAllJuror() (map[string]*modules.JurorDeposit, error)
	//GetJurorByAddr(addr string) (*modules.JurorDeposit, error)
	GetJurorReward(jurorAdd common.Address) common.Address
	GetJurorByAddrHash(addrHash common.Hash) (*modules.JurorDeposit, error)
	GetContractDeveloperList() ([]common.Address, error)
	IsContractDeveloper(address common.Address) bool

	GetPartitionChains() ([]*modules.PartitionChain, error)
	GetMainChain() (*modules.MainChain, error)
	//获得一个合约的陪审团列表
	GetContractJury(contractId []byte) (*modules.ElectionNode, error)
	GetAllContractTpl() ([]*modules.ContractTemplate, error)
	GetDataVersion() (*modules.DataVersion, error)
	StoreDataVersion(dv *modules.DataVersion) error

	GetSysParamWithoutVote() (map[string]string, error)
	GetSysParamsWithVotes() (*modules.SysTokenIDInfo, error)
	SaveSysConfigContract(key string, val []byte, ver *modules.StateVersion) error
	GetBlacklistAddress() ([]common.Address, *modules.StateVersion, error)

	SaveContractWithJuryAddr(addr common.Hash, contract *modules.Contract) error
	GetContractsWithJuryAddr(addr common.Hash) []*modules.Contract
}

type IUnitProduceRepository

type IUnitProduceRepository interface {
	PushUnit(nextUnit *modules.Unit) error
	ApplyUnit(nextUnit *modules.Unit) error
	Close()
	SubscribeChainMaintenanceEvent(ob AfterChainMaintenanceEventFunc)
	SubscribeActiveMediatorsUpdatedEvent(ch chan<- modules.ActiveMediatorsUpdatedEvent) event.Subscription
	RefreshSysParameters()
}

type IUnitRepository

type IUnitRepository interface {
	GetGenesisUnit() (*modules.Unit, error)
	//GenesisHeight() modules.ChainIndex
	SaveUnit(unit *modules.Unit, isGenesis bool) error
	CreateUnit(mediatorReward common.Address, txpool txspool.ITxPool, when time.Time,
		propdb IPropRepository, getJurorRewardFunc modules.GetJurorRewardAddFunc) (*modules.Unit, error)
	IsGenesis(hash common.Hash) bool
	GetAddrTransactions(addr common.Address) ([]*modules.TransactionWithUnitInfo, error)
	GetHeaderByHash(hash common.Hash) (*modules.Header, error)
	GetHeaderList(hash common.Hash, parentCount int) ([]*modules.Header, error)
	SaveHeader(header *modules.Header) error
	SaveNewestHeader(header *modules.Header) error
	SaveHeaders(headers []*modules.Header) error
	GetHeaderByNumber(index *modules.ChainIndex) (*modules.Header, error)
	GetHeadersByAuthor(authorAddr common.Address, startHeight, count uint64) ([]*modules.Header, error)
	IsHeaderExist(uHash common.Hash) (bool, error)
	GetHashByNumber(number *modules.ChainIndex) (common.Hash, error)

	GetUnitTransactions(hash common.Hash) (modules.Transactions, error)
	GetUnit(hash common.Hash) (*modules.Unit, error)

	GetBody(unitHash common.Hash) ([]common.Hash, error)
	GetTransaction(hash common.Hash) (*modules.TransactionWithUnitInfo, error)
	GetTransactionOnly(hash common.Hash) (*modules.Transaction, error)
	IsTransactionExist(txHash common.Hash) (bool, error)
	GetTxLookupEntry(hash common.Hash) (*modules.TxLookupEntry, error)
	GetCommon(key []byte) ([]byte, error)
	GetCommonByPrefix(prefix []byte) map[string][]byte
	GetAllData() ([][]byte, [][]byte)
	//GetReqIdByTxHash(hash common.Hash) (common.Hash, error)
	GetTxHashByReqId(reqid common.Hash) (common.Hash, error)
	//GetAddrOutput(addr string) ([]modules.Output, error)
	GetTrieSyncProgress() (uint64, error)
	//GetHeadHeaderHash() (common.Hash, error)
	//GetHeadUnitHash() (common.Hash, error)
	//GetHeadFastUnitHash() (common.Hash, error)
	GetNumberWithUnitHash(hash common.Hash) (*modules.ChainIndex, error)
	//GetCanonicalHash(number uint64) (common.Hash, error)
	GetAssetTxHistory(asset *modules.Asset) ([]*modules.TransactionWithUnitInfo, error)

	//GetHeaderRlp(hash common.Hash, index uint64) rlp.RawValue
	GetFileInfo(filehash []byte) ([]*modules.FileInfo, error)

	GetTxFromAddress(tx *modules.Transaction) ([]common.Address, error)
	GetTxRequesterAddress(tx *modules.Transaction) (common.Address, error)
	//根据现有Tx数据,重新构建地址和Tx的关系索引
	RefreshAddrTxIndex() error
	GetAssetReference(asset []byte) ([]*modules.ProofOfExistence, error)
	QueryProofOfExistenceByReference(ref []byte) ([]*modules.ProofOfExistence, error)
	SubscribeSysContractStateChangeEvent(ob AfterSysContractStateChangeEventFunc)
	SaveCommon(key, val []byte) error
	RebuildAddrTxIndex() error

	CheckReadSetValid(contractId []byte, readSet []modules.ContractReadSet) bool
}

type IUtxoRepository

type IUtxoRepository interface {
	GetUtxoEntry(outpoint *modules.OutPoint) (*modules.Utxo, error)
	GetStxoEntry(outpoint *modules.OutPoint) (*modules.Stxo, error)
	GetAllUtxos() (map[modules.OutPoint]*modules.Utxo, error)
	GetAddrOutpoints(addr common.Address) ([]modules.OutPoint, error)
	GetAddrUtxos(addr common.Address, asset *modules.Asset) (map[modules.OutPoint]*modules.Utxo, error)
	GetUxto(txin modules.Input) *modules.Utxo
	UpdateUtxo(unitTime int64, txHash common.Hash, payment *modules.PaymentPayload, msgIndex uint32) error
	IsUtxoSpent(outpoint *modules.OutPoint) (bool, error)
	ComputeTxFee(tx *modules.Transaction) (*modules.AmountAsset, error)
	GetUxtoSetByInputs(txins []modules.Input) (map[modules.OutPoint]*modules.Utxo, uint64)
	//GetAccountTokens(addr common.Address) (map[string]*modules.AccountToken, error)
	//WalletBalance(addr common.Address, asset modules.Asset) uint64
	// ComputeAwards(txs []*txspool.TxPoolTransaction, dagdb storage.IDagDb) (*modules.Addition, error)
	// ComputeTxAward(tx *modules.Transaction, dagdb storage.IDagDb) (uint64, error)
	ClearUtxo() error
	ClearAddrUtxo(addr common.Address) error
	SaveUtxoView(view map[modules.OutPoint]*modules.Utxo) error
	SaveUtxoEntity(outpoint *modules.OutPoint, utxo *modules.Utxo) error
}

type PropRepository

type PropRepository struct {
	// contains filtered or unexported fields
}

func NewPropRepository

func NewPropRepository(db storage.IPropertyDb) *PropRepository

func NewPropRepository4Db

func NewPropRepository4Db(db ptndb.Database) *PropRepository

func (*PropRepository) GetChainParameters

func (pRep *PropRepository) GetChainParameters() *core.ChainParameters

func (*PropRepository) GetChainThreshold

func (pRep *PropRepository) GetChainThreshold() (int, error)

func (*PropRepository) GetHeadUnitProperty

func (pRep *PropRepository) GetHeadUnitProperty(asset modules.AssetId) (*modules.UnitProperty, error)

func (*PropRepository) GetNewestUnit

func (pRep *PropRepository) GetNewestUnit(token modules.AssetId) (common.Hash, *modules.ChainIndex, error)

func (*PropRepository) GetNewestUnitTimestamp

func (pRep *PropRepository) GetNewestUnitTimestamp(token modules.AssetId) (int64, error)

func (*PropRepository) GetScheduledMediator

func (pRep *PropRepository) GetScheduledMediator(slotNum uint32) common.Address

* @brief 获取指定的未来slotNum对应的调度mediator来生产见证单元. Get the mediator scheduled for uint verification in a slot.

slotNum总是对应于未来的时间。 slotNum always corresponds to a time in the future.

如果slotNum == 1,则返回下一个调度Mediator。 If slotNum == 1, return the next scheduled mediator.

如果slotNum == 2,则返回下下一个调度Mediator。 If slotNum == 2, return the next scheduled mediator after 1 uint gap.

func (*PropRepository) GetSlotAtTime

func (pRep *PropRepository) GetSlotAtTime(when time.Time) uint32

* 获取在给定时间或之前出现的最近一个slot。 Get the last slot which occurs AT or BEFORE the given time.

func (*PropRepository) GetSlotTime

func (pRep *PropRepository) GetSlotTime(slotNum uint32) time.Time

* @brief 获取给定的未来第slotNum个slot开始的时间。 Get the time at which the given slot occurs.

如果slotNum == 0,则返回time.Unix(0,0)。 If slotNum == 0, return time.Unix(0,0).

如果slotNum == N 且 N > 0,则返回大于UnitTime的第N个单元验证间隔的对齐时间 If slotNum == N for N > 0, return the Nth next unit-interval-aligned time greater than head_block_time().

func (*PropRepository) RetrieveDynGlobalProp

func (pRep *PropRepository) RetrieveDynGlobalProp() (*modules.DynamicGlobalProperty, error)

func (*PropRepository) RetrieveGlobalProp

func (pRep *PropRepository) RetrieveGlobalProp() (*modules.GlobalProperty, error)

func (*PropRepository) RetrieveMediatorSchl

func (pRep *PropRepository) RetrieveMediatorSchl() (*modules.MediatorSchedule, error)

func (*PropRepository) SetNewestUnit

func (pRep *PropRepository) SetNewestUnit(header *modules.Header) error

func (*PropRepository) StoreDynGlobalProp

func (pRep *PropRepository) StoreDynGlobalProp(dgp *modules.DynamicGlobalProperty) error

func (*PropRepository) StoreGlobalProp

func (pRep *PropRepository) StoreGlobalProp(gp *modules.GlobalProperty) error

func (*PropRepository) StoreMediatorSchl

func (pRep *PropRepository) StoreMediatorSchl(ms *modules.MediatorSchedule) error

func (*PropRepository) UpdateMediatorSchedule

func (pRep *PropRepository) UpdateMediatorSchedule() bool

洗牌算法,更新mediator的调度顺序

type StateRepository

type StateRepository struct {
	// contains filtered or unexported fields
}

func NewStateRepository

func NewStateRepository(statedb storage.IStateDb, dagdb storage.IDagDb) *StateRepository

func NewStateRepository4Db

func NewStateRepository4Db(db ptndb.Database) *StateRepository

func (*StateRepository) GetAccountBalance

func (rep *StateRepository) GetAccountBalance(address common.Address) uint64

func (*StateRepository) GetAccountState

func (rep *StateRepository) GetAccountState(address common.Address, statekey string) (*modules.ContractStateValue,
	error)

func (*StateRepository) GetAccountVotedMediators

func (rep *StateRepository) GetAccountVotedMediators(addr common.Address) map[string]bool

func (*StateRepository) GetAllAccountStates

func (rep *StateRepository) GetAllAccountStates(address common.Address) (map[string]*modules.ContractStateValue,
	error)

func (*StateRepository) GetAllContractTpl

func (rep *StateRepository) GetAllContractTpl() ([]*modules.ContractTemplate, error)

func (*StateRepository) GetAllContracts

func (rep *StateRepository) GetAllContracts() ([]*modules.Contract, error)

func (*StateRepository) GetAllJuror

func (rep *StateRepository) GetAllJuror() (map[string]*modules.JurorDeposit, error)

func (*StateRepository) GetBlacklistAddress

func (rep *StateRepository) GetBlacklistAddress() ([]common.Address, *modules.StateVersion, error)

func (*StateRepository) GetContract

func (rep *StateRepository) GetContract(id []byte) (*modules.Contract, error)

func (*StateRepository) GetContractDeploy

func (rep *StateRepository) GetContractDeploy(tempId, contractId []byte, name string) (*modules.ContractDeployPayload, error)

func (*StateRepository) GetContractDeveloperList

func (rep *StateRepository) GetContractDeveloperList() ([]common.Address, error)

func (*StateRepository) GetContractJury

func (rep *StateRepository) GetContractJury(contractId []byte) (*modules.ElectionNode, error)

获得一个合约的陪审团列表

func (*StateRepository) GetContractState

func (rep *StateRepository) GetContractState(id []byte, field string) ([]byte, *modules.StateVersion, error)

func (*StateRepository) GetContractStateByVersion

func (rep *StateRepository) GetContractStateByVersion(id []byte,
	field string, version *modules.StateVersion) ([]byte, error)

获取某个版本的值 先根据StateVersion查到对应的交易 然后交易的WriteSet找出来对应的key和value

func (*StateRepository) GetContractStatesById

func (rep *StateRepository) GetContractStatesById(id []byte) (map[string]*modules.ContractStateValue, error)

func (*StateRepository) GetContractStatesByPrefix

func (rep *StateRepository) GetContractStatesByPrefix(id []byte,
	prefix string) (map[string]*modules.ContractStateValue, error)

func (*StateRepository) GetContractTpl

func (rep *StateRepository) GetContractTpl(tplId []byte) (*modules.ContractTemplate, error)

func (*StateRepository) GetContractTplCode

func (rep *StateRepository) GetContractTplCode(tplId []byte) ([]byte, error)

func (*StateRepository) GetContractsByTpl

func (rep *StateRepository) GetContractsByTpl(tplId []byte) ([]*modules.Contract, error)

func (*StateRepository) GetContractsWithJuryAddr

func (rep *StateRepository) GetContractsWithJuryAddr(addr common.Hash) []*modules.Contract

func (*StateRepository) GetDataVersion

func (rep *StateRepository) GetDataVersion() (*modules.DataVersion, error)

func (*StateRepository) GetJurorByAddrHash

func (rep *StateRepository) GetJurorByAddrHash(hash common.Hash) (*modules.JurorDeposit, error)

func (*StateRepository) GetJurorReward

func (rep *StateRepository) GetJurorReward(jurorAdd common.Address) common.Address

func (*StateRepository) GetJuryCandidateList

func (rep *StateRepository) GetJuryCandidateList() (map[string]bool, error)

func (*StateRepository) GetMainChain

func (rep *StateRepository) GetMainChain() (*modules.MainChain, error)

func (*StateRepository) GetMediator

func (rep *StateRepository) GetMediator(add common.Address) *core.Mediator

func (*StateRepository) GetMediatorVotedResults

func (rep *StateRepository) GetMediatorVotedResults() (map[string]uint64, error)

func (*StateRepository) GetMediators

func (rep *StateRepository) GetMediators() map[common.Address]bool

func (*StateRepository) GetPartitionChains

func (rep *StateRepository) GetPartitionChains() ([]*modules.PartitionChain, error)

func (*StateRepository) GetPledgeDepositApplyList

func (rep *StateRepository) GetPledgeDepositApplyList() ([]*modules.AddressAmount, error)

获得新的用户的质押申请列表

func (*StateRepository) GetPledgeList

func (rep *StateRepository) GetPledgeList() (*modules.PledgeList, error)

func (*StateRepository) GetPledgeListWithNew

func (rep *StateRepository) GetPledgeListWithNew() (*modules.PledgeList, error)

根据用户的新质押和提币申请,以及质押列表计算

func (*StateRepository) GetPledgeWithdrawApplyList

func (rep *StateRepository) GetPledgeWithdrawApplyList() ([]*modules.AddressAmount, error)

func (*StateRepository) GetSysParamWithoutVote

func (rep *StateRepository) GetSysParamWithoutVote() (map[string]string, error)

func (*StateRepository) GetSysParamsWithVotes

func (rep *StateRepository) GetSysParamsWithVotes() (*modules.SysTokenIDInfo, error)

func (*StateRepository) GetVotingForMediator

func (rep *StateRepository) GetVotingForMediator(addStr string) (map[string]uint64, error)

func (*StateRepository) IsContractDeveloper

func (rep *StateRepository) IsContractDeveloper(address common.Address) bool

func (*StateRepository) IsJury

func (rep *StateRepository) IsJury(address common.Address) bool

func (*StateRepository) IsMediator

func (rep *StateRepository) IsMediator(address common.Address) bool

func (*StateRepository) LookupAccount

func (rep *StateRepository) LookupAccount() map[common.Address]*modules.AccountInfo

func (*StateRepository) LookupMediatorInfo

func (rep *StateRepository) LookupMediatorInfo() []*modules.MediatorInfo

func (*StateRepository) RetrieveMediator

func (rep *StateRepository) RetrieveMediator(address common.Address) (*core.Mediator, error)

func (*StateRepository) RetrieveMediatorInfo

func (rep *StateRepository) RetrieveMediatorInfo(address common.Address) (*modules.MediatorInfo, error)

func (*StateRepository) SaveContract

func (rep *StateRepository) SaveContract(contract *modules.Contract) error

func (*StateRepository) SaveContractState

func (rep *StateRepository) SaveContractState(contractId []byte, ws *modules.ContractWriteSet,
	version *modules.StateVersion) error

func (*StateRepository) SaveContractWithJuryAddr

func (rep *StateRepository) SaveContractWithJuryAddr(addr common.Hash, contract *modules.Contract) error

func (*StateRepository) SaveSysConfigContract

func (rep *StateRepository) SaveSysConfigContract(key string, val []byte, ver *modules.StateVersion) error

func (*StateRepository) StoreDataVersion

func (rep *StateRepository) StoreDataVersion(dv *modules.DataVersion) error

func (*StateRepository) StoreMediator

func (rep *StateRepository) StoreMediator(med *core.Mediator) error

func (*StateRepository) StoreMediatorInfo

func (rep *StateRepository) StoreMediatorInfo(add common.Address, mi *modules.MediatorInfo) error

func (*StateRepository) UpdateMediatorInfoExpand

func (rep *StateRepository) UpdateMediatorInfoExpand(med *core.Mediator) error

type UnitProduceRepository

type UnitProduceRepository struct {
	// contains filtered or unexported fields
}

func NewUnitProduceRepository

func NewUnitProduceRepository(unitRep IUnitRepository, propRep IPropRepository,
	stateRep IStateRepository) *UnitProduceRepository

func NewUnitProduceRepository4Db

func NewUnitProduceRepository4Db(db ptndb.Database,
	tokenEngine tokenengine.ITokenEngine) *UnitProduceRepository

func (*UnitProduceRepository) ApplyUnit

func (rep *UnitProduceRepository) ApplyUnit(nextUnit *modules.Unit) error

ApplyUnit, 运用下一个 unit 更新整个区块链状态

func (*UnitProduceRepository) Close

func (d *UnitProduceRepository) Close()

func (*UnitProduceRepository) GetDynGlobalProp

func (rep *UnitProduceRepository) GetDynGlobalProp() *modules.DynamicGlobalProperty

func (*UnitProduceRepository) GetGlobalProp

func (rep *UnitProduceRepository) GetGlobalProp() *modules.GlobalProperty

func (*UnitProduceRepository) GetMediator

func (rep *UnitProduceRepository) GetMediator(add common.Address) *core.Mediator

func (*UnitProduceRepository) GetMediatorSchl

func (rep *UnitProduceRepository) GetMediatorSchl() *modules.MediatorSchedule

func (*UnitProduceRepository) PushUnit

func (rep *UnitProduceRepository) PushUnit(newUnit *modules.Unit) error

*

  • Push unit "may fail" in which case every partial change is unwound. After
  • push unit is successful the block is appended to the chain database on disk. *
  • 推块“可能会失败”,在这种情况下,每个部分地更改都会撤销。 推块成功后,该块将附加到磁盘上的链数据库。
  • 推块必须连续,如果不连续的推块,会返回错误
  • @return true if we switched forks as a result of this push.

func (*UnitProduceRepository) RefreshSysParameters

func (dag *UnitProduceRepository) RefreshSysParameters()

func (*UnitProduceRepository) SubscribeActiveMediatorsUpdatedEvent

func (dag *UnitProduceRepository) SubscribeActiveMediatorsUpdatedEvent(
	ch chan<- modules.ActiveMediatorsUpdatedEvent) event.Subscription

func (*UnitProduceRepository) SubscribeChainMaintenanceEvent

func (rep *UnitProduceRepository) SubscribeChainMaintenanceEvent(ob AfterChainMaintenanceEventFunc)

func (*UnitProduceRepository) UpdateSysParams

func (dag *UnitProduceRepository) UpdateSysParams(version *modules.StateVersion) error

type UnitRepository

type UnitRepository struct {
	// contains filtered or unexported fields
}

func NewUnitRepository

func NewUnitRepository(dagdb storage.IDagDb, idxdb storage.IIndexDb,
	utxodb storage.IUtxoDb, statedb storage.IStateDb,
	propdb storage.IPropertyDb,
	engine tokenengine.ITokenEngine) *UnitRepository

func NewUnitRepository4Db

func NewUnitRepository4Db(db ptndb.Database, tokenEngine tokenengine.ITokenEngine) *UnitRepository

func (*UnitRepository) CheckReadSetValid

func (rep *UnitRepository) CheckReadSetValid(contractId []byte, readSet []modules.ContractReadSet) bool

func (*UnitRepository) ComputeGenerateUnitReward

func (rep *UnitRepository) ComputeGenerateUnitReward(mediatorReward common.Address, asset *modules.Asset) *modules.Addition

,Mediator奖励

func (*UnitRepository) ComputeTxFeesAllocate

func (rep *UnitRepository) ComputeTxFeesAllocate(mediatorReward common.Address, txs []*modules.Transaction,
	getJurorRewardFunc modules.GetJurorRewardAddFunc) ([]*modules.Addition, error)

func (*UnitRepository) CreateCoinbase

func (rep *UnitRepository) CreateCoinbase(ads []*modules.Addition, height uint64) (
	*modules.Transaction, uint64, error)

* 创建coinbase交易 To create coinbase transaction

func (*UnitRepository) CreateUnit

func (rep *UnitRepository) CreateUnit(mediatorReward common.Address, txpool txspool.ITxPool,
	when time.Time, propdb IPropRepository, getJurorRewardFunc modules.GetJurorRewardAddFunc) (*modules.Unit, error)

* 创建单元,但是未签名 create common unit @param mAddr is minner addr return: correct if error is nil, and otherwise is incorrect

func (*UnitRepository) GetAddrTransactions

func (rep *UnitRepository) GetAddrTransactions(address common.Address) ([]*modules.TransactionWithUnitInfo, error)

GetAddrTransactions containing from && to address

func (*UnitRepository) GetAllData

func (rep *UnitRepository) GetAllData() ([][]byte, [][]byte)

func (*UnitRepository) GetAssetReference

func (rep *UnitRepository) GetAssetReference(asset []byte) ([]*modules.ProofOfExistence, error)

func (*UnitRepository) GetAssetTxHistory

func (rep *UnitRepository) GetAssetTxHistory(asset *modules.Asset) ([]*modules.TransactionWithUnitInfo, error)

func (*UnitRepository) GetBody

func (rep *UnitRepository) GetBody(unitHash common.Hash) ([]common.Hash, error)

func (*UnitRepository) GetCommon

func (rep *UnitRepository) GetCommon(key []byte) ([]byte, error)

func (*UnitRepository) GetCommonByPrefix

func (rep *UnitRepository) GetCommonByPrefix(prefix []byte) map[string][]byte

func (*UnitRepository) GetFileInfo

func (rep *UnitRepository) GetFileInfo(filehash []byte) ([]*modules.FileInfo, error)

func (*UnitRepository) GetFileInfoByHash

func (rep *UnitRepository) GetFileInfoByHash(hashs []common.Hash) ([]*modules.FileInfo, error)

func (*UnitRepository) GetGenesisUnit

func (rep *UnitRepository) GetGenesisUnit() (*modules.Unit, error)

* 从leveldb中查询GenesisUnit信息 To get genesis unit info from leveldb

func (*UnitRepository) GetHashByNumber

func (rep *UnitRepository) GetHashByNumber(number *modules.ChainIndex) (common.Hash, error)

func (*UnitRepository) GetHeaderByHash

func (rep *UnitRepository) GetHeaderByHash(hash common.Hash) (*modules.Header, error)

func (*UnitRepository) GetHeaderByNumber

func (rep *UnitRepository) GetHeaderByNumber(index *modules.ChainIndex) (*modules.Header, error)

func (*UnitRepository) GetHeaderList

func (rep *UnitRepository) GetHeaderList(hash common.Hash, parentCount int) ([]*modules.Header, error)

func (*UnitRepository) GetHeadersByAuthor

func (rep *UnitRepository) GetHeadersByAuthor(authorAddr common.Address, startHeight, count uint64) ([]*modules.Header, error)

func (*UnitRepository) GetNumberWithUnitHash

func (rep *UnitRepository) GetNumberWithUnitHash(hash common.Hash) (*modules.ChainIndex, error)

func (*UnitRepository) GetTransaction

func (rep *UnitRepository) GetTransaction(hash common.Hash) (*modules.TransactionWithUnitInfo, error)

func (*UnitRepository) GetTransactionOnly

func (rep *UnitRepository) GetTransactionOnly(hash common.Hash) (*modules.Transaction, error)

func (*UnitRepository) GetTrieSyncProgress

func (rep *UnitRepository) GetTrieSyncProgress() (uint64, error)

func (*UnitRepository) GetTxFee

func (rep *UnitRepository) GetTxFee(pay *modules.Transaction) (*modules.AmountAsset, error)

func (*UnitRepository) GetTxFromAddress

func (rep *UnitRepository) GetTxFromAddress(tx *modules.Transaction) ([]common.Address, error)

func (*UnitRepository) GetTxHashByReqId

func (rep *UnitRepository) GetTxHashByReqId(reqid common.Hash) (common.Hash, error)

func (*UnitRepository) GetTxLookupEntry

func (rep *UnitRepository) GetTxLookupEntry(hash common.Hash) (*modules.TxLookupEntry, error)

func (*UnitRepository) GetTxRequesterAddress

func (rep *UnitRepository) GetTxRequesterAddress(tx *modules.Transaction) (common.Address, error)

Get who send this transaction

func (*UnitRepository) GetUnit

func (rep *UnitRepository) GetUnit(hash common.Hash) (*modules.Unit, error)

func (*UnitRepository) GetUnitTransactions

func (rep *UnitRepository) GetUnitTransactions(unitHash common.Hash) (modules.Transactions, error)

func (*UnitRepository) IsGenesis

func (unitRep *UnitRepository) IsGenesis(hash common.Hash) bool

func (*UnitRepository) IsHeaderExist

func (rep *UnitRepository) IsHeaderExist(uHash common.Hash) (bool, error)

func (*UnitRepository) IsTransactionExist

func (rep *UnitRepository) IsTransactionExist(txHash common.Hash) (bool, error)

func (*UnitRepository) QueryProofOfExistenceByReference

func (rep *UnitRepository) QueryProofOfExistenceByReference(ref []byte) ([]*modules.ProofOfExistence, error)

func (*UnitRepository) RebuildAddrTxIndex

func (rep *UnitRepository) RebuildAddrTxIndex() error

func (*UnitRepository) RefreshAddrTxIndex

func (rep *UnitRepository) RefreshAddrTxIndex() error

func (*UnitRepository) SaveCommon

func (rep *UnitRepository) SaveCommon(key, val []byte) error

func (*UnitRepository) SaveHeader

func (rep *UnitRepository) SaveHeader(header *modules.Header) error

func (*UnitRepository) SaveHeaders

func (rep *UnitRepository) SaveHeaders(headers []*modules.Header) error

func (*UnitRepository) SaveNewestHeader

func (rep *UnitRepository) SaveNewestHeader(header *modules.Header) error

func (*UnitRepository) SaveUnit

func (rep *UnitRepository) SaveUnit(unit *modules.Unit, isGenesis bool) error

* 保存单元数据,如果单元的结构基本相同 save genesis unit data

func (*UnitRepository) SubscribeSysContractStateChangeEvent

func (rep *UnitRepository) SubscribeSysContractStateChangeEvent(ob AfterSysContractStateChangeEventFunc)

type UtxoRepository

type UtxoRepository struct {
	// contains filtered or unexported fields
}

func NewUtxoRepository

func NewUtxoRepository(utxodb storage.IUtxoDb, idxdb storage.IIndexDb,
	statedb storage.IStateDb, propDb storage.IPropertyDb,
	tokenEngine tokenengine.ITokenEngine) *UtxoRepository

func NewUtxoRepository4Db

func NewUtxoRepository4Db(db ptndb.Database, tokenEngine tokenengine.ITokenEngine) *UtxoRepository

func (*UtxoRepository) ClearAddrUtxo

func (repository *UtxoRepository) ClearAddrUtxo(addr common.Address) error

func (*UtxoRepository) ClearUtxo

func (repository *UtxoRepository) ClearUtxo() error

func (*UtxoRepository) ComputeTxFee

func (repository *UtxoRepository) ComputeTxFee(tx *modules.Transaction) (*modules.AmountAsset, error)

计算一笔Tx中包含多少手续费

func (*UtxoRepository) GetAddrOutpoints

func (repository *UtxoRepository) GetAddrOutpoints(addr common.Address) ([]modules.OutPoint, error)

func (*UtxoRepository) GetAddrUtxos

func (repository *UtxoRepository) GetAddrUtxos(addr common.Address, asset *modules.Asset) (
	map[modules.OutPoint]*modules.Utxo, error)

func (*UtxoRepository) GetAllUtxos

func (repository *UtxoRepository) GetAllUtxos() (map[modules.OutPoint]*modules.Utxo, error)

func (*UtxoRepository) GetStxoEntry

func (repository *UtxoRepository) GetStxoEntry(outpoint *modules.OutPoint) (*modules.Stxo, error)

func (*UtxoRepository) GetUtxoByOutpoint

func (repository *UtxoRepository) GetUtxoByOutpoint(outpoint *modules.OutPoint) (*modules.Utxo, error)

GetUtosOutPoint

func (*UtxoRepository) GetUtxoEntry

func (repository *UtxoRepository) GetUtxoEntry(outpoint *modules.OutPoint) (*modules.Utxo, error)

func (*UtxoRepository) GetUxto

func (repository *UtxoRepository) GetUxto(txin modules.Input) *modules.Utxo

* 获取某个input对应的utxo信息 To get utxo struct according to it's input information

func (*UtxoRepository) GetUxtoSetByInputs

func (repository *UtxoRepository) GetUxtoSetByInputs(txins []modules.Input) (
	map[modules.OutPoint]*modules.Utxo, uint64)

* 根据payload中的inputs获得对应的UTXO map

func (*UtxoRepository) IsUtxoSpent

func (repository *UtxoRepository) IsUtxoSpent(outpoint *modules.OutPoint) (bool, error)

func (*UtxoRepository) SaveUtxoEntity

func (repository *UtxoRepository) SaveUtxoEntity(outpoint *modules.OutPoint, utxo *modules.Utxo) error

func (*UtxoRepository) SaveUtxoView

func (repository *UtxoRepository) SaveUtxoView(view map[modules.OutPoint]*modules.Utxo) error

func (*UtxoRepository) UpdateUtxo

func (repository *UtxoRepository) UpdateUtxo(unitTime int64, txHash common.Hash,
	payment *modules.PaymentPayload, msgIndex uint32) error

* 根据交易信息中的outputs创建UTXO, 根据交易信息中的inputs销毁UTXO To create utxo according to outpus in transaction, and destroy utxo according to inputs in transaction

Jump to

Keyboard shortcuts

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