Documentation ¶
Overview ¶
* @author PalletOne core developers <dev@pallet.one> * @date 2018
Index ¶
- func ComputeGenerateUnitReward() uint64
- func GenGenesisConfigPayload(genesisConf *core.Genesis, asset *modules.Asset) ([]*modules.ContractInvokePayload, error)
- func GetUnitWithSig(unit *modules.Unit, ks *keystore.KeyStore, signer common.Address) (*modules.Unit, error)
- func NewGenesisUnit(txs modules.Transactions, time int64, asset *modules.Asset, ...) (*modules.Unit, error)
- type AfterChainMaintenanceEventFunc
- type AfterSysContractStateChangeEventFunc
- type IPropRepository
- type IStateRepository
- type IUnitProduceRepository
- type IUnitRepository
- type IUtxoRepository
- type PropRepository
- func (pRep *PropRepository) GetChainParameters() *core.ChainParameters
- func (pRep *PropRepository) GetChainThreshold() (int, error)
- func (pRep *PropRepository) GetChaincode(contractId common.Address) (*list.CCInfo, error)
- func (pRep *PropRepository) GetNewestUnit(token modules.AssetId) (common.Hash, *modules.ChainIndex, error)
- func (pRep *PropRepository) GetNewestUnitTimestamp(token modules.AssetId) (int64, error)
- func (pRep *PropRepository) GetScheduledMediator(slotNum uint32) common.Address
- func (pRep *PropRepository) GetSlotAtTime(when time.Time) uint32
- func (pRep *PropRepository) GetSlotTime(slotNum uint32) time.Time
- func (pRep *PropRepository) RetrieveChaincodes() ([]*list.CCInfo, error)
- func (pRep *PropRepository) RetrieveDynGlobalProp() (*modules.DynamicGlobalProperty, error)
- func (pRep *PropRepository) RetrieveGlobalProp() (*modules.GlobalProperty, error)
- func (pRep *PropRepository) RetrieveMediatorSchl() (*modules.MediatorSchedule, error)
- func (pRep *PropRepository) SaveChaincode(contractId common.Address, cc *list.CCInfo) error
- func (pRep *PropRepository) SetNewestUnit(header *modules.Header) error
- func (pRep *PropRepository) StoreDynGlobalProp(dgp *modules.DynamicGlobalProperty) error
- func (pRep *PropRepository) StoreGlobalProp(gp *modules.GlobalProperty) error
- func (pRep *PropRepository) StoreMediatorSchl(ms *modules.MediatorSchedule) error
- func (pRep *PropRepository) UpdateMediatorSchedule() bool
- type StateRepository
- func (rep *StateRepository) GetAccountBalance(address common.Address) uint64
- func (rep *StateRepository) GetAccountState(address common.Address, statekey string) (*modules.ContractStateValue, error)
- func (rep *StateRepository) GetAccountVotedMediators(addr common.Address) map[string]bool
- func (rep *StateRepository) GetAllAccountStates(address common.Address) (map[string]*modules.ContractStateValue, error)
- func (rep *StateRepository) GetAllContractTpl() ([]*modules.ContractTemplate, error)
- func (rep *StateRepository) GetAllContracts() ([]*modules.Contract, error)
- func (rep *StateRepository) GetAllJuror() (map[string]*modules.JurorDeposit, error)
- func (rep *StateRepository) GetBlacklistAddress() ([]common.Address, *modules.StateVersion, error)
- func (rep *StateRepository) GetContract(id []byte) (*modules.Contract, error)
- func (rep *StateRepository) GetContractDeploy(tempId, contractId []byte, name string) (*modules.ContractDeployPayload, error)
- func (rep *StateRepository) GetContractDeveloperList() ([]common.Address, error)
- func (rep *StateRepository) GetContractJury(contractId []byte) (*modules.ElectionNode, error)
- func (rep *StateRepository) GetContractState(id []byte, field string) ([]byte, *modules.StateVersion, error)
- func (rep *StateRepository) GetContractStatesById(id []byte) (map[string]*modules.ContractStateValue, error)
- func (rep *StateRepository) GetContractStatesByPrefix(id []byte, prefix string) (map[string]*modules.ContractStateValue, error)
- func (rep *StateRepository) GetContractTpl(tplId []byte) (*modules.ContractTemplate, error)
- func (rep *StateRepository) GetContractTplCode(tplId []byte) ([]byte, error)
- func (rep *StateRepository) GetContractsByTpl(tplId []byte) ([]*modules.Contract, error)
- func (rep *StateRepository) GetDataVersion() (*modules.DataVersion, error)
- func (rep *StateRepository) GetJurorByAddr(addr string) (*modules.JurorDeposit, error)
- func (rep *StateRepository) GetJurorByAddrHash(hash common.Hash) (*modules.JurorDeposit, error)
- func (rep *StateRepository) GetJuryCandidateList() (map[string]bool, error)
- func (rep *StateRepository) GetMainChain() (*modules.MainChain, error)
- func (rep *StateRepository) GetMediator(add common.Address) *core.Mediator
- func (rep *StateRepository) GetMediatorVotedResults() (map[string]uint64, error)
- func (rep *StateRepository) GetMediators() map[common.Address]bool
- func (rep *StateRepository) GetPartitionChains() ([]*modules.PartitionChain, error)
- func (rep *StateRepository) GetPledgeDepositApplyList() ([]*modules.AddressAmount, error)
- func (rep *StateRepository) GetPledgeList() (*modules.PledgeList, error)
- func (rep *StateRepository) GetPledgeListWithNew() (*modules.PledgeList, error)
- func (rep *StateRepository) GetPledgeWithdrawApplyList() ([]*modules.AddressAmount, error)
- func (rep *StateRepository) GetSysParamWithoutVote() (map[string]string, error)
- func (rep *StateRepository) GetSysParamsWithVotes() (*modules.SysTokenIDInfo, error)
- func (rep *StateRepository) GetVotingForMediator(addStr string) (map[string]uint64, error)
- func (rep *StateRepository) IsContractDeveloper(address common.Address) bool
- func (rep *StateRepository) IsJury(address common.Address) bool
- func (rep *StateRepository) IsMediator(address common.Address) bool
- func (rep *StateRepository) LookupAccount() map[common.Address]*modules.AccountInfo
- func (rep *StateRepository) LookupMediatorInfo() []*modules.MediatorInfo
- func (rep *StateRepository) RetrieveMediator(address common.Address) (*core.Mediator, error)
- func (rep *StateRepository) RetrieveMediatorInfo(address common.Address) (*modules.MediatorInfo, error)
- func (rep *StateRepository) SaveContractState(contractId []byte, ws *modules.ContractWriteSet, version *modules.StateVersion) error
- func (rep *StateRepository) SaveSysConfigContract(key string, val []byte, ver *modules.StateVersion) error
- func (rep *StateRepository) StoreDataVersion(dv *modules.DataVersion) error
- func (rep *StateRepository) StoreMediator(med *core.Mediator) error
- func (rep *StateRepository) StoreMediatorInfo(add common.Address, mi *modules.MediatorInfo) error
- type UnitProduceRepository
- func (rep *UnitProduceRepository) ApplyUnit(nextUnit *modules.Unit) error
- func (d *UnitProduceRepository) Close()
- func (rep *UnitProduceRepository) GetDynGlobalProp() *modules.DynamicGlobalProperty
- func (rep *UnitProduceRepository) GetGlobalProp() *modules.GlobalProperty
- func (rep *UnitProduceRepository) GetMediator(add common.Address) *core.Mediator
- func (rep *UnitProduceRepository) GetMediatorSchl() *modules.MediatorSchedule
- func (dag *UnitProduceRepository) HeadUnitTime() int64
- func (rep *UnitProduceRepository) PushUnit(newUnit *modules.Unit) error
- func (dag *UnitProduceRepository) RefreshSysParameters()
- func (dag *UnitProduceRepository) SubscribeActiveMediatorsUpdatedEvent(ch chan<- modules.ActiveMediatorsUpdatedEvent) event.Subscription
- func (rep *UnitProduceRepository) SubscribeChainMaintenanceEvent(ob AfterChainMaintenanceEventFunc)
- func (dag *UnitProduceRepository) UpdateSysParams(version *modules.StateVersion) error
- type UnitRepository
- func (rep *UnitRepository) ComputeGenerateUnitReward(m common.Address, asset *modules.Asset) *modules.Addition
- func (rep *UnitRepository) ComputeTxFeesAllocate(m common.Address, txs []*modules.Transaction) ([]*modules.Addition, error)
- func (rep *UnitRepository) CreateCoinbase(ads []*modules.Addition, height uint64) (*modules.Transaction, uint64, error)
- func (rep *UnitRepository) CreateUnit(mAddr common.Address, txpool txspool.ITxPool, propdb IPropRepository, ...) (*modules.Unit, error)
- func (rep *UnitRepository) GetAddrTransactions(address common.Address) ([]*modules.TransactionWithUnitInfo, error)
- func (rep *UnitRepository) GetAssetReference(asset []byte) ([]*modules.ProofOfExistence, error)
- func (rep *UnitRepository) GetAssetTxHistory(asset *modules.Asset) ([]*modules.TransactionWithUnitInfo, error)
- func (rep *UnitRepository) GetBody(unitHash common.Hash) ([]common.Hash, error)
- func (rep *UnitRepository) GetCommon(key []byte) ([]byte, error)
- func (rep *UnitRepository) GetCommonByPrefix(prefix []byte) map[string][]byte
- func (rep *UnitRepository) GetCurrentChainIndex(assetId modules.AssetId) (*modules.ChainIndex, error)
- func (rep *UnitRepository) GetFileInfo(filehash []byte) ([]*modules.FileInfo, error)
- func (rep *UnitRepository) GetFileInfoByHash(hashs []common.Hash) ([]*modules.FileInfo, error)
- func (rep *UnitRepository) GetGenesisUnit() (*modules.Unit, error)
- func (rep *UnitRepository) GetHashByNumber(number *modules.ChainIndex) (common.Hash, error)
- func (rep *UnitRepository) GetHeaderByHash(hash common.Hash) (*modules.Header, error)
- func (rep *UnitRepository) GetHeaderByNumber(index *modules.ChainIndex) (*modules.Header, error)
- func (rep *UnitRepository) GetHeaderList(hash common.Hash, parentCount int) ([]*modules.Header, error)
- func (rep *UnitRepository) GetLastIrreversibleUnit(assetID modules.AssetId) (*modules.Unit, error)
- func (rep *UnitRepository) GetNumberWithUnitHash(hash common.Hash) (*modules.ChainIndex, error)
- func (rep *UnitRepository) GetTransaction(hash common.Hash) (*modules.TransactionWithUnitInfo, error)
- func (rep *UnitRepository) GetTransactionOnly(hash common.Hash) (*modules.Transaction, error)
- func (rep *UnitRepository) GetTrieSyncProgress() (uint64, error)
- func (rep *UnitRepository) GetTxFromAddress(tx *modules.Transaction) ([]common.Address, error)
- func (rep *UnitRepository) GetTxHashByReqId(reqid common.Hash) (common.Hash, error)
- func (rep *UnitRepository) GetTxLookupEntry(hash common.Hash) (*modules.TxLookupEntry, error)
- func (rep *UnitRepository) GetTxRequesterAddress(tx *modules.Transaction) (common.Address, error)
- func (rep *UnitRepository) GetUnit(hash common.Hash) (*modules.Unit, error)
- func (rep *UnitRepository) GetUnitTransactions(unitHash common.Hash) (modules.Transactions, error)
- func (unitRep *UnitRepository) IsGenesis(hash common.Hash) bool
- func (rep *UnitRepository) IsHeaderExist(uHash common.Hash) (bool, error)
- func (rep *UnitRepository) IsTransactionExist(txHash common.Hash) (bool, error)
- func (rep *UnitRepository) QueryProofOfExistenceByReference(ref []byte) ([]*modules.ProofOfExistence, error)
- func (rep *UnitRepository) RebuildAddrTxIndex() error
- func (rep *UnitRepository) RefreshAddrTxIndex() error
- func (rep *UnitRepository) SaveCommon(key, val []byte) error
- func (rep *UnitRepository) SaveHeader(header *modules.Header) error
- func (rep *UnitRepository) SaveHeaders(headers []*modules.Header) error
- func (rep *UnitRepository) SaveNewestHeader(header *modules.Header) error
- func (rep *UnitRepository) SaveUnit(unit *modules.Unit, isGenesis bool) error
- func (rep *UnitRepository) SubscribeSysContractStateChangeEvent(ob AfterSysContractStateChangeEventFunc)
- type UtxoRepository
- func (repository *UtxoRepository) ClearUtxo() error
- func (repository *UtxoRepository) ComputeTxFee(tx *modules.Transaction) (*modules.AmountAsset, error)
- func (repository *UtxoRepository) GetAddrOutpoints(addr common.Address) ([]modules.OutPoint, error)
- func (repository *UtxoRepository) GetAddrUtxos(addr common.Address, asset *modules.Asset) (map[modules.OutPoint]*modules.Utxo, error)
- func (repository *UtxoRepository) GetAllUtxos() (map[modules.OutPoint]*modules.Utxo, error)
- func (repository *UtxoRepository) GetStxoEntry(outpoint *modules.OutPoint) (*modules.Stxo, error)
- func (repository *UtxoRepository) GetUtxoByOutpoint(outpoint *modules.OutPoint) (*modules.Utxo, error)
- func (repository *UtxoRepository) GetUtxoEntry(outpoint *modules.OutPoint) (*modules.Utxo, error)
- func (repository *UtxoRepository) GetUxto(txin modules.Input) *modules.Utxo
- func (repository *UtxoRepository) GetUxtoSetByInputs(txins []modules.Input) (map[modules.OutPoint]*modules.Utxo, uint64)
- func (repository *UtxoRepository) IsUtxoSpent(outpoint *modules.OutPoint) (bool, error)
- func (repository *UtxoRepository) SaveUtxoEntity(outpoint *modules.OutPoint, utxo *modules.Utxo) error
- func (repository *UtxoRepository) SaveUtxoView(view map[modules.OutPoint]*modules.Utxo) error
- func (repository *UtxoRepository) UpdateUtxo(unitTime int64, txHash common.Hash, payment *modules.PaymentPayload, ...) error
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, error)
* 生成创世单元,需要传入创世单元的配置信息以及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) GetChainThreshold() (int, 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) GetScheduledMediator(slotNum uint32) common.Address UpdateMediatorSchedule() bool GetSlotTime(slotNum uint32) time.Time GetSlotAtTime(when time.Time) uint32 SaveChaincode(contractId common.Address, cc *list.CCInfo) error GetChaincode(contractId common.Address) (*list.CCInfo, error) RetrieveChaincodes() ([]*list.CCInfo, error) GetChainParameters() *core.ChainParameters }
type IStateRepository ¶
type IStateRepository interface { GetContractState(id []byte, field string) ([]byte, *modules.StateVersion, 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) StoreMediator(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) 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) }
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(mAddr common.Address, txpool txspool.ITxPool, propdb IPropRepository, t time.Time) (*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) 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 //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) //获得某个分区上的最新不可逆单元 GetLastIrreversibleUnit(assetID modules.AssetId) (*modules.Unit, 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 }
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 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) GetChaincode ¶ added in v1.0.3
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) RetrieveChaincodes ¶ added in v1.0.3
func (pRep *PropRepository) RetrieveChaincodes() ([]*list.CCInfo, error)
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) SaveChaincode ¶
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) *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) 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) GetDataVersion ¶
func (rep *StateRepository) GetDataVersion() (*modules.DataVersion, error)
func (*StateRepository) GetJurorByAddr ¶ added in v1.0.3
func (rep *StateRepository) GetJurorByAddr(addr string) (*modules.JurorDeposit, error)
func (*StateRepository) GetJurorByAddrHash ¶ added in v1.0.3
func (rep *StateRepository) GetJurorByAddrHash(hash common.Hash) (*modules.JurorDeposit, error)
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) 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 (*StateRepository) RetrieveMediatorInfo ¶
func (rep *StateRepository) RetrieveMediatorInfo(address common.Address) (*modules.MediatorInfo, error)
func (*StateRepository) SaveContractState ¶
func (rep *StateRepository) SaveContractState(contractId []byte, ws *modules.ContractWriteSet, version *modules.StateVersion) 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
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) HeadUnitTime ¶
func (dag *UnitProduceRepository) HeadUnitTime() int64
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) ComputeGenerateUnitReward ¶
func (rep *UnitRepository) ComputeGenerateUnitReward(m common.Address, asset *modules.Asset) *modules.Addition
,Mediator奖励
func (*UnitRepository) ComputeTxFeesAllocate ¶
func (rep *UnitRepository) ComputeTxFeesAllocate(m common.Address, txs []*modules.Transaction) ( []*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(mAddr common.Address, txpool txspool.ITxPool, propdb IPropRepository, t time.Time) (*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) 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) GetCommonByPrefix ¶
func (rep *UnitRepository) GetCommonByPrefix(prefix []byte) map[string][]byte
func (*UnitRepository) GetCurrentChainIndex ¶
func (rep *UnitRepository) GetCurrentChainIndex(assetId modules.AssetId) (*modules.ChainIndex, error)
func (*UnitRepository) GetFileInfo ¶
func (rep *UnitRepository) GetFileInfo(filehash []byte) ([]*modules.FileInfo, error)
func (*UnitRepository) GetFileInfoByHash ¶
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 (*UnitRepository) GetHeaderByNumber ¶
func (rep *UnitRepository) GetHeaderByNumber(index *modules.ChainIndex) (*modules.Header, error)
func (*UnitRepository) GetHeaderList ¶
func (*UnitRepository) GetLastIrreversibleUnit ¶
func (*UnitRepository) GetNumberWithUnitHash ¶
func (rep *UnitRepository) GetNumberWithUnitHash(hash common.Hash) (*modules.ChainIndex, error)
func (rep *UnitRepository) GetHeadHeaderHash() (common.Hash, error) { return rep.dagdb.GetHeadHeaderHash() }
func (rep *UnitRepository) GetHeadUnitHash() (common.Hash, error) { return rep.dagdb.GetHeadUnitHash() }
func (rep *UnitRepository) GetHeadFastUnitHash() (common.Hash, error) { return rep.dagdb.GetHeadFastUnitHash() }
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 (rep *UnitRepository) GetAddrOutput(addr string) ([]modules.Output, error) { return rep.dagdb.GetAddrOutput(addr) }
func (*UnitRepository) GetTxFromAddress ¶
func (rep *UnitRepository) GetTxFromAddress(tx *modules.Transaction) ([]common.Address, error)
func (*UnitRepository) GetTxHashByReqId ¶
func (rep *UnitRepository) GetReqIdByTxHash(hash common.Hash) (common.Hash, error) { return rep.dagdb.GetReqIdByTxHash(hash) }
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) GetUnitTransactions ¶
func (rep *UnitRepository) GetUnitTransactions(unitHash common.Hash) (modules.Transactions, error)
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 (*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) ClearUtxo ¶
func (repository *UtxoRepository) ClearUtxo() error
func (*UtxoRepository) ComputeTxFee ¶
func (repository *UtxoRepository) ComputeTxFee(tx *modules.Transaction) (*modules.AmountAsset, error)
计算一笔Tx中包含多少手续费
func (*UtxoRepository) GetAddrOutpoints ¶
func (*UtxoRepository) GetAddrUtxos ¶
func (*UtxoRepository) GetAllUtxos ¶
func (*UtxoRepository) GetStxoEntry ¶ added in v1.0.1
func (*UtxoRepository) GetUtxoByOutpoint ¶
func (repository *UtxoRepository) GetUtxoByOutpoint(outpoint *modules.OutPoint) (*modules.Utxo, error)
GetUtosOutPoint
func (*UtxoRepository) GetUtxoEntry ¶
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) SaveUtxoEntity ¶
func (*UtxoRepository) SaveUtxoView ¶
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