Documentation ¶
Overview ¶
* file description: account role * @Author: may luo * @Date: 2017-12-12 * @Last Modified by: * @Last Modified time:
Index ¶
- Constants
- func CreateAccountRole(ldb *db.DBService) error
- func CreateBalanceRole(ldb *db.DBService) error
- func CreateBlockHistoryRole(ldb *db.DBService) error
- func CreateChainStateRole(ldb *db.DBService) error
- func CreateContractRole(ldb *db.DBService) error
- func CreateCoreStateRole(ldb *db.DBService) error
- func CreateDelegateRole(ldb *db.DBService) error
- func CreateDelegateVotesRole(ldb *db.DBService) error
- func CreateKeyValueRole(ldb *db.DBService) error
- func CreateMsignAccountRole(ldb *db.DBService) error
- func CreateResourceLimitRole(ldb *db.DBService) error
- func CreateScheduleDelegateRole(ldb *db.DBService) error
- func CreateStakedBalanceRole(ldb *db.DBService) error
- func CreateTransactionExpirationRole(ldb *db.DBService) error
- func CreateTransferCreditRole(ldb *db.DBService) error
- func CreateTransitVotesRole(ldb *db.DBService) error
- func CreateVoterRole(ldb *db.DBService) error
- func DeleteTransferCreditRole(ldb *db.DBService, name string, spender string) error
- func ElectNextTermDelegatesRole(ldb *db.DBService, writeState bool) []string
- func FilterOutgoingDelegate(ldb *db.DBService) []string
- func GetAllSortFinishTimeDelegates(ldb *db.DBService) ([]string, error)
- func GetAllSortVotesDelegates(ldb *db.DBService) ([]string, error)
- func GetBinValue(ldb *db.DBService, contract string, object string, key string) ([]byte, error)
- func GetCandidateRoleBySlot(ldb *db.DBService, slotNum uint64) (string, error)
- func GetStrValue(ldb *db.DBService, contract string, object string, key string) (string, error)
- func RemoveKeyValue(ldb *db.DBService, contract string, object string, key string) error
- func RemoveTransactionExpirationRoleByExpiration(ldb *db.DBService, expiration uint64) error
- func ResetAllDelegateNewTerm(ldb *db.DBService)
- func ResetCandidatesTerm(ldb *db.DBService)
- func SetAccountRole(ldb *db.DBService, accountName string, value *Account) error
- func SetBalanceRole(ldb *db.DBService, accountName string, value *Balance) error
- func SetBinValue(ldb *db.DBService, contract string, object string, key string, value []byte) error
- func SetBlockHistoryRole(ldb *db.DBService, blockNumber uint64, blockHash common.Hash) error
- func SetCandidatesTerm(ldb *db.DBService, termTime *big.Int, list []string)
- func SetChainStateRole(ldb *db.DBService, value *ChainState) error
- func SetContractRole(ldb *db.DBService, contractName string, value *Contract) error
- func SetCoreStateRole(ldb *db.DBService, value *CoreState) error
- func SetDelegateListNewTerm(ldb *db.DBService, termTime *big.Int, lists []string)
- func SetDelegateRole(ldb *db.DBService, key string, value *Delegate) error
- func SetDelegateVotesRole(ldb *db.DBService, key string, value *DelegateVotes) error
- func SetMsignAccountRole(ldb *db.DBService, accountName string, value *MsignAccount) error
- func SetResourceLimitRole(ldb *db.DBService, accountName string, value *ResourceLimit) error
- func SetScheduleDelegateRole(ldb *db.DBService, value *ScheduleDelegate) error
- func SetStakedBalanceRole(ldb *db.DBService, accountName string, value *StakedBalance) error
- func SetStrValue(ldb *db.DBService, contract string, object string, key string, value string) error
- func SetTransactionExpirationRole(ldb *db.DBService, hash common.Hash, value *TransactionExpiration) error
- func SetTransferCreditRole(ldb *db.DBService, name string, value *TransferCredit) error
- func SetVoterRole(ldb *db.DBService, accountName string, value *Voter) error
- func ShuffleEelectCandidateListRole(ldb *db.DBService, block *types.Block) ([]string, error)
- type Account
- type Balance
- type BlockHistory
- type ChainConfig
- type ChainState
- type Contract
- type CoreState
- type Delegate
- type DelegateVotes
- type MsignAccount
- type MsignAccountAuthority
- type ResourceLimit
- type ResourceUsage
- type Role
- func (r *Role) AddTransactionHistory(txHash common.Hash, blockHash common.Hash) error
- func (r *Role) CreateDelegateVotes() error
- func (r *Role) DeleteTransferCredit(name string, spender string) error
- func (r *Role) ElectNextTermDelegates(block *types.Block, writeState bool) []string
- func (r *Role) GetAccount(name string) (*Account, error)
- func (r *Role) GetAllDelegateVotes() ([]*DelegateVotes, error)
- func (r *Role) GetBalance(accountName string) (*Balance, error)
- func (r *Role) GetBinValue(contract string, object string, key string) ([]byte, error)
- func (r *Role) GetBlockHistory(blockNumber uint64) (*BlockHistory, error)
- func (r *Role) GetCandidateBySlot(slotNum uint64) (string, error)
- func (r *Role) GetChainState() (*ChainState, error)
- func (r *Role) GetContract(name string) (*Contract, error)
- func (r *Role) GetCoreState() (*CoreState, error)
- func (r *Role) GetDelegateByAccountName(name string) (*Delegate, error)
- func (r *Role) GetDelegateBySignKey(key string) (*Delegate, error)
- func (r *Role) GetDelegateParticipationRate() uint64
- func (r *Role) GetDelegateVotes(key string) (*DelegateVotes, error)
- func (r *Role) GetGenesisState() (*GenesisState, error)
- func (r *Role) GetScheduleDelegate() (*ScheduleDelegate, error)
- func (r *Role) GetSlotAtTime(current uint64) uint64
- func (r *Role) GetSlotTime(slotNum uint64) uint64
- func (r *Role) GetStakedBalance(accountName string) (*StakedBalance, error)
- func (r *Role) GetStrValue(contract string, object string, key string) (string, error)
- func (r *Role) GetTransactionExpiration(txHash common.Hash) (*TransactionExpiration, error)
- func (r *Role) GetTransactionHistory(txHash common.Hash) (common.Hash, error)
- func (r *Role) GetTransferCredit(name string, spender string) (*TransferCredit, error)
- func (r *Role) GetVoter(name string) (*Voter, error)
- func (r *Role) IsAccountExist(name string) bool
- func (r *Role) IsChainActivated() bool
- func (r *Role) IsTransitPeriod(blockNum uint64) bool
- func (r *Role) RemoveKeyValue(contract string, object string, key string) error
- func (r *Role) SetAccount(name string, value *Account) error
- func (r *Role) SetBalance(accountName string, value *Balance) error
- func (r *Role) SetBinValue(contract string, object string, key string, value []byte) error
- func (r *Role) SetBlockHistory(blockNumber uint64, blockHash common.Hash) error
- func (r *Role) SetChainState(value *ChainState) error
- func (r *Role) SetContract(name string, value *Contract) error
- func (r *Role) SetCoreState(value *CoreState) error
- func (r *Role) SetDelegate(accountName string, value *Delegate) error
- func (r *Role) SetDelegateVotes(key string, value *DelegateVotes) error
- func (r *Role) SetGenesisState(value *GenesisState) error
- func (r *Role) SetScheduleDelegate(value *ScheduleDelegate) error
- func (r *Role) SetStakedBalance(accountName string, value *StakedBalance) error
- func (r *Role) SetStrValue(contract string, object string, key string, value string) error
- func (r *Role) SetTransactionExpiration(txHash common.Hash, value *TransactionExpiration) error
- func (r *Role) SetTransferCredit(name string, value *TransferCredit) error
- func (r *Role) SetVoter(name string, value *Voter) error
- func (r *Role) ShuffleEelectCandidateList(block *types.Block) ([]string, error)
- type RoleInterface
- type ScheduleDelegate
- type Serve
- type StakedBalance
- type TransactionExpiration
- type TransferCredit
- type TransitVotes
- type Voter
Constants ¶
const ( //AccountObjectName is the table name of user account AccountObjectName string = "account" //MsignAccountObjectName is the table name of user multisign account MsignAccountObjectName string = "msignaccount" )
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" )
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" )
const ( //VoterObjectName is the table name of voter object VoterObjectName string = "voter" VoterObjectKeyName string = "owner" )
const BalanceObjectName string = "balance"
BalanceObjectName is definition of object name of balance
const BlockHistoryObjectName string = "block_history"
BlockHistoryObjectName is definition of block history object name
const ( //ContractObjectName is the table name of user contract ContractObjectName string = "contract" )
const DelegateObjectIndexName string = "signing_key"
DelegateObjectIndexName is definition of delegate object index name
const DelegateObjectKeyName string = "account_name"
DelegateObjectKeyName is definition of delegate object key name
const DelegateObjectName string = "delegate"
DelegateObjectName is definition of delegate object name
const DelegateVotesObjectIndexFinishTime string = "term_finish_time"
DelegateVotesObjectIndexFinishTime is definition of delegate vote object index finish time
const DelegateVotesObjectIndexFinishTimeJSON string = "serve.term_finish_time"
const DelegateVotesObjectIndexVote string = "votes"
DelegateVotesObjectIndexVote is definition of delegate vote object index name
const DelegateVotesObjectIndexVoteJSON string = "serve.votes"
const DelegateVotesObjectKeyName string = "owner_account"
DelegateVotesObjectKeyName is definition of delegate vote object key name
const DelegateVotesObjectName string = "producervote"
DelegateVotesObjectName is definition of delegate vote object name
const ( //KeyValueObjectName is the table name of keyvalue object KeyValueObjectName string = "keyvalue" )
const ResourceLimitObjectName string = "resource_limit"
ResourceObjectName is definition of object name of balance
const ResourceUsageObjectName string = "resource_usage"
StakedBalanceObjectName is definition of object name of stake balance
const ScheduleDelegateObjectName string = "scheduledelegate"
ScheduleDelegateObjectName is scheduledelegate
const StakedBalanceObjectName string = "staked_balance"
StakedBalanceObjectName is definition of object name of stake balance
const TransactionExpirationObjectIndexExpiration string = "expiration"
const TransactionExpirationObjectKeyName string = "trx_hash"
const TransactionExpirationObjectName string = "transaction_expiration"
const TransferCreditObjectName string = "credit"
TransferCreditObjectName is credit name
const TransitVotesObjectIndexVote string = "transit_votes"
TransitVotesObjectIndexVote is definition of delegate vote object index name in transition period
const TransitVotesObjectIndexVoteJSON string = "transit_votes"
const TransitVotesObjectKeyName string = "producer_account"
TransitVotesObjectKeyName is definition of delegate vote object key name in transition period
const TransitVotesObjectName string = "transitvotes"
TransitVotesObjectName is definition of delegate vote object name in transition period
Variables ¶
This section is empty.
Functions ¶
func CreateAccountRole ¶
CreateAccountRole is create account role
func CreateBalanceRole ¶
CreateBalanceRole is to create balance role
func CreateBlockHistoryRole ¶
CreateBlockHistoryRole is to init block history
func CreateChainStateRole ¶
CreateChainStateRole is to save init chain state
func CreateContractRole ¶
CreateContractRole is create contract role
func CreateCoreStateRole ¶
CreateCoreStateRole is to save init core state
func CreateDelegateRole ¶
CreateDelegateRole is to save initial delegate
func CreateDelegateVotesRole ¶
CreateDelegateVotesRole is to save initial delegate votes
func CreateKeyValueRole ¶
CreateKeyValueRole is create account role
func CreateMsignAccountRole ¶
CreateMsignAccountRole is create account role
func CreateResourceLimitRole ¶
CreateResourceLimitRole is to create resource limit role
func CreateStakedBalanceRole ¶
CreateStakedBalanceRole is to create stake balance role
func CreateTransactionExpirationRole ¶
CreateTransactionExpirationRole is creating transaction expiration role
func CreateTransferCreditRole ¶
CreateTransferCreditRole is create transfer credits
func CreateTransitVotesRole ¶
CreateTransitVotesRole is to save initial delegate votes in transition period
func CreateVoterRole ¶
CreateVoterRole is create voter role
func DeleteTransferCreditRole ¶
DeleteTransferCreditRole is deleting transfer credit role
func ElectNextTermDelegatesRole ¶
ElectNextTermDelegatesRole is to elect next term delegates
func FilterOutgoingDelegate ¶
FilterOutgoingDelegate is to filter outgoing delegate
func GetAllSortFinishTimeDelegates ¶
GetAllSortFinishTimeDelegates is to get all sort finish time delegates
func GetAllSortVotesDelegates ¶
GetAllSortVotesDelegates is to get all sort votes delegates
func GetBinValue ¶
GetBinValue
func GetCandidateRoleBySlot ¶
GetCandidateRoleBySlot is to get candidate by slot
func GetStrValue ¶
GetStrValue
func RemoveKeyValue ¶
RemoveStrValue
func ResetAllDelegateNewTerm ¶
ResetAllDelegateNewTerm is to reset all delegate
func ResetCandidatesTerm ¶
ResetCandidatesTerm is reseting candidates term
func SetAccountRole ¶
SetAccountRole is common func to set role for account
func SetBalanceRole ¶
SetBalanceRole is to set balance
func SetBinValue ¶
SetBinValue
func SetBlockHistoryRole ¶
SetBlockHistoryRole is to save block history
func SetCandidatesTerm ¶
SetCandidatesTerm is setting candidates term
func SetChainStateRole ¶
func SetChainStateRole(ldb *db.DBService, value *ChainState) error
SetChainStateRole is to save chain state
func SetContractRole ¶
SetContractRole is common func to set role for contract
func SetCoreStateRole ¶
SetCoreStateRole is to save core state
func SetDelegateListNewTerm ¶
SetDelegateListNewTerm is to set delegate list new term
func SetDelegateRole ¶
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 ¶
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 ¶
SetVoterRole is common func to set role for voter
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
type Balance ¶
Balance is definition of balance
func GetBalanceRole ¶
GetBalanceRole is to get balance
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
type CoreState ¶
type CoreState struct { Config ChainConfig `json:"chain_config"` CurrentDelegates []string `json:"current_delegates"` }
CoreState is definition of 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 ¶
GetAllDelegates is to get all delegates
func GetDelegateRoleByAccountName ¶
GetDelegateRoleByAccountName is to get delegate by account name
type DelegateVotes ¶
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 ¶
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 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 ¶
Role is a part of DDD, according to DDD, all the data we domain them in Role
func (*Role) AddTransactionHistory ¶
AddTransactionHistory is to add transaction history
func (*Role) CreateDelegateVotes ¶
CreateDelegateVotes is creating delegate votes
func (*Role) DeleteTransferCredit ¶
DeleteTransferCredit is deleting transfer credit
func (*Role) ElectNextTermDelegates ¶
ElectNextTermDelegates is to elect next term delegates
func (*Role) GetAccount ¶
GetAccount is getting account
func (*Role) GetAllDelegateVotes ¶
func (r *Role) GetAllDelegateVotes() ([]*DelegateVotes, error)
GetAllDelegateVotes is gettting all delegate votes
func (*Role) GetBalance ¶
GetBalance is getting balance
func (*Role) GetBinValue ¶
func (*Role) GetBlockHistory ¶
func (r *Role) GetBlockHistory(blockNumber uint64) (*BlockHistory, error)
GetBlockHistory is getting block history
func (*Role) GetCandidateBySlot ¶
GetCandidateBySlot is getting candidate by slot
func (*Role) GetChainState ¶
func (r *Role) GetChainState() (*ChainState, error)
GetChainState is geting chain state
func (*Role) GetContract ¶
GetContract is getting account
func (*Role) GetCoreState ¶
GetCoreState is getting core state
func (*Role) GetDelegateByAccountName ¶
GetDelegateByAccountName is getting delegate by account name.
func (*Role) GetDelegateBySignKey ¶
GetDelegateBySignKey is getting delegate by sign key
func (*Role) GetDelegateParticipationRate ¶
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 (*Role) GetScheduleDelegate ¶
func (r *Role) GetScheduleDelegate() (*ScheduleDelegate, error)
GetScheduleDelegate is getting schedule delegate
func (*Role) GetSlotAtTime ¶
GetSlotAtTime is geting slot at time
func (*Role) GetSlotTime ¶
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 (*Role) GetTransactionExpiration ¶
func (r *Role) GetTransactionExpiration(txHash common.Hash) (*TransactionExpiration, error)
GetTransactionExpiration is to get transaction expiration
func (*Role) GetTransactionHistory ¶
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) IsAccountExist ¶
IsAccountExist is checking account if it is exist
func (*Role) IsChainActivated ¶
func (*Role) IsTransitPeriod ¶
func (*Role) RemoveKeyValue ¶
func (*Role) SetAccount ¶
SetAccount is setting account
func (*Role) SetBalance ¶
SetBalance is setting balance
func (*Role) SetBinValue ¶
func (*Role) SetBlockHistory ¶
SetBlockHistory is setting block history
func (*Role) SetChainState ¶
func (r *Role) SetChainState(value *ChainState) error
SetChainState is setting chain state
func (*Role) SetContract ¶
SetContract is setting account
func (*Role) SetCoreState ¶
SetCoreState is setting core state
func (*Role) SetDelegate ¶
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 (*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 (*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
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
type ScheduleDelegate ¶
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 ¶
GetTransferCreditRole is geting transfer credit role
type TransitVotes ¶
type TransitVotes struct { ProducerAccount string `json:"producer_account"` TransitVotes *big.Int `json:"transit_votes"` }
TransitVotes is definition of delegate votes
Source Files ¶
- account-role.go
- balance-role.go
- block-history-role.go
- chain-state-role.go
- contract-role.go
- core-state-role.go
- delegate-role.go
- delegate-vote-role.go
- key-value-role.go
- resource-role.go
- role.go
- schedule-delegate-role.go
- slot-role.go
- transaction-expiration-role.go
- transfer-credit.go
- transit-role-vole.go
- voter-role.go