contracts

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RegisterGas               uint64 = 62200
	UpdateRegistrationGas     uint64 = 62200
	CancelRegisterGas         uint64 = 83200
	RewardGas                 uint64 = 238800
	VoteGas                   uint64 = 62000
	CancelVoteGas             uint64 = 62000
	PledgeGas                 uint64 = 21000
	CancelPledgeGas           uint64 = 21000
	CreateConsensusGroupGas   uint64 = 62200
	CancelConsensusGroupGas   uint64 = 83200
	ReCreateConsensusGroupGas uint64 = 62200
	MintageGas                uint64 = 83200
	MintageCancelPledgeGas    uint64 = 83200
	MintGas                   uint64 = 104525
	IssueGas                  uint64 = 69325
	BurnGas                   uint64 = 48837
	TransferOwnerGas          uint64 = 58981
	ChangeTokenTypeGas        uint64 = 63125

	RewardDayLimit uint64 = 90
)

Variables

View Source
var (
	ContractsParamsTest = ContractsParams{
		MinPledgeHeight:                  1,
		CreateConsensusGroupPledgeHeight: 1,
		MintagePledgeHeight:              1,
		RewardEndTimeLimit:               75,
		RewardTimeUnit:                   75 * 2,
	}
	ContractsParamsMainNet = ContractsParams{
		MinPledgeHeight:                  3600 * 24 * 3,
		CreateConsensusGroupPledgeHeight: 3600 * 24 * 3,
		MintagePledgeHeight:              3600 * 24 * 30 * 3,
		RewardEndTimeLimit:               3600 * 24,
		RewardTimeUnit:                   1152 * 75,
	}
)
View Source
var SimpleCountingRuleList = map[cabi.ConditionCode]createConsensusGroupCondition{
	cabi.RegisterConditionOfPledge: &registerConditionOfPledge{},
	cabi.VoteConditionOfDefault:    &voteConditionOfDefault{},
	cabi.VoteConditionOfBalance:    &voteConditionOfKeepToken{},
}

Functions

func CalcMinRewardTime

func CalcMinRewardTime(registration *types.Registration, genesisTime int64, periodTime uint64) int64

func CheckCreateConsensusGroupData

func CheckCreateConsensusGroupData(db vmctxt_interface.VmDatabase, param *types.ConsensusGroupInfo) error

func CheckMintToken added in v1.3.0

func CheckMintToken(param cabi.ParamMintage) error

func CheckToken

func CheckToken(param cabi.ParamMintage) error

func IndexToTime

func IndexToTime(index uint64, genesisTime int64, periodTime uint64) int64

func InitContractsConfig

func InitContractsConfig(isTestParam bool)

func IsExistGid

func IsExistGid(db vmctxt_interface.VmDatabase, gid types.Gid) bool

Types

type ContractsParams

type ContractsParams struct {
	MinPledgeHeight                  uint64 // Minimum pledge height
	CreateConsensusGroupPledgeHeight uint64 // Pledge height for registering to be a super node of snapshot group and common delegate group
	MintagePledgeHeight              uint64 // Pledge height for mintage if choose to pledge instead of destroy vite token
	RewardEndTimeLimit               uint64 // Cannot get snapshot block reward of current few blocks, for latest snapshot block could be reverted
	RewardTimeUnit                   uint64
}

type MethodBurn added in v1.3.0

type MethodBurn struct{}

func (*MethodBurn) DoReceive added in v1.3.0

func (p *MethodBurn) DoReceive(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock) ([]*SendBlock, error)

func (*MethodBurn) DoSend added in v1.3.0

func (p *MethodBurn) DoSend(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, quotaLeft uint64) (uint64, error)

func (*MethodBurn) GetFee added in v1.3.0

func (*MethodBurn) GetQuota added in v1.3.0

func (p *MethodBurn) GetQuota() uint64

func (*MethodBurn) GetRefundData added in v1.3.0

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

type MethodCancelConsensusGroup

type MethodCancelConsensusGroup struct{}

func (*MethodCancelConsensusGroup) DoReceive

func (*MethodCancelConsensusGroup) DoSend

Cancel consensus group and get pledge back. A canceled consensus group(no-active) will not generate contract blocks after cancel receive block is confirmed. Consensus group name is kept even if canceled.

func (*MethodCancelConsensusGroup) GetFee

func (*MethodCancelConsensusGroup) GetQuota added in v1.3.0

func (p *MethodCancelConsensusGroup) GetQuota() uint64

func (*MethodCancelConsensusGroup) GetRefundData

