Documentation ¶
Overview ¶
* * This file is part of go-palletone. * go-palletone is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * go-palletone is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with go-palletone. If not, see <http://www.gnu.org/licenses/>. * / * * * @author PalletOne core developers <dev@pallet.one> * * @date 2018-2019 *
Index ¶
- type ChainTempDb
- type ContractSupportRepository
- func (c *ContractSupportRepository) GetAddr1TokenUtxos(addr common.Address, asset *modules.Asset) (map[modules.OutPoint]*modules.Utxo, error)
- func (c *ContractSupportRepository) GetAddrByOutPoint(outPoint *modules.OutPoint) (common.Address, error)
- func (c *ContractSupportRepository) GetAddrUtxos(addr common.Address) (map[modules.OutPoint]*modules.Utxo, error)
- func (c *ContractSupportRepository) GetChainParameters() *core.ChainParameters
- func (c *ContractSupportRepository) GetContract(id []byte) (*modules.Contract, error)
- func (c *ContractSupportRepository) GetContractState(contractid []byte, field string) ([]byte, *modules.StateVersion, error)
- func (c *ContractSupportRepository) GetContractStatesById(contractid []byte) (map[string]*modules.ContractStateValue, error)
- func (c *ContractSupportRepository) GetContractStatesByPrefix(contractid []byte, prefix string) (map[string]*modules.ContractStateValue, error)
- func (c *ContractSupportRepository) GetContractTpl(tplId []byte) (*modules.ContractTemplate, error)
- func (c *ContractSupportRepository) GetContractTplCode(tplId []byte) ([]byte, error)
- func (c *ContractSupportRepository) GetContractsWithJuryAddr(addr common.Hash) []*modules.Contract
- func (c *ContractSupportRepository) GetDb() ptndb.Database
- func (c *ContractSupportRepository) GetGlobalProp() *modules.GlobalProperty
- func (c *ContractSupportRepository) GetHeaderByNumber(number *modules.ChainIndex) (*modules.Header, error)
- func (c *ContractSupportRepository) GetImmutableChainParameters() *core.ImmutableChainParameters
- func (c *ContractSupportRepository) GetNewestUnit(token modules.AssetId) (common.Hash, *modules.ChainIndex, error)
- func (c *ContractSupportRepository) GetStableTransactionOnly(hash common.Hash) (*modules.Transaction, error)
- func (c *ContractSupportRepository) GetStableUnit(hash common.Hash) (*modules.Unit, error)
- func (c *ContractSupportRepository) GetStableUnitByNumber(number *modules.ChainIndex) (*modules.Unit, error)
- func (c *ContractSupportRepository) GetUtxoEntry(outpoint *modules.OutPoint) (*modules.Utxo, error)
- func (c *ContractSupportRepository) NewTemp() (dboperation.IContractDag, error)
- func (c *ContractSupportRepository) SaveContract(contract *modules.Contract) error
- func (c *ContractSupportRepository) SaveTransaction(tx *modules.Transaction, txIndex int) error
- func (c *ContractSupportRepository) UnstableHeadUnitProperty(asset modules.AssetId) (*modules.UnitProperty, error)
- type IMemDag
- type MemDag
- func (chain *MemDag) AddStableUnit(unit *modules.Unit) error
- func (chain *MemDag) AddUnit(unit *modules.Unit, isGenerate bool) (common2.IUnitRepository, common2.IUtxoRepository, common2.IStateRepository, ...)
- func (pmg *MemDag) Close()
- func (chain *MemDag) GetChainUnits() map[common.Hash]*modules.Unit
- func (chain *MemDag) GetHeaderByHash(hash common.Hash) (*modules.Header, error)
- func (chain *MemDag) GetHeaderByNumber(number *modules.ChainIndex) (*modules.Header, error)
- func (chain *MemDag) GetLastMainChainUnit() *modules.Unit
- func (chain *MemDag) GetLastStableUnitHash() common.Hash
- func (chain *MemDag) GetLastStableUnitHeight() uint64
- func (chain *MemDag) GetLastStableUnitInfo() (common.Hash, uint64)
- func (chain *MemDag) GetUnstableRepositories() (common2.IUnitRepository, common2.IUtxoRepository, common2.IStateRepository, ...)
- func (chain *MemDag) Info() (*modules.MemdagStatus, error)
- func (chain *MemDag) SaveHeader(header *modules.Header) error
- func (pmg *MemDag) SetStableThreshold(count int)
- func (chain *MemDag) SetUnitGroupSign(uHash common.Hash, groupSign []byte) error
- func (pmg *MemDag) SubscribeRollbackUnitEvent(ch chan<- modules.RollbackUnitEvent) event.Subscription
- func (pmg *MemDag) SubscribeSaveStableUnitEvent(ch chan<- modules.SaveUnitEvent) event.Subscription
- func (pmg *MemDag) SubscribeSaveUnitEvent(ch chan<- modules.SaveUnitEvent) event.Subscription
- func (pmg *MemDag) SubscribeSwitchMainChainEvent(ob SwitchMainChainEventFunc)
- func (pmg *MemDag) SubscribeToGroupSignEvent(ch chan<- modules.ToGroupSignEvent) event.Subscription
- type SwitchMainChainEvent
- type SwitchMainChainEventFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainTempDb ¶ added in v1.0.1
type ChainTempDb struct { Tempdb *ptndb.Tempdb UnitRep comm2.IUnitRepository UtxoRep comm2.IUtxoRepository StateRep comm2.IStateRepository PropRep comm2.IPropRepository UnitProduceRep comm2.IUnitProduceRepository Validator validator.Validator Unit *modules.Unit }
func NewChainTempDb ¶ added in v1.0.1
func NewChainTempDb(db ptndb.Database, cache palletcache.ICache, tokenEngine tokenengine.ITokenEngine, saveHeaderOnly bool, builderFunc validator.ValidatorBuilderFunc, enableGasFee bool) (*ChainTempDb, error)
func (*ChainTempDb) AddUnit ¶ added in v1.0.1
func (chain_temp *ChainTempDb) AddUnit(unit *modules.Unit, saveHeaderOnly bool) (*ChainTempDb, error)
type ContractSupportRepository ¶ added in v1.0.6
type ContractSupportRepository struct {
// contains filtered or unexported fields
}
func NewContractSupportRepository ¶ added in v1.0.6
func NewContractSupportRepository(db ptndb.Database, enableGasFee bool) *ContractSupportRepository
func (*ContractSupportRepository) GetAddr1TokenUtxos ¶ added in v1.0.6
func (*ContractSupportRepository) GetAddrByOutPoint ¶ added in v1.0.6
func (*ContractSupportRepository) GetAddrUtxos ¶ added in v1.0.6
func (*ContractSupportRepository) GetChainParameters ¶ added in v1.0.6
func (c *ContractSupportRepository) GetChainParameters() *core.ChainParameters
func (*ContractSupportRepository) GetContract ¶ added in v1.0.6
func (c *ContractSupportRepository) GetContract(id []byte) (*modules.Contract, error)
func (*ContractSupportRepository) GetContractState ¶ added in v1.0.6
func (c *ContractSupportRepository) GetContractState(contractid []byte, field string) ([]byte, *modules.StateVersion, error)
func (*ContractSupportRepository) GetContractStatesById ¶ added in v1.0.6
func (c *ContractSupportRepository) GetContractStatesById(contractid []byte) (map[string]*modules.ContractStateValue, error)
func (*ContractSupportRepository) GetContractStatesByPrefix ¶ added in v1.0.6
func (c *ContractSupportRepository) GetContractStatesByPrefix(contractid []byte, prefix string) (map[string]*modules.ContractStateValue, error)
func (*ContractSupportRepository) GetContractTpl ¶ added in v1.0.6
func (c *ContractSupportRepository) GetContractTpl(tplId []byte) (*modules.ContractTemplate, error)
func (*ContractSupportRepository) GetContractTplCode ¶ added in v1.0.6
func (c *ContractSupportRepository) GetContractTplCode(tplId []byte) ([]byte, error)
func (*ContractSupportRepository) GetContractsWithJuryAddr ¶ added in v1.0.6
func (c *ContractSupportRepository) GetContractsWithJuryAddr(addr common.Hash) []*modules.Contract
func (*ContractSupportRepository) GetDb ¶ added in v1.0.6
func (c *ContractSupportRepository) GetDb() ptndb.Database
func (*ContractSupportRepository) GetGlobalProp ¶ added in v1.0.6
func (c *ContractSupportRepository) GetGlobalProp() *modules.GlobalProperty
func (*ContractSupportRepository) GetHeaderByNumber ¶ added in v1.0.6
func (c *ContractSupportRepository) GetHeaderByNumber(number *modules.ChainIndex) (*modules.Header, error)
func (*ContractSupportRepository) GetImmutableChainParameters ¶ added in v1.0.6
func (c *ContractSupportRepository) GetImmutableChainParameters() *core.ImmutableChainParameters
func (*ContractSupportRepository) GetNewestUnit ¶ added in v1.0.6
func (c *ContractSupportRepository) GetNewestUnit(token modules.AssetId) (common.Hash, *modules.ChainIndex, error)
func (*ContractSupportRepository) GetStableTransactionOnly ¶ added in v1.0.6
func (c *ContractSupportRepository) GetStableTransactionOnly(hash common.Hash) (*modules.Transaction, error)
func (*ContractSupportRepository) GetStableUnit ¶ added in v1.0.6
func (*ContractSupportRepository) GetStableUnitByNumber ¶ added in v1.0.6
func (c *ContractSupportRepository) GetStableUnitByNumber(number *modules.ChainIndex) (*modules.Unit, error)
func (*ContractSupportRepository) GetUtxoEntry ¶ added in v1.0.6
func (*ContractSupportRepository) NewTemp ¶ added in v1.0.6
func (c *ContractSupportRepository) NewTemp() (dboperation.IContractDag, error)
func (*ContractSupportRepository) SaveContract ¶ added in v1.0.6
func (c *ContractSupportRepository) SaveContract(contract *modules.Contract) error
func (*ContractSupportRepository) SaveTransaction ¶ added in v1.0.6
func (c *ContractSupportRepository) SaveTransaction(tx *modules.Transaction, txIndex int) error
func (*ContractSupportRepository) UnstableHeadUnitProperty ¶ added in v1.0.6
func (c *ContractSupportRepository) UnstableHeadUnitProperty(asset modules.AssetId) (*modules.UnitProperty, error)
type IMemDag ¶
type IMemDag interface { //增加一个稳定单元 AddStableUnit(unit *modules.Unit) error ////设置MemDag的稳定单元 //SetStableUnit(unit *modules.Unit, isGenesis bool) //增加一个单元到MemDag AddUnit(unit *modules.Unit, isProd bool) (common2.IUnitRepository, common2.IUtxoRepository, common2.IStateRepository, common2.IPropRepository, common2.IUnitProduceRepository, error) //保存Header SaveHeader(header *modules.Header) error //获取最新稳定单元的信息 GetLastStableUnitInfo() (common.Hash, uint64) //获取主链的最新单元 GetLastMainChainUnit() *modules.Unit //获取所有的不稳定单元 GetChainUnits() map[common.Hash]*modules.Unit //设置要形成稳定单元的阈值,一般是2/3*Count(Mediator) SetStableThreshold(threshold int) //获得不稳定的Repository GetUnstableRepositories() (common2.IUnitRepository, common2.IUtxoRepository, common2.IStateRepository, common2.IPropRepository, common2.IUnitProduceRepository) //设置一个单元的群签名,使得该单元稳定 SetUnitGroupSign(uHash common.Hash, groupSign []byte) error //通过Hash获得Header GetHeaderByHash(hash common.Hash) (*modules.Header, error) //通过高度获得Header GetHeaderByNumber(number *modules.ChainIndex) (*modules.Header, error) //获得MemDag的信息,包括分叉情况,孤儿块等 Info() (*modules.MemdagStatus, error) //订阅切换主链事件 SubscribeSwitchMainChainEvent(ob SwitchMainChainEventFunc) SubscribeToGroupSignEvent(ch chan<- modules.ToGroupSignEvent) event.Subscription SubscribeSaveStableUnitEvent(ch chan<- modules.SaveUnitEvent) event.Subscription SubscribeSaveUnitEvent(ch chan<- modules.SaveUnitEvent) event.Subscription SubscribeRollbackUnitEvent(ch chan<- modules.RollbackUnitEvent) event.Subscription //关闭 Close() }
不稳定单元和新单元的操作
type MemDag ¶
type MemDag struct {
// contains filtered or unexported fields
}
func NewMemDag ¶
func NewMemDag(token modules.AssetId, threshold int, saveHeaderOnly, enableGasFee bool, db ptndb.Database, stableUnitRep common2.IUnitRepository, propRep common2.IPropRepository, stableStateRep common2.IStateRepository, cache palletcache.ICache, tokenEngine tokenengine.ITokenEngine, builderFunc validator.ValidatorBuilderFunc) *MemDag
func (*MemDag) AddStableUnit ¶ added in v1.0.3
func (*MemDag) AddUnit ¶
func (chain *MemDag) AddUnit(unit *modules.Unit, isGenerate bool) (common2.IUnitRepository, common2.IUtxoRepository, common2.IStateRepository, common2.IPropRepository, common2.IUnitProduceRepository, error)
func (*MemDag) GetChainUnits ¶
查询所有不稳定单元(不包括孤儿单元)
func (*MemDag) GetHeaderByHash ¶
func (*MemDag) GetHeaderByNumber ¶
func (*MemDag) GetLastMainChainUnit ¶
func (*MemDag) GetLastStableUnitHash ¶ added in v1.0.5
func (*MemDag) GetLastStableUnitHeight ¶ added in v1.0.5
func (*MemDag) GetLastStableUnitInfo ¶ added in v1.0.1
func (*MemDag) GetUnstableRepositories ¶
func (chain *MemDag) GetUnstableRepositories() (common2.IUnitRepository, common2.IUtxoRepository, common2.IStateRepository, common2.IPropRepository, common2.IUnitProduceRepository)
func (*MemDag) SaveHeader ¶ added in v1.0.4
func (*MemDag) SetStableThreshold ¶
func (*MemDag) SetUnitGroupSign ¶
func (*MemDag) SubscribeRollbackUnitEvent ¶ added in v1.0.7
func (pmg *MemDag) SubscribeRollbackUnitEvent(ch chan<- modules.RollbackUnitEvent) event.Subscription
func (*MemDag) SubscribeSaveStableUnitEvent ¶ added in v1.0.6
func (pmg *MemDag) SubscribeSaveStableUnitEvent(ch chan<- modules.SaveUnitEvent) event.Subscription
func (*MemDag) SubscribeSaveUnitEvent ¶ added in v1.0.7
func (pmg *MemDag) SubscribeSaveUnitEvent(ch chan<- modules.SaveUnitEvent) event.Subscription
func (*MemDag) SubscribeSwitchMainChainEvent ¶ added in v1.0.4
func (pmg *MemDag) SubscribeSwitchMainChainEvent(ob SwitchMainChainEventFunc)
func (*MemDag) SubscribeToGroupSignEvent ¶
func (pmg *MemDag) SubscribeToGroupSignEvent(ch chan<- modules.ToGroupSignEvent) event.Subscription
type SwitchMainChainEvent ¶ added in v1.0.4
type SwitchMainChainEventFunc ¶ added in v1.0.4
type SwitchMainChainEventFunc func(event *SwitchMainChainEvent)