role

package
v3.8.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

* file description: account role * @Author: may luo * @Date: 2017-12-12 * @Last Modified by: * @Last Modified time:

Index

Constants

View Source
const (
	//AccountObjectName is the table name of user account
	AccountObjectName string = "account"
	//MsignAccountObjectName is the table name of user multisign account
	MsignAccountObjectName string = "msignaccount"
)
View Source
const (
	// ChainStateName is definition of chain state name
	ChainStateName string = "chain_state"
	// ChainStateDefaultKey is definition of chain stake default key
	ChainStateDefaultKey string = "chain_state_defkey"
)
View Source
const (
	// CoreStateName is definition of core state name
	CoreStateName string = "core_state"
	// CoreStateDefaultKey is definition of core state default key
	CoreStateDefaultKey string = "core_state_defkey"
)
View Source
const (
	//VoterObjectName is the table name of voter object
	VoterObjectName    string = "voter"
	VoterObjectKeyName string = "owner"
)
View Source
const BalanceObjectName string = "balance"

BalanceObjectName is definition of object name of balance

View Source
const BlockHistoryObjectName string = "block_history"

BlockHistoryObjectName is definition of block history object name

View Source
const (
	//ContractObjectName is the table name of user contract
	ContractObjectName string = "contract"
)
View Source
const DelegateObjectIndexName string = "signing_key"

DelegateObjectIndexName is definition of delegate object index name

View Source
const DelegateObjectKeyName string = "account_name"

DelegateObjectKeyName is definition of delegate object key name

View Source
const DelegateObjectName string = "delegate"

DelegateObjectName is definition of delegate object name

View Source
const DelegateVotesObjectIndexFinishTime string = "term_finish_time"

DelegateVotesObjectIndexFinishTime is definition of delegate vote object index finish time

View Source
const DelegateVotesObjectIndexFinishTimeJSON string = "serve.term_finish_time"
View Source
const DelegateVotesObjectIndexVote string = "votes"

DelegateVotesObjectIndexVote is definition of delegate vote object index name

View Source
const DelegateVotesObjectIndexVoteJSON string = "serve.votes"
View Source
const DelegateVotesObjectKeyName string = "owner_account"

DelegateVotesObjectKeyName is definition of delegate vote object key name

View Source
const DelegateVotesObjectName string = "producervote"

DelegateVotesObjectName is definition of delegate vote object name

View Source
const (
	//KeyValueObjectName is the table name of keyvalue object
	KeyValueObjectName string = "keyvalue"
)
View Source
const ResourceLimitObjectName string = "resource_limit"

ResourceObjectName is definition of object name of balance

View Source
const ResourceUsageObjectName string = "resource_usage"

StakedBalanceObjectName is definition of object name of stake balance

View Source
const ScheduleDelegateObjectName string = "scheduledelegate"

ScheduleDelegateObjectName is scheduledelegate

View Source
const StakedBalanceObjectName string = "staked_balance"

StakedBalanceObjectName is definition of object name of stake balance

View Source
const TransactionExpirationObjectIndexExpiration string = "expiration"
View Source
const TransactionExpirationObjectKeyName string = "trx_hash"
View Source
const TransactionExpirationObjectName string = "transaction_expiration"
View Source
const TransferCreditObjectName string = "credit"

TransferCreditObjectName is credit name

View Source
const TransitVotesObjectIndexVote string = "transit_votes"

TransitVotesObjectIndexVote is definition of delegate vote object index name in transition period

View Source
const TransitVotesObjectIndexVoteJSON string = "transit_votes"
View Source
const TransitVotesObjectKeyName string = "producer_account"

TransitVotesObjectKeyName is definition of delegate vote object key name in transition period

View Source
const TransitVotesObjectName string = "transitvotes"

TransitVotesObjectName is definition of delegate vote object name in transition period

Variables

This section is empty.

Functions

func CreateAccountRole

func CreateAccountRole(ldb *db.DBService) error

CreateAccountRole is create account role

func CreateBalanceRole

func CreateBalanceRole(ldb *db.DBService) error

CreateBalanceRole is to create balance role

func CreateBlockHistoryRole

func CreateBlockHistoryRole(ldb *db.DBService) error

CreateBlockHistoryRole is to init block history

func CreateChainStateRole

func CreateChainStateRole(ldb *db.DBService) error

