contracts

package
v2.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RegisterGas               uint64 = 62200
	UpdateRegistrationGas     uint64 = 62200
	CancelRegisterGas         uint64 = 83200
	RewardGas                 uint64 = 68200
	VoteGas                   uint64 = 62000
	CancelVoteGas             uint64 = 62000
	PledgeGas                 uint64 = 82000
	CancelPledgeGas           uint64 = 73000
	AgentPledgeGas            uint64 = 82000
	AgentCancelPledgeGas      uint64 = 73000
	CreateConsensusGroupGas   uint64 = 62200
	CancelConsensusGroupGas   uint64 = 83200
	ReCreateConsensusGroupGas uint64 = 62200
	MintageCancelPledgeGas    uint64 = 83200
	MintGas                   uint64 = 104525
	IssueGas                  uint64 = 69325
	BurnGas                   uint64 = 48837
	TransferOwnerGas          uint64 = 58981
	ChangeTokenTypeGas        uint64 = 63125
	GetTokenInfoGas           uint64 = 63200

	GetRewardTimeLimit int64 = 3600 // Cannot get snapshot block reward of current few blocks, for latest snapshot block could be reverted
)

Variables

View Source
var (
	ContractsParamsTest = ContractsParams{
		RegisterMinPledgeHeight:          1,
		PledgeHeight:                     1,
		CreateConsensusGroupPledgeHeight: 1,
		MintPledgeHeight:                 1,
	}
	ContractsParamsMainNet = ContractsParams{
		RegisterMinPledgeHeight:          3600 * 24 * 3,
		PledgeHeight:                     3600 * 24 * 3,
		CreateConsensusGroupPledgeHeight: 3600 * 24 * 3,
		MintPledgeHeight:                 3600 * 24 * 30 * 3,
	}
)
View Source
var (
	Agent          = true
	NoAgent        = false
	NoAgentAddress = types.ZERO_ADDRESS
	NoBid          = uint8(0)
)

Functions

func CalcRewardByDay

func CalcRewardByDay(db vm_db.VmDb, reader util.ConsensusReader, timestamp int64) (m map[string]*Reward, err error)

func CheckMintToken added in v1.3.0

func CheckMintToken(param abi.ParamMintage) error

func InitContractsConfig

func InitContractsConfig(isTestParam bool)

func RewardDrained

func RewardDrained(reward *Reward, drained bool) bool

Types

type BuiltinContractMethod

type BuiltinContractMethod interface {
	GetFee(block *ledger.AccountBlock) (*big.Int, error)
	// calc and use quota, check tx data
	DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error
	// quota for doSend block
	GetSendQuota(data []byte) (uint64, error)
	// check status, update state
	DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)
	// refund data at receive error
	GetRefundData() ([]byte, bool)
}

func GetBuiltinContractMethod

func GetBuiltinContractMethod(addr types.Address, methodSelector []byte) (BuiltinContractMethod, bool, error)

type ContractsParams

type ContractsParams struct {
	RegisterMinPledgeHeight          uint64 // Minimum pledge height for register
	PledgeHeight                     uint64 // pledge height for stake
	CreateConsensusGroupPledgeHeight uint64 // Pledge height for registering to be a super node of snapshot group and common delegate group
	MintPledgeHeight                 uint64 // Pledge height for mintage if choose to pledge instead of destroy vite token
}

type MethodAgentCancelPledge

type MethodAgentCancelPledge struct{}

func (*MethodAgentCancelPledge) DoReceive

func (p *MethodAgentCancelPledge) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodAgentCancelPledge) DoSend

func (*MethodAgentCancelPledge) GetFee

func (p *MethodAgentCancelPledge) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodAgentCancelPledge) GetRefundData

func (p *MethodAgentCancelPledge) GetRefundData() ([]byte, bool)

func (*MethodAgentCancelPledge) GetSendQuota

func (p *MethodAgentCancelPledge) GetSendQuota(data []byte) (uint64, error)

type MethodAgentPledge

type MethodAgentPledge struct{}

func (*MethodAgentPledge) DoReceive

func (p *MethodAgentPledge) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodAgentPledge) DoSend

func (p *MethodAgentPledge) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

func (*MethodAgentPledge) GetFee

func (p *MethodAgentPledge) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodAgentPledge) GetRefundData

func (p *MethodAgentPledge) GetRefundData() ([]byte, bool)

func (*MethodAgentPledge) GetSendQuota

func (p *MethodAgentPledge) GetSendQuota(data []byte) (uint64, error)

