govern_token

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GovCtx

type GovCtx struct {
	// 基础上下文
	xcontext.BaseCtx
	BcName   string
	Ledger   LedgerRely
	Contract contract.Manager
	// 增加真正的账本字段
	RealLedger *rledger.Ledger
}

func NewGovCtx

func NewGovCtx(bcName string, leg LedgerRely, contract contract.Manager) (*GovCtx, error)

type GovManager

type GovManager interface {
	GetGovTokenBalance(accountName string) (*pb.GovernTokenBalance, error)
	DetermineGovTokenIfInitialized() (bool, error)
}

func NewGovManager

func NewGovManager(ctx *GovCtx) (GovManager, error)

NewGovManager create instance of GovManager

type KernMethod

type KernMethod struct {
	BcName               string
	NewGovResourceAmount int64
	Predistribution      []xledger.Predistribution
}

func NewKernContractMethod

func NewKernContractMethod(bcName string, NewGovResourceAmount int64, Predistribution []xledger.Predistribution) *KernMethod

func (*KernMethod) AddTokens

func (t *KernMethod) AddTokens(ctx contract.KContext) (*contract.Response, error)

func (*KernMethod) CheckTokens

func (t *KernMethod) CheckTokens(ctx contract.KContext, amount *big.Int) error

func (*KernMethod) GetRatio

func (t *KernMethod) GetRatio(ctx contract.KContext) (map[string]int64, error)

获取分红比例

func (*KernMethod) GetRewardRatio

func (t *KernMethod) GetRewardRatio(ctx contract.KContext, name string) int64

获取分红比

func (*KernMethod) GetVoters

func (t *KernMethod) GetVoters(ctx contract.KContext, name string) (map[string]*big.Int, *big.Int, int64)

获取投票数

func (*KernMethod) InitGovernTokens

func (t *KernMethod) InitGovernTokens(ctx contract.KContext) (*contract.Response, error)

func (*KernMethod) LockGovernTokens

func (t *KernMethod) LockGovernTokens(ctx contract.KContext) (*contract.Response, error)

func (*KernMethod) QueryAccountGovernTokens

func (t *KernMethod) QueryAccountGovernTokens(ctx contract.KContext) (*contract.Response, error)

func (*KernMethod) SubTokens

func (t *KernMethod) SubTokens(ctx contract.KContext) (*contract.Response, error)

func (*KernMethod) TotalSupply

func (t *KernMethod) TotalSupply(ctx contract.KContext) (*contract.Response, error)

意义转变,不是纯粹的治理代币总量,而是网络中UTXO兑换为治理代币的数量

func (*KernMethod) TransferGovernTokens

func (t *KernMethod) TransferGovernTokens(ctx contract.KContext) (*contract.Response, error)

func (*KernMethod) UnLockGovernTokens

func (t *KernMethod) UnLockGovernTokens(ctx contract.KContext) (*contract.Response, error)

func (*KernMethod) UpdateCacheTable

func (t *KernMethod) UpdateCacheTable(ctx contract.KContext) error

type LedgerRely

type LedgerRely interface {
	// 从创世块获取创建合约账户消耗gas
	GetNewGovGas() (int64, error)
	// 从创世块获取创建合约账户消耗gas
	GetGenesisPreDistribution() ([]xledger.Predistribution, error)
	// 获取状态机最新确认快照
	GetTipXMSnapshotReader() (ledger.XMSnapshotReader, error)
	// 计算UTXO总量视为治理代币总量
	CalGovTokenTotal() (*big.Int, error)
}

type Manager

type Manager struct {
	Ctx *GovCtx
}

Manager manages all gov releated data, providing read/write interface

func (*Manager) AllTokens

func (mgr *Manager) AllTokens(ctx contract.KContext) (*contract.Response, error)

获取全网UTXO总量视为治理代币总量,这个方法只提供给提案proposal到截止投票高度时计算赞成票数比调用

func (*Manager) BonusObtain

func (mgr *Manager) BonusObtain(ctx contract.KContext) (*contract.Response, error)

取出分红 这两个方法理论上也是可以在manager初始化完成之后在meta那边注册的,在那边注册的话同样可以直接拿到账本数据

func (*Manager) BonusQuery

func (mgr *Manager) BonusQuery(ctx contract.KContext) (*contract.Response, error)

查询总计分红

func (*Manager) DetermineGovTokenIfInitialized

func (mgr *Manager) DetermineGovTokenIfInitialized() (bool, error)

DetermineGovTokenIfInitialized

func (*Manager) GetGovTokenBalance

func (mgr *Manager) GetGovTokenBalance(accountName string) (*pb.GovernTokenBalance, error)

GetGovTokenBalance get govern token balance of an account

func (*Manager) GetObjectBySnapshot

func (mgr *Manager) GetObjectBySnapshot(bucket string, object []byte) ([]byte, error)

func (*Manager) SyncCheckBonus

func (mgr *Manager) SyncCheckBonus(ctx contract.KContext, height int64) (*big.Int, error)

同步时校验分红可用余额专用

Jump to

Keyboard shortcuts

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