CreateChainStateRole is to save init chain state

func CreateContractRole

func CreateContractRole(ldb *db.DBService) error

CreateContractRole is create contract role

func CreateCoreStateRole

func CreateCoreStateRole(ldb *db.DBService) error

CreateCoreStateRole is to save init core state

func CreateDelegateRole

func CreateDelegateRole(ldb *db.DBService) error

CreateDelegateRole is to save initial delegate

func CreateDelegateVotesRole

func CreateDelegateVotesRole(ldb *db.DBService) error

CreateDelegateVotesRole is to save initial delegate votes

func CreateKeyValueRole

func CreateKeyValueRole(ldb *db.DBService) error

CreateKeyValueRole is create account role

func CreateMsignAccountRole

func CreateMsignAccountRole(ldb *db.DBService) error

CreateMsignAccountRole is create account role

func CreateResourceLimitRole

func CreateResourceLimitRole(ldb *db.DBService) error

CreateResourceLimitRole is to create resource limit role

func CreateScheduleDelegateRole

func CreateScheduleDelegateRole(ldb *db.DBService) error

func CreateStakedBalanceRole

func CreateStakedBalanceRole(ldb *db.DBService) error

CreateStakedBalanceRole is to create stake balance role

func CreateTransactionExpirationRole

func CreateTransactionExpirationRole(ldb *db.DBService) error

CreateTransactionExpirationRole is creating transaction expiration role

func CreateTransferCreditRole

func CreateTransferCreditRole(ldb *db.DBService) error

CreateTransferCreditRole is create transfer credits

func CreateTransitVotesRole

func CreateTransitVotesRole(ldb *db.DBService) error

CreateTransitVotesRole is to save initial delegate votes in transition period

func CreateVoterRole

func CreateVoterRole(ldb *db.DBService) error

CreateVoterRole is create voter role

func DeleteTransferCreditRole

func DeleteTransferCreditRole(ldb *db.DBService, name string, spender string) error

DeleteTransferCreditRole is deleting transfer credit role

func ElectNextTermDelegatesRole

func ElectNextTermDelegatesRole(ldb *db.DBService, writeState bool) []string

ElectNextTermDelegatesRole is to elect next term delegates

func FilterOutgoingDelegate

func FilterOutgoingDelegate(ldb *db.DBService) []string

FilterOutgoingDelegate is to filter outgoing delegate

func GetAllSortFinishTimeDelegates

func GetAllSortFinishTimeDelegates(ldb *db.DBService) ([]string, error)

GetAllSortFinishTimeDelegates is to get all sort finish time delegates

func GetAllSortVotesDelegates

func GetAllSortVotesDelegates(ldb *db.DBService) ([]string, error)

GetAllSortVotesDelegates is to get all sort votes delegates

func GetBinValue

func GetBinValue(ldb *db.DBService, contract string, object string, key string) ([]byte, error)

GetBinValue

func GetCandidateRoleBySlot

func GetCandidateRoleBySlot(ldb *db.DBService, slotNum uint64) (string, error)

GetCandidateRoleBySlot is to get candidate by slot

func GetStrValue

func GetStrValue(ldb *db.DBService, contract string, object string, key string) (string, error)

GetStrValue

func RemoveKeyValue

func RemoveKeyValue(ldb *db.DBService, contract string, object string, key string) error

RemoveStrValue

func RemoveTransactionExpirationRoleByExpiration

func RemoveTransactionExpirationRoleByExpiration(ldb *db.DBService, expiration uint64) error

func ResetAllDelegateNewTerm

func ResetAllDelegateNewTerm(ldb *db.DBService)

ResetAllDelegateNewTerm is to reset all delegate

func ResetCandidatesTerm

func ResetCandidatesTerm(ldb *db.DBService)

ResetCandidatesTerm is reseting candidates term

func SetAccountRole

func SetAccountRole(ldb *db.DBService, accountName string, value *Account) error

SetAccountRole is common func to set role for account

func SetBalanceRole

func SetBalanceRole(ldb *db.DBService, accountName string, value *Balance) error

SetBalanceRole is to set balance

func SetBinValue

func SetBinValue(ldb *db.DBService, contract string, object string, key string, value []byte) error

SetBinValue

func SetBlockHistoryRole