type MethodBurn added in v1.3.0

type MethodBurn struct{}

func (*MethodBurn) DoReceive added in v1.3.0

func (p *MethodBurn) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodBurn) DoSend added in v1.3.0

func (p *MethodBurn) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

func (*MethodBurn) GetFee added in v1.3.0

func (p *MethodBurn) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodBurn) GetRefundData added in v1.3.0

func (p *MethodBurn) GetRefundData() ([]byte, bool)

func (*MethodBurn) GetSendQuota

func (p *MethodBurn) GetSendQuota(data []byte) (uint64, error)

type MethodCancelPledge

type MethodCancelPledge struct{}

func (*MethodCancelPledge) DoReceive

func (p *MethodCancelPledge) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodCancelPledge) DoSend

func (p *MethodCancelPledge) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

func (*MethodCancelPledge) GetFee

func (p *MethodCancelPledge) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodCancelPledge) GetRefundData

func (p *MethodCancelPledge) GetRefundData() ([]byte, bool)

func (*MethodCancelPledge) GetSendQuota

func (p *MethodCancelPledge) GetSendQuota(data []byte) (uint64, error)

type MethodCancelRegister

type MethodCancelRegister struct {
}

func (*MethodCancelRegister) DoReceive

func (p *MethodCancelRegister) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodCancelRegister) DoSend

func (p *MethodCancelRegister) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

cancel register to become a super node of a consensus group after registered for 3 month, get 100w ViteToken back

func (*MethodCancelRegister) GetFee

func (p *MethodCancelRegister) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodCancelRegister) GetRefundData

func (p *MethodCancelRegister) GetRefundData() ([]byte, bool)

func (*MethodCancelRegister) GetSendQuota

func (p *MethodCancelRegister) GetSendQuota(data []byte) (uint64, error)

type MethodCancelVote

type MethodCancelVote struct {
}

func (*MethodCancelVote) DoReceive

func (p *MethodCancelVote) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodCancelVote) DoSend

func (p *MethodCancelVote) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

cancel vote for a super node of a consensus group

func (*MethodCancelVote) GetFee

func (p *MethodCancelVote) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodCancelVote) GetRefundData

func (p *MethodCancelVote) GetRefundData() ([]byte, bool)

func (*MethodCancelVote) GetSendQuota

func (p *MethodCancelVote) GetSendQuota(data []byte) (uint64, error)

type MethodChangeTokenType added in v1.3.0

type MethodChangeTokenType struct{}

func (*MethodChangeTokenType) DoReceive added in v1.3.0

func (p *MethodChangeTokenType) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodChangeTokenType) DoSend added in v1.3.0

func (p *MethodChangeTokenType) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

func (*MethodChangeTokenType) GetFee added in v1.3.0

func (p *MethodChangeTokenType) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodChangeTokenType) GetRefundData added in v1.3.0

func (p *MethodChangeTokenType) GetRefundData() ([]byte, bool)

func (*MethodChangeTokenType) GetSendQuota

func (p *MethodChangeTokenType) GetSendQuota(data []byte) (uint64, error)

type MethodGetTokenInfo

type MethodGetTokenInfo struct{}

func (*MethodGetTokenInfo) DoReceive

func (p *MethodGetTokenInfo) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodGetTokenInfo) DoSend

func (p *MethodGetTokenInfo) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

func (*MethodGetTokenInfo) GetFee

func (p *MethodGetTokenInfo) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodGetTokenInfo) GetRefundData

func (p *MethodGetTokenInfo) GetRefundData() ([]byte, bool)

func (*MethodGetTokenInfo) GetSendQuota

func (p *MethodGetTokenInfo) GetSendQuota(data []byte) (uint64, error)

type MethodIssue added in v1.3.0

type MethodIssue struct{}

func (*MethodIssue) DoReceive added in v1.3.0

func (p *MethodIssue) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodIssue) DoSend added in v1.3.0

func (p *MethodIssue) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

func (*MethodIssue) GetFee added in v1.3.0

func (p *MethodIssue) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodIssue) GetRefundData added in v1.3.0

func (p *MethodIssue) GetRefundData() ([]byte, bool)

func (*MethodIssue) GetSendQuota

func (p *MethodIssue) GetSendQuota(data []byte) (uint64, error)

type MethodMint added in v1.3.0

type MethodMint struct{}

func (*MethodMint) DoReceive added in v1.3.0

func (p *MethodMint) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodMint) DoSend added in v1.3.0