func (p *MethodCancelConsensusGroup) GetRefundData() []byte

type MethodCancelPledge

type MethodCancelPledge struct{}

func (*MethodCancelPledge) DoReceive

func (*MethodCancelPledge) DoSend

cancel pledge ViteToken

func (*MethodCancelPledge) GetFee

func (*MethodCancelPledge) GetQuota added in v1.3.0

func (p *MethodCancelPledge) GetQuota() uint64

func (*MethodCancelPledge) GetRefundData

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

type MethodCancelRegister

type MethodCancelRegister struct {
}

func (*MethodCancelRegister) DoReceive

func (*MethodCancelRegister) DoSend

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

func (*MethodCancelRegister) GetFee

func (*MethodCancelRegister) GetQuota added in v1.3.0

func (p *MethodCancelRegister) GetQuota() uint64

func (*MethodCancelRegister) GetRefundData

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

type MethodCancelVote

type MethodCancelVote struct {
}

func (*MethodCancelVote) DoReceive

func (*MethodCancelVote) DoSend

func (p *MethodCancelVote) DoSend(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, quotaLeft uint64) (uint64, error)

cancel vote for a super node of a consensus group

func (*MethodCancelVote) GetFee

func (*MethodCancelVote) GetQuota added in v1.3.0

func (p *MethodCancelVote) GetQuota() uint64

func (*MethodCancelVote) GetRefundData

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

type MethodChangeTokenType added in v1.3.0

type MethodChangeTokenType struct{}

func (*MethodChangeTokenType) DoReceive added in v1.3.0

func (*MethodChangeTokenType) DoSend added in v1.3.0

func (*MethodChangeTokenType) GetFee added in v1.3.0

func (*MethodChangeTokenType) GetQuota added in v1.3.0

func (p *MethodChangeTokenType) GetQuota() uint64

func (*MethodChangeTokenType) GetRefundData added in v1.3.0

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

type MethodCreateConsensusGroup

type MethodCreateConsensusGroup struct{}

func (*MethodCreateConsensusGroup) DoReceive

func (*MethodCreateConsensusGroup) DoSend

func (*MethodCreateConsensusGroup) GetFee

func (*MethodCreateConsensusGroup) GetQuota added in v1.3.0

func (p *MethodCreateConsensusGroup) GetQuota() uint64

func (*MethodCreateConsensusGroup) GetRefundData

func (p *MethodCreateConsensusGroup) GetRefundData() []byte

type MethodIssue added in v1.3.0

type MethodIssue struct{}

func (*MethodIssue) DoReceive added in v1.3.0

func (p *MethodIssue) DoReceive(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock) ([]*SendBlock, error)

func (*MethodIssue) DoSend added in v1.3.0

func (p *MethodIssue) DoSend(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, quotaLeft uint64) (uint64, error)

func (*MethodIssue) GetFee added in v1.3.0

func (*MethodIssue) GetQuota added in v1.3.0

func (p *MethodIssue) GetQuota() uint64

func (*MethodIssue) GetRefundData added in v1.3.0

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

type MethodMint added in v1.3.0

type MethodMint struct{}

func (*MethodMint) DoReceive added in v1.3.0

func (p *MethodMint) DoReceive(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock) ([]*SendBlock, error)

func (*MethodMint) DoSend added in v1.3.0

func (p *MethodMint) DoSend(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, quotaLeft uint64) (uint64, error)

func (*MethodMint) GetFee added in v1.3.0

func (*MethodMint) GetQuota added in v1.3.0

func (p *MethodMint) GetQuota() uint64

func (*MethodMint) GetRefundData added in v1.3.0

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

type MethodMintage

type MethodMintage struct{}

func (*MethodMintage) DoReceive

func (p *MethodMintage) DoReceive(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock) ([]*SendBlock, error)

func (*MethodMintage) DoSend

func (p *MethodMintage) DoSend(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, quotaLeft uint64) (uint64, error)

func (*MethodMintage) GetFee

func (*MethodMintage) GetQuota added in v1.3.0

func (p *MethodMintage) GetQuota() uint64

func (*MethodMintage) GetRefundData

func (p *MethodMintage) GetRefundData() []byte

type MethodMintageCancelPledge

type MethodMintageCancelPledge struct{}

func (*MethodMintageCancelPledge) DoReceive

func (*MethodMintageCancelPledge) DoSend

func (*MethodMintageCancelPledge) GetFee

func (*MethodMintageCancelPledge) GetQuota added in v1.3.0