func SetBlockHistoryRole(ldb *db.DBService, blockNumber uint64, blockHash common.Hash) error

SetBlockHistoryRole is to save block history

func SetCandidatesTerm

func SetCandidatesTerm(ldb *db.DBService, termTime *big.Int, list []string)

SetCandidatesTerm is setting candidates term

func SetChainStateRole

func SetChainStateRole(ldb *db.DBService, value *ChainState) error

SetChainStateRole is to save chain state

func SetContractRole

func SetContractRole(ldb *db.DBService, contractName string, value *Contract) error

SetContractRole is common func to set role for contract

func SetCoreStateRole

func SetCoreStateRole(ldb *db.DBService, value *CoreState) error

SetCoreStateRole is to save core state

func SetDelegateListNewTerm

func SetDelegateListNewTerm(ldb *db.DBService, termTime *big.Int, lists []string)

SetDelegateListNewTerm is to set delegate list new term

func SetDelegateRole

func SetDelegateRole(ldb *db.DBService, key string, value *Delegate) error

SetDelegateRole is to save delegate

func SetDelegateVotesRole

func SetDelegateVotesRole(ldb *db.DBService, key string, value *DelegateVotes) error

SetDelegateVotesRole is to save delegate votes

func SetMsignAccountRole

func SetMsignAccountRole(ldb *db.DBService, accountName string, value *MsignAccount) error

SetMsignAccountRole is common func to set role for multisign account

func SetResourceLimitRole

func SetResourceLimitRole(ldb *db.DBService, accountName string, value *ResourceLimit) error

SetResourceLimitRole is to set resource limit

func SetScheduleDelegateRole

func SetScheduleDelegateRole(ldb *db.DBService, value *ScheduleDelegate) error

SetScheduleDelegateRole is seting scheduled delegate role

func SetStakedBalanceRole

func SetStakedBalanceRole(ldb *db.DBService, accountName string, value *StakedBalance) error

SetStakedBalanceRole is to set stake balance role

func SetStrValue

func SetStrValue(ldb *db.DBService, contract string, object string, key string, value string) error

SetStrValue

func SetTransactionExpirationRole

func SetTransactionExpirationRole(ldb *db.DBService, hash common.Hash, value *TransactionExpiration) error

SetTransactionExpirationRole is setting transaction expiration role

func SetTransferCreditRole

func SetTransferCreditRole(ldb *db.DBService, name string, value *TransferCredit) error

SetTransferCreditRole is setting transfer credit role

func SetVoterRole

func SetVoterRole(ldb *db.DBService, accountName string, value *Voter) error

SetVoterRole is common func to set role for voter

func ShuffleEelectCandidateListRole

func ShuffleEelectCandidateListRole(ldb *db.DBService, block *types.Block) ([]string, error)

ShuffleEelectCandidateListRole is to shuffle the candidates in one round

Types

type Account

type Account struct {
	AccountName  string   `json:"account_name"`
	PublicKey    []byte   `json:"public_key"`
	CreateTime   uint64   `json:"create_date"`
	GsPermission bool     `json:"gs_permission"`
	ContractName []string `json:"contract_name"`
}

Account is definition of user account

func GetAccountRole

func GetAccountRole(ldb *db.DBService, accountName string) (*Account, error)

GetAccountRole is common func to get role for account

type Balance

type Balance struct {
	AccountName string   `json:"account_name"`
	Balance     *big.Int `json:"balance"`
}

Balance is definition of balance

func GetBalanceRole

func GetBalanceRole(ldb *db.DBService, accountName string) (*Balance, error)

GetBalanceRole is to get balance

func (*Balance) SafeAdd

func (balance *Balance) SafeAdd(amount *big.Int) error

SafeAdd is safe function to add balance

func (*Balance) SafeSub

func (balance *Balance) SafeSub(amount *big.Int) error

SafeSub is safe function to sub balance var a, c big.Int

type BlockHistory

type BlockHistory struct {
	BlockNumber uint64      `json:"block_number"`
	BlockHash   common.Hash `json:"block_hash"`
}

BlockHistory is definition of block history

func GetBlockHistoryRole

func GetBlockHistoryRole(ldb *db.DBService, blockNumber uint64) (*BlockHistory, error)

GetBlockHistoryRole is to get block history

type ChainConfig