func (p *MethodMint) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

func (*MethodMint) GetFee added in v1.3.0

func (p *MethodMint) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodMint) GetRefundData added in v1.3.0

func (p *MethodMint) GetRefundData() ([]byte, bool)

func (*MethodMint) GetSendQuota

func (p *MethodMint) GetSendQuota(data []byte) (uint64, error)

type MethodPledge

type MethodPledge struct{}

func (*MethodPledge) DoReceive

func (p *MethodPledge) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodPledge) DoSend

func (p *MethodPledge) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

func (*MethodPledge) GetFee

func (p *MethodPledge) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodPledge) GetRefundData

func (p *MethodPledge) GetRefundData() ([]byte, bool)

func (*MethodPledge) GetSendQuota

func (p *MethodPledge) GetSendQuota(data []byte) (uint64, error)

type MethodRegister

type MethodRegister struct {
}

func (*MethodRegister) DoReceive

func (p *MethodRegister) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodRegister) DoSend

func (p *MethodRegister) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

register to become a super node of a consensus group, lock 1 million ViteToken for 3 month

func (*MethodRegister) GetFee

func (p *MethodRegister) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodRegister) GetRefundData

func (p *MethodRegister) GetRefundData() ([]byte, bool)

func (*MethodRegister) GetSendQuota

func (p *MethodRegister) GetSendQuota(data []byte) (uint64, error)

type MethodReward

type MethodReward struct {
}

func (*MethodReward) DoReceive

func (p *MethodReward) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodReward) DoSend

func (p *MethodReward) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

get reward of generating snapshot block

func (*MethodReward) GetFee

func (p *MethodReward) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodReward) GetRefundData

func (p *MethodReward) GetRefundData() ([]byte, bool)

func (*MethodReward) GetSendQuota

func (p *MethodReward) GetSendQuota(data []byte) (uint64, error)

type MethodTransferOwner added in v1.3.0

type MethodTransferOwner struct{}

func (*MethodTransferOwner) DoReceive added in v1.3.0

func (p *MethodTransferOwner) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodTransferOwner) DoSend added in v1.3.0

func (p *MethodTransferOwner) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

func (*MethodTransferOwner) GetFee added in v1.3.0

func (p *MethodTransferOwner) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodTransferOwner) GetRefundData added in v1.3.0

func (p *MethodTransferOwner) GetRefundData() ([]byte, bool)

func (*MethodTransferOwner) GetSendQuota

func (p *MethodTransferOwner) GetSendQuota(data []byte) (uint64, error)

type MethodUpdateRegistration

type MethodUpdateRegistration struct {
}

func (*MethodUpdateRegistration) DoReceive

func (p *MethodUpdateRegistration) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodUpdateRegistration) DoSend

update registration info

func (*MethodUpdateRegistration) GetFee

func (p *MethodUpdateRegistration) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodUpdateRegistration) GetRefundData

func (p *MethodUpdateRegistration) GetRefundData() ([]byte, bool)

func (*MethodUpdateRegistration) GetSendQuota

func (p *MethodUpdateRegistration) GetSendQuota(data []byte) (uint64, error)

type MethodVote

type MethodVote struct {
}

func (*MethodVote) DoReceive

func (p *MethodVote) DoReceive(db vm_db.VmDb, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock, vm vmEnvironment) ([]*ledger.AccountBlock, error)

func (*MethodVote) DoSend

func (p *MethodVote) DoSend(db vm_db.VmDb, block *ledger.AccountBlock) error

vote for a super node of a consensus group

func (*MethodVote) GetFee

func (p *MethodVote) GetFee(block *ledger.AccountBlock) (*big.Int, error)

func (*MethodVote) GetRefundData

func (p *MethodVote) GetRefundData() ([]byte, bool)

func (*MethodVote) GetSendQuota

func (p *MethodVote) GetSendQuota(data []byte) (uint64, error)

type NodeConfig

type NodeConfig struct {
	// contains filtered or unexported fields
}

type Reward

type Reward struct {
	VoteReward       *big.Int
	BlockReward      *big.Int
	TotalReward      *big.Int
	BlockNum         uint64
	ExpectedBlockNum uint64
}

func CalcReward

func CalcReward(reader util.ConsensusReader, db vm_db.VmDb, old *types.Registration, current *ledger.SnapshotBlock) (startTime int64, endTime int64, reward *Reward, drained bool, err error)

func (*Reward) Add

func (r *Reward) Add(a *Reward)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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