common

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

type ILocalRepository interface {
	SaveLocalTx(tx *modules.Transaction) error
	GetLocalTx(txId common.Hash) (*modules.Transaction, modules.TxStatus, error)
	SaveLocalTxStatus(txId common.Hash, status modules.TxStatus) error
}

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
	LookupMediatorBaseInfo() []*modules.MediatorInfo
	LookupMediatorInfo() []*modules.MediatorInfo2
	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 {
	GetDb() ptndb.Database
	GetGenesisUnit() (*modules.Unit, error)
	//GenesisHeight() modules.ChainIndex
	SaveUnit(unit *modules.Unit, isGenesis bool) error
	SaveTransaction(tx *modules.Transaction, txIndex int) error
	CreateUnit(mediatorReward common.Address, txs []*modules.Transaction, when time.Time,
		propdb IPropRepository, getJurorRewardFunc modules.GetJurorRewardAddFunc, enableGasFee bool) (*modules.Unit, error)
	IsGenesis(hash common.Hash) bool
	GetAddrTransactions(addr common.Address) ([]*modules.TransactionWithUnitInfo, error)
	GetAddrUtxoTxs(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
	InitNewestHeader(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)
	GetAddressCount() int
	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.ProofOfExistencesInfo, error)
	GetProofOfExistencesByMaindata(maindata []byte) ([]*modules.ProofOfExistencesInfo, 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)
	GetTxOutput(outpoint *modules.OutPoint) (*modules.Utxo, 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)
	GetAddrUtxoAndReqMapping(addr common.Address, asset *modules.Asset) (map[modules.OutPoint]*modules.Utxo, map[common.Hash]common.Hash, error)
	GetUxto(txin modules.Input) *modules.Utxo
	UpdateUtxo(unitTime int64, txHash, reqHash 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
	ComputeTxFee(tx *modules.Transaction) (*modules.AmountAsset, error)
}

type LocalRepository added in v1.0.6

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

func NewLocalRepository added in v1.0.6

func NewLocalRepository(localdb storage.ILocalDb) *LocalRepository

func (*LocalRepository) GetLocalTx added in v1.0.6

func (rep *LocalRepository) GetLocalTx(txId common.Hash) (*modules.Transaction, modules.TxStatus, error)

查询某交易的内容和状态

func (*LocalRepository) SaveLocalTx added in v1.0.6

func (rep *LocalRepository) SaveLocalTx(tx *modules.Transaction) error

通过本地RPC创建或广播的交易

func (*LocalRepository) SaveLocalTxStatus added in v1.0.6

func (rep *LocalRepository) SaveLocalTxStatus(txId common.Hash, status modules.TxStatus) 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 added in v1.0.5

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

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

func (*StateRepository) GetBlacklistAddress added in v1.0.3

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

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

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

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

func (*StateRepository) GetDataVersion

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

func (*StateRepository) GetJurorByAddrHash added in v1.0.3

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

func (*StateRepository) GetJurorReward added in v1.0.4

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

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

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

func (*StateRepository) IsContractDeveloper added in v1.0.1

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

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

func (*StateRepository) LookupMediatorInfo

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

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

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

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

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, enableGasFee bool) *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,
	txutxodb storage.IUtxoDb, requtxodb storage.IUtxoDb, statedb storage.IStateDb,
	propdb storage.IPropertyDb,
	engine tokenengine.ITokenEngine, enableGasFee bool) *UnitRepository

func NewUnitRepository4Db

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

func (*UnitRepository) CheckReadSetValid added in v1.0.5

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, txs2 []*modules.Transaction,
	when time.Time, propdb IPropRepository, getJurorRewardFunc modules.GetJurorRewardAddFunc, enableGasFee bool) (*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) GetAddrUtxoTxs added in v1.0.6

func (rep *UnitRepository) GetAddrUtxoTxs(addr common.Address) ([]*modules.TransactionWithUnitInfo, error)

func (*UnitRepository) GetAddressCount added in v1.0.6

func (rep *UnitRepository) GetAddressCount() int

func (*UnitRepository) GetAllData added in v1.0.4

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

func (*UnitRepository) GetAssetReference added in v1.0.1

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

func (rep *UnitRepository) GetDb() ptndb.Database

func (*UnitRepository) GetFileInfo

func (rep *UnitRepository) GetFileInfo(filehash []byte) ([]*modules.ProofOfExistencesInfo, 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 added in v1.0.4

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

func (rep *UnitRepository) GetProofOfExistencesByMaindata(maindata []byte) ([]*modules.ProofOfExistencesInfo, 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) 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) 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) InitNewestHeader added in v1.0.7

func (rep *UnitRepository) InitNewestHeader(header *modules.Header) 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 added in v1.0.3

func (rep *UnitRepository) RebuildAddrTxIndex() error

func (*UnitRepository) RefreshAddrTxIndex

func (rep *UnitRepository) RefreshAddrTxIndex() error
func (rep *UnitRepository) GetTxFromAddress(tx *modules.Transaction) ([]common.Address, error) {
	rep.lock.RLock()
	defer rep.lock.RUnlock()
	return rep.getPayFromAddresses(tx), nil
}

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

func (rep *UnitRepository) SaveTransaction(tx *modules.Transaction, txIndex int) error

Mock一个Unit,然后保存Tx,主要用于内存模拟操作

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(txutxodb storage.IUtxoDb, requtxodb 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 added in v1.0.4

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

func (*UtxoRepository) ClearUtxo

func (repository *UtxoRepository) ClearUtxo() error
func (repository *UtxoRepository) SaveUtxoEntity(outpoint *modules.OutPoint, utxo *modules.Utxo) error {
	return repository.txUtxodb.SaveUtxoEntity(outpoint, utxo)
}

func (*UtxoRepository) ComputeTxFee

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

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

func (*UtxoRepository) DeleteUtxo added in v1.0.6

func (rep *UtxoRepository) DeleteUtxo(outpoint *modules.OutPoint, spentTxId common.Hash, spentTime uint64) error

当一个UTXO被使用后,先去TxUTXO进行删除,然后查找ReqUtxo,如果能查到,继续进行ReqUtxo的删除

func (*UtxoRepository) GetAddrOutpoints

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

func (*UtxoRepository) GetAddrUtxoAndReqMapping added in v1.0.6

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

返回一个地址的TxUtxo和该ReqHash对应的TxHash

func (*UtxoRepository) GetAddrUtxos

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

活动一个地址的所有UTXO,包括完整交易的和Request的,存证交叉,需要通过Mapping过滤

func (*UtxoRepository) GetAllUtxos

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

func (*UtxoRepository) GetStxoEntry added in v1.0.1

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

func (*UtxoRepository) GetTxOutput added in v1.0.6

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

获得消费的和未消费的交易输出

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

func (repository *UtxoRepository) IsUtxoSpent(outpoint *modules.OutPoint) (bool, 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, reqHash 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