type ChainConfig struct {
	MaxBlockSize   uint32 `json:"max_block_size"`
	MaxTrxLifetime uint32 `json:"max_trx_lifetime"`
	MaxTrxRuntime  uint32 `json:"max_trx_runtime"`
	InDepthLeimit  uint32 `json:"in_depth_limit"`
}

ChainConfig is definition of chain config

type ChainState

type ChainState struct {
	LastBlockNum              uint64      `json:"last_block_num"`
	LastBlockHash             common.Hash `json:"last_block_hash"`
	LastBlockTime             uint64      `json:"last_block_time"`
	LastConsensusBlockNum     uint64      `json:"last_consensus_block_num"`
	LastDposConsensusBlockNum uint64      `json:"last_dpos_consensus_block_num"`
	CurrentDelegate           string      `json:"current_delegate"`
	CurrentAbsoluteSlot       uint64      `json:"current_absolute_slot"`
	RecentSlotFilled          uint64      `json:"recent_slot_filled"`
}

ChainState is definition of chain state

func GetChainStateRole

func GetChainStateRole(ldb *db.DBService) (*ChainState, error)

GetChainStateRole is to get chain state

type Contract

type Contract struct {
	ContractName      string      `json:"contract_name"`
	VMType            byte        `json:"vm_type"`
	VMVersion         byte        `json:"vm_version"`
	CodeVersion       common.Hash `json:"code_version"`
	ContractCode      []byte      `json:"contract_code"`
	ContractAbi       []byte      `json:"abi"`
	DeployAccountName string      `json:"deploy_account_name"`
}

Contract is definition of user contract

func GetContractRole

func GetContractRole(ldb *db.DBService, contractName string) (*Contract, error)

GetContractRole is common func to get role for contract

type CoreState

type CoreState struct {
	Config           ChainConfig `json:"chain_config"`
	CurrentDelegates []string    `json:"current_delegates"`
}

CoreState is definition of core state

func GetCoreStateRole

func GetCoreStateRole(ldb *db.DBService) (*CoreState, error)

GetCoreStateRole is to get core state

type Delegate

type Delegate struct {
	AccountName           string `json:"account_name"`
	ReportKey             string `json:"report_key"`
	Location              string `json:"location"`
	Description           string `json:"desc"`
	LastSlot              uint64 `json:"last_slot"`
	TotalMissed           int64  `json:"total_missed"`
	LastConfirmedBlockNum uint64 `json:"last_confirmed_block_num"`
	Active                bool   `json:"active"`
}

Delegate is definition of delegate

func GetAllDelegates

func GetAllDelegates(ldb *db.DBService) []*Delegate

GetAllDelegates is to get all delegates

func GetDelegateRoleByAccountName

func GetDelegateRoleByAccountName(ldb *db.DBService, key string) (*Delegate, error)

GetDelegateRoleByAccountName is to get delegate by account name

func GetDelegateRoleBySignKey

func GetDelegateRoleBySignKey(ldb *db.DBService, keyValue string) (*Delegate, error)

GetDelegateRoleBySignKey is to get delegate by sign key

type DelegateVotes

type DelegateVotes struct {
	OwnerAccount string `json:"owner_account"`
	Serve        `json:"serve"`
}

DelegateVotes is definition of delegate votes

func GetAllDelegateVotesRole

func GetAllDelegateVotesRole(ldb *db.DBService) ([]*DelegateVotes, error)

GetAllDelegateVotesRole is to get all delegate votes

func GetDelegateVotesRole

func GetDelegateVotesRole(ldb *db.DBService, key string) (*DelegateVotes, error)

GetDelegateVotesRole is to get delegate votes by account name

func GetDelegateVotesRoleByFinishTime

func GetDelegateVotesRoleByFinishTime(ldb *db.DBService, key *big.Int) (*DelegateVotes, error)

GetDelegateVotesRoleByFinishTime is to get delegate votes by finish time

func (*DelegateVotes) StartNewTerm

func (d *DelegateVotes) StartNewTerm(currentTermTime *big.Int) *DelegateVotes

StartNewTerm is to start new term

func (*DelegateVotes) UpdateVotes

func (d *DelegateVotes) UpdateVotes(votes *big.Int, currentTermTime *big.Int)

UpdateVotes is to update votes

type MsignAccount

type MsignAccount struct {
	MsignAccountName string                  `json:"msign_account_name"`
	Authority        []MsignAccountAuthority `json:"authority"`
	Threshold        uint32                  `json:"threshold"`
}

MsignAccount is definition of user multisign account

func GetMsignAccountRole

func GetMsignAccountRole(ldb *db.DBService, accountName string) (*MsignAccount, error)

GetMsignAccountRole is common func to get role for multisign account

type MsignAccountAuthority

type MsignAccountAuthority struct {
	AuthorAccount string `json:"author_account"`
	Weight        uint32 `json:"weight"`
}

type ResourceLimit

type ResourceLimit struct {
	AccountName                string `json:"account_name"`
	PledgedSpaceLimitInWin     uint64 `json:"pledged_space_limit_in_win"`
	PledgedTimeTokenLimitInWin uint64 `json:"pledged_time_token_limit_in_win"`
	FreeTimeTokenLimitInWin    uint64 `json:"free_time_token_limit_in_win"`
	FreeSpaceTokenLimitInWin   uint64 `json:"free_space_token_limit_in_win"`
}

ResourceLimit 单账户在窗口期内的可使用总量最大值,每次触发执行合约时更新,更新时必须保证用户使用量不超过此上限

func GetResourceLimitRole

func GetResourceLimitRole(ldb *db.DBService, accountName string) (*ResourceLimit, error)

GetResourceLimitRole is to get resource limit

type ResourceUsage

type ResourceUsage struct {
	AccountName                string `json:"account_name"`
	PledgedSpaceTokenUsedInWin uint64 `json:"pledged_space_token_used_in_win"`
	PledgedTimeTokenUsedInWin  uint64 `json:"pledged_time_token_used_in_win"`
	FreeTimeTokenUsedInWin     uint64 `json:"free_time_token_used_in_win"` // balance大于1 BTO时才有的免费资源使用量
	FreeSpaceTokenUsedInWin    uint64 `json:"free_space_token_used_in_win"`
	LastSpaceCursorBlock       uint64 `json:"last_space_cursor_block"` //上次使用资源的block位置
	LastTimeCursorBlock        uint64 `json:"last_time_cursor_block"`  //上次使用资源的block位置
}

ResourceUsage 单账户在窗口期内已使用的资源量,每次触发执行合约时更新

func GetResourceUsageRoleByName

func GetResourceUsageRoleByName(ldb *db.DBService, name string) (*ResourceUsage, error)

GetResourceUsageRoleByName is to get resource usage

type Role

type Role struct {
	Db *db.DBService
}

Role is a part of DDD, according to DDD, all the data we domain them in Role

func (*Role) AddTransactionHistory

func (r *Role) AddTransactionHistory(txHash common.Hash, blockHash common.Hash) error

AddTransactionHistory is to add transaction history

func (*Role) CreateDelegateVotes

func (r *Role) CreateDelegateVotes() error

CreateDelegateVotes is creating delegate votes

func (*Role) DeleteTransferCredit

func (r *Role) DeleteTransferCredit(name string, spender string) error

DeleteTransferCredit is deleting transfer credit

func (*Role) ElectNextTermDelegates

func (r *Role) ElectNextTermDelegates(block *types.Block, writeState bool) []string

ElectNextTermDelegates is to elect next term delegates

func (*Role) GetAccount

func (r *Role) GetAccount(name string) (*Account, error)

GetAccount is getting account

func (*Role) GetAllDelegateVotes

func (r *Role) GetAllDelegateVotes() ([]*DelegateVotes, error)

GetAllDelegateVotes is gettting all delegate votes

func (*Role) GetBalance

func (r *Role) GetBalance(accountName string) (*Balance, error)

GetBalance is getting balance

func (*Role) GetBinValue

func (r *Role) GetBinValue(contract string, object string, key string) ([]byte, error)

func (*Role) GetBlockHistory

func (r *Role) GetBlockHistory(blockNumber uint64) (*BlockHistory, error)

GetBlockHistory is getting block history

func (*Role) GetCandidateBySlot

func (r *Role) GetCandidateBySlot(slotNum uint64) (string, error)

GetCandidateBySlot is getting candidate by slot

func (*Role) GetChainState

func (r *Role) GetChainState() (*ChainState, error)

GetChainState is geting chain state

func (*Role) GetContract

func (r *Role) GetContract(name string) (*Contract, error)

GetContract is getting account

func (*Role) GetCoreState

func (r *Role) GetCoreState() (*CoreState, error)

GetCoreState is getting core state

func (*Role) GetDelegateByAccountName

func (r *Role) GetDelegateByAccountName(name string) (*Delegate, error)

GetDelegateByAccountName is getting delegate by account name.

func (*Role) GetDelegateBySignKey

func (r *Role) GetDelegateBySignKey(key string) (*Delegate, error)

GetDelegateBySignKey is getting delegate by sign key

func (*Role) GetDelegateParticipationRate

func (r *Role) GetDelegateParticipationRate() uint64

GetDelegateParticipationRate is getting delegate participationRate

func (*Role) GetDelegateVotes

func (r *Role) GetDelegateVotes(key string) (*DelegateVotes, error)

GetDelegateVotes get delegate votes role

func (*Role) GetGenesisState

func (r *Role) GetGenesisState() (*GenesisState, error)

func (*Role) GetScheduleDelegate

func (r *Role) GetScheduleDelegate() (*ScheduleDelegate, error)

GetScheduleDelegate is getting schedule delegate

func (*Role) GetSlotAtTime

func (r *Role) GetSlotAtTime(current uint64) uint64

GetSlotAtTime is geting slot at time

func (*Role) GetSlotTime

func (r *Role) GetSlotTime(slotNum uint64) uint64

GetSlotTime is geting slot time

func (*Role) GetStakedBalance

func (r *Role) GetStakedBalance(accountName string) (*StakedBalance, error)

GetStakedBalance is getting staked balance

func (*Role) GetStrValue

func (r *Role) GetStrValue(contract string, object string, key string) (string, error)

func (*Role) GetTransactionExpiration

func (r *Role) GetTransactionExpiration(txHash common.Hash) (*TransactionExpiration, error)

GetTransactionExpiration is to get transaction expiration

func (*Role) GetTransactionHistory

func (r *Role) GetTransactionHistory(txHash common.Hash) (common.Hash, error)

GetTransactionHistory is to get transaction history

func (*Role) GetTransferCredit

func (r *Role) GetTransferCredit(name string, spender string) (*TransferCredit, error)

GetTransferCredit is getting transfer credit

func (*Role) GetVoter

func (r *Role) GetVoter(name string) (*Voter, error)

GetVoter

func (*Role) IsAccountExist

func (r *Role) IsAccountExist(name string) bool

IsAccountExist is checking account if it is exist

func (*Role) IsChainActivated

func (r *Role) IsChainActivated() bool

func (*Role) IsTransitPeriod

func (r *Role) IsTransitPeriod(blockNum uint64) bool

func (*Role) RemoveKeyValue

func (r *Role) RemoveKeyValue(contract string, object string, key string) error

func (*Role) SetAccount

func (r *Role) SetAccount(name string, value *Account) error

SetAccount is setting account

func (*Role) SetBalance

func (r *Role) SetBalance(accountName string, value *Balance) error

SetBalance is setting balance

func (*Role) SetBinValue

func (r *Role) SetBinValue(contract string, object string, key string, value []byte) error

func (*Role) SetBlockHistory

func (r *Role) SetBlockHistory(blockNumber uint64, blockHash common.Hash) error

SetBlockHistory is setting block history

func (*Role) SetChainState

func (r *Role) SetChainState(value *ChainState) error

SetChainState is setting chain state

func (*Role) SetContract

func (r *Role) SetContract(name string, value *Contract) error

SetContract is setting account

func (*Role) SetCoreState

func (r *Role) SetCoreState(value *CoreState) error

SetCoreState is setting core state

func (*Role) SetDelegate

func (r *Role) SetDelegate(accountName string, value *Delegate) error

SetDelegate is setting delegate

func (*Role) SetDelegateVotes

func (r *Role) SetDelegateVotes(key string, value *DelegateVotes) error

SetDelegateVotes set delegate votes role

func (*Role) SetGenesisState

func (r *Role) SetGenesisState(value *GenesisState) error

func (*Role) SetScheduleDelegate

func (r *Role) SetScheduleDelegate(value *ScheduleDelegate) error

SetScheduleDelegate is setting schedule delegate

func (*Role) SetStakedBalance

func (r *Role) SetStakedBalance(accountName string, value *StakedBalance) error

SetStakedBalance is setting staked balance

func (*Role) SetStrValue

func (r *Role) SetStrValue(contract string, object string, key string, value string) error

func (*Role) SetTransactionExpiration

func (r *Role) SetTransactionExpiration(txHash common.Hash, value *TransactionExpiration) error

SetTransactionExpiration is to set transaction history

func (*Role) SetTransferCredit

func (r *Role) SetTransferCredit(name string, value *TransferCredit) error

SetTransferCredit is setting transfer credit

func (*Role) SetVoter

func (r *Role) SetVoter(name string, value *Voter) error

SetVoter

func (*Role) ShuffleEelectCandidateList

func (r *Role) ShuffleEelectCandidateList(block *types.Block) ([]string, error)

ShuffleEelectCandidateList is to elect next term delegates

type RoleInterface

type RoleInterface interface {
	SetChainState(value *ChainState) error
	GetChainState() (*ChainState, error)
	SetCoreState(value *CoreState) error
	GetCoreState() (*CoreState, error)
	SetGenesisState(value *GenesisState) error
	GetGenesisState() (*GenesisState, error)
	IsChainActivated() bool
	IsTransitPeriod(blockNum uint64) bool
	SetAccount(name string, value *Account) error
	GetAccount(name string) (*Account, error)
	IsAccountExist(name string) bool
	SetContract(name string, value *Contract) error
	GetContract(name string) (*Contract, error)
	SetContractTable(contract string, table string) error
	GetContractTable(contract string, table string) (*ContractTable, error)
	GetContractTables() ([]string, error)
	SetBalance(accountName string, value *Balance) error
	GetBalance(accountName string) (*Balance, error)
	SetStakedBalance(accountName string, value *StakedBalance) error
	GetStakedBalance(accountName string) (*StakedBalance, error)
	SetTransferCredit(name string, value *TransferCredit) error
	GetTransferCredit(name string, spender string) (*TransferCredit, error)
	DeleteTransferCredit(name string, spender string) error

	SetDelegate(accountName string, value *Delegate) error
	GetDelegateByAccountName(name string) (*Delegate, error)
	GetDelegateBySignKey(key string) (*Delegate, error)
	GetCandidateBySlot(slotNum uint64) (string, error)
	GetDelegateParticipationRate(string) uint32
	GetAllDelegatesFilter() ([]*Delegate, error)

	SetTransitVotes(accountName string, value *TransitVotes) error
	GetTransitVotes(accountName string) (*TransitVotes, error)

	SetScheduleDelegate(value *ScheduleDelegate) error
	GetScheduleDelegate() (*ScheduleDelegate, error)
	SetVoter(name string, value *Voter) error
	GetVoter(name string) (*Voter, error)
	GetAllVoters() ([]*Voter, error)

	CreateDelegateVotes() error
	GetDelegateVotes(key string) (*DelegateVotes, error)
	SetDelegateVotes(key string, value *DelegateVotes) error
	GetAllDelegateVotes() ([]*DelegateVotes, error)

	SetBlockHistory(blockNumber uint64, blockHash common.Hash) error
	GetBlockHistory(blockNumber uint64) (*BlockHistory, error)
	AddTransactionHistory(txHash common.Hash, blockHash common.Hash) error
	GetTransactionHistory(txHash common.Hash) (common.Hash, error)
	SetTransactionExpiration(txHash common.Hash, value *TransactionExpiration) error
	GetTransactionExpiration(txHash common.Hash) (*TransactionExpiration, error)

	GetSlotAtTime(current uint64) uint64
	GetSlotTime(slotNum uint64) uint64

	ElectNextTermDelegates(block *types.Block, writeState bool) []string
	ShuffleEelectCandidateList(block *types.Block) ([]string, error)

	SetStrValue(contract string, object string, key string, value string) error
	GetStrValue(contract string, object string, key string) (string, error)
	SetBinValue(contract string, object string, key string, value []byte) error
	GetBinValue(contract string, object string, key string) ([]byte, error)
	RemoveKeyValue(contract string, object string, key string) error

	SetDelegateReward(accountName string, value *DelegateReward) error
	GetDelegateReward(accountName string) (*DelegateReward, error)
	GetDelegateRewardByAccountName(key string) (*DelegateReward, error)
	GetAllDelegateReward() ([]*DelegateReward, error)
	GetDelegateUnpaidReward(delegateName string) (*big.Int, *big.Int)
	SetRewardPool(value *RewardPool) error
	GetRewardPool() (*RewardPool, error)
	RewardHandleVotesChange(delegateName string, amount *big.Int, isTransitVote bool) error
	DelegateRewardUnReg(delegateName string) error
	DelegateRewardReReg(delegateName string) error
	OnBlock(delegateName string) error
	ClaimReward(delegateName string, isUnReg bool) error
	InitRewardPoolRole() error

	CreateTableIndex(contract string, table string, index string, indexJson string) error
}