func (p *MethodMintageCancelPledge) GetQuota() uint64

func (*MethodMintageCancelPledge) GetRefundData

func (p *MethodMintageCancelPledge) GetRefundData() []byte

type MethodPledge

type MethodPledge struct{}

func (*MethodPledge) DoReceive

func (p *MethodPledge) DoReceive(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock) ([]*SendBlock, error)

func (*MethodPledge) DoSend

func (p *MethodPledge) DoSend(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, quotaLeft uint64) (uint64, error)

pledge ViteToken for a beneficial to get quota

func (*MethodPledge) GetFee

func (*MethodPledge) GetQuota added in v1.3.0

func (p *MethodPledge) GetQuota() uint64

func (*MethodPledge) GetRefundData

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

type MethodReCreateConsensusGroup

type MethodReCreateConsensusGroup struct{}

func (*MethodReCreateConsensusGroup) DoReceive

func (*MethodReCreateConsensusGroup) DoSend

Pledge again for a canceled consensus group. A consensus group will start generate contract blocks after recreate receive block is confirmed.

func (*MethodReCreateConsensusGroup) GetFee

func (*MethodReCreateConsensusGroup) GetQuota added in v1.3.0

func (p *MethodReCreateConsensusGroup) GetQuota() uint64

func (*MethodReCreateConsensusGroup) GetRefundData

func (p *MethodReCreateConsensusGroup) GetRefundData() []byte

type MethodRegister

type MethodRegister struct {
}

func (*MethodRegister) DoReceive

func (p *MethodRegister) DoReceive(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock) ([]*SendBlock, error)

func (*MethodRegister) DoSend

func (p *MethodRegister) DoSend(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, quotaLeft uint64) (uint64, error)

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

func (*MethodRegister) GetFee

func (*MethodRegister) GetQuota added in v1.3.0

func (p *MethodRegister) GetQuota() uint64

func (*MethodRegister) GetRefundData

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

type MethodReward

type MethodReward struct {
}

func (*MethodReward) DoReceive

func (p *MethodReward) DoReceive(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock) ([]*SendBlock, error)

func (*MethodReward) DoSend

func (p *MethodReward) DoSend(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, quotaLeft uint64) (uint64, error)

get reward of generating snapshot block

func (*MethodReward) GetFee

func (*MethodReward) GetQuota added in v1.3.0

func (p *MethodReward) GetQuota() uint64

func (*MethodReward) GetRefundData

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

type MethodTransferOwner added in v1.3.0

type MethodTransferOwner struct{}

func (*MethodTransferOwner) DoReceive added in v1.3.0

func (*MethodTransferOwner) DoSend added in v1.3.0

func (*MethodTransferOwner) GetFee added in v1.3.0

func (*MethodTransferOwner) GetQuota added in v1.3.0

func (p *MethodTransferOwner) GetQuota() uint64

func (*MethodTransferOwner) GetRefundData added in v1.3.0

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

type MethodUpdateRegistration

type MethodUpdateRegistration struct {
}

func (*MethodUpdateRegistration) DoReceive

func (*MethodUpdateRegistration) DoSend

update registration info

func (*MethodUpdateRegistration) GetFee

func (*MethodUpdateRegistration) GetQuota added in v1.3.0

func (p *MethodUpdateRegistration) GetQuota() uint64

func (*MethodUpdateRegistration) GetRefundData

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

type MethodVote

type MethodVote struct {
}

func (*MethodVote) DoReceive

func (p *MethodVote) DoReceive(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock) ([]*SendBlock, error)

func (*MethodVote) DoSend

func (p *MethodVote) DoSend(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, quotaLeft uint64) (uint64, error)

vote for a super node of a consensus group

func (*MethodVote) GetFee

func (*MethodVote) GetQuota added in v1.3.0

func (p *MethodVote) GetQuota() uint64

func (*MethodVote) GetRefundData

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

type NodeConfig

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

type PrecompiledContractMethod

type PrecompiledContractMethod interface {
	GetFee(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock) (*big.Int, error)
	// calc and use quota, check tx data
	DoSend(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, quotaLeft uint64) (uint64, error)
	// check status, update state
	DoReceive(db vmctxt_interface.VmDatabase, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock) ([]*SendBlock, error)
	// refund data at receive error
	GetRefundData() []byte
	GetQuota() uint64
}

type SendBlock

type SendBlock struct {
	Block     *ledger.AccountBlock
	ToAddress types.Address
	BlockType byte
	Amount    *big.Int
	TokenId   types.TokenTypeId
	Data      []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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