RoleInterface is the interface that provided by Role

func NewRole

func NewRole(db *db.DBService) RoleInterface

NewRole is creating new role

type ScheduleDelegate

type ScheduleDelegate struct {
	CurrentTermTime *big.Int
}

ScheduleDelegate is singleton role

func GetScheduleDelegateRole

func GetScheduleDelegateRole(ldb *db.DBService) (*ScheduleDelegate, error)

GetScheduleDelegateRole is to get schedulated delegate role

type Serve

type Serve struct {
	Votes          *big.Int `json:"votes"`
	Position       *big.Int `json:"position"`
	TermUpdateTime *big.Int `json:"term_update_time"`
	TermFinishTime *big.Int `json:"term_finish_time"`
}

Serve is definition of serve

type StakedBalance

type StakedBalance struct {
	AccountName        string   `json:"account_name"`
	StakedBalance      *big.Int `json:"staked_balance"`
	StakedTimeBalance  *big.Int `json:"staked_time_balance"`
	StakedSpaceBalance *big.Int `json:"staked_space_balance"`
	UnstakingBalance   *big.Int `json:"unstaking_balance"`
	LastUnstakingTime  uint64   `json:"unstaking_time"`
}

StakedBalance is definition of stake balance

func GetStakedBalanceRoleByName

func GetStakedBalanceRoleByName(ldb *db.DBService, name string) (*StakedBalance, error)

GetStakedBalanceRoleByName is to get stake balance

func (*StakedBalance) Claim

func (balance *StakedBalance) Claim(amount *big.Int) error

UnstakingAmount

func (*StakedBalance) SafeAdd

func (balance *StakedBalance) SafeAdd(amount *big.Int) error

SafeAdd is safe function to add stake balance

func (*StakedBalance) SafeSub

func (balance *StakedBalance) SafeSub(amount *big.Int) error

SafeSub is safe function to sub stake balance

func (*StakedBalance) UnstakingAmount

func (balance *StakedBalance) UnstakingAmount(amount *big.Int) error

UnstakingAmount

type TransactionExpiration

type TransactionExpiration struct {
	TrxHash    common.Hash `json:"trx_hash"`
	Expiration uint64      `json:"expiration"`
}

TransactionExpiration is transaction expiration struct

func GetTransactionExpirationRoleByHash

func GetTransactionExpirationRoleByHash(ldb *db.DBService, hash common.Hash) (*TransactionExpiration, error)

GetTransactionExpirationRoleByHash is getting transaction expiration role hash

type TransferCredit

type TransferCredit struct {
	Name    string   `json:"name"`
	Spender string   `json:"spender"`
	Limit   *big.Int `json:"limit"`
}

TransferCredit is the struct for transferring credit

func GetTransferCreditRole

func GetTransferCreditRole(ldb *db.DBService, name string, spender string) (*TransferCredit, error)

GetTransferCreditRole is geting transfer credit role

func (*TransferCredit) SafeSub

func (credit *TransferCredit) SafeSub(amount *big.Int) error

SafeSub is safe sub

type TransitVotes

type TransitVotes struct {
	ProducerAccount string   `json:"producer_account"`
	TransitVotes    *big.Int `json:"transit_votes"`
}

TransitVotes is definition of delegate votes

type Voter

type Voter struct {
	Owner    string `json:"owner"`
	Delegate string `json:"delegate"`
}

Voter is definition of voter

func GetAllVotersRole

func GetAllVotersRole(ldb *db.DBService) ([]*Voter, error)

func GetVoterRole

func GetVoterRole(ldb *db.DBService, accountName string) (*Voter, error)

GetVoterRole is common func to get role for voter

Jump to

Keyboard shortcuts

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