Commit 4b5873d9 authored by 任硕's avatar 任硕 Committed by linj

unfreeze

parent 83795d85
package commands
import "github.com/spf13/cobra"
func Cmd() *cobra.Command {
return nil
}
package executor
// 定期解冻token
package executor
import (
uf "gitlab.33.cn/chain33/chain33/plugin/dapp/unfreeze/types"
"gitlab.33.cn/chain33/chain33/types"
)
func (u *Unfreeze) Exec_Create(payload *uf.GameCreate, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(u, tx, index)
return action.UnfreezeCreate(payload)
}
func (u *Unfreeze) Exec_Cancel(payload *uf.GameCancel, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(u, tx, index)
return action.UnfreezeWithdraw(payload)
}
func (u *Unfreeze) Exec_Terminate(payload *uf.GameClose, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(u, tx, index)
return action.UnfreezeTerminate(payload)
}
package executor
import (
uf "gitlab.33.cn/chain33/chain33/plugin/dapp/unfreeze/types"
"gitlab.33.cn/chain33/chain33/types"
)
func (u *Unfreeze) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
return dbSet, nil
}
func (u *Unfreeze) ExecDelLocal_Create(payload *uf.UnfreezeCreate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return u.execDelLocal(receiptData)
}
func (u *Unfreeze) ExecDelLocal_Withdraw(payload *uf.UnfreezeWithdraw, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return u.execDelLocal(receiptData)
}
func (u *Unfreeze) ExecDelLocal_Terminate(payload *uf.UnfreezeTerminate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return u.execDelLocal(receiptData)
}
package executor
import (
uf "gitlab.33.cn/chain33/chain33/plugin/dapp/unfreeze/types"
"gitlab.33.cn/chain33/chain33/types"
)
func (u *Unfreeze) execLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
return dbSet, nil
}
func (u *Unfreeze) ExecLocal_Create(payload *uf.UnfreezeCreate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return u.execLocal(receiptData)
}
func (u *Unfreeze) ExecLocal_Withdraw(payload *uf.UnfreezeWithdraw, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return u.execLocal(receiptData)
}
func (u *Unfreeze) ExecLocal_Terminate(payload *uf.UnfreezeTerminate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return u.execLocal(receiptData)
}
package executor
package executor
import (
"fmt"
log "github.com/inconshreveable/log15"
uf "gitlab.33.cn/chain33/chain33/plugin/dapp/unfreeze/types"
drivers "gitlab.33.cn/chain33/chain33/system/dapp"
"gitlab.33.cn/chain33/chain33/types"
)
var uflog = log.New("module", "execs.unfreeze")
var driverName = uf.UnfreezeX
func init() {
ety := types.LoadExecutorType(driverName)
ety.InitFuncList(types.ListMethod(&Unfreeze{}))
}
func Init(name string) {
drivers.Register(GetName(), newGame, 0)
}
type Unfreeze struct {
drivers.DriverBase
}
func newUnfreeze() drivers.Driver {
t := &Unfreeze{}
t.SetChild(t)
t.SetExecutorType(types.LoadExecutorType(driverName))
return t
}
func GetName() string {
return newUnfreeze().GetName()
}
func (u *Unfreeze) GetDriverName() string {
return driverName
}
func (u *Unfreeze) GetPayloadValue() types.Message {
return &uf.UnfreezeAction{}
}
func (u *Unfreeze) GetTypeMap() map[string]int32 {
return map[string]int32{
"Create": uf.UnfreezeActionCreate,
"Withdraw": uf.UnfreezeActionWithdraw,
"Terminate": uf.UnfreezeActionTerminate,
}
}
package executor
//database opeartion for executor unfreeze
package unfreeze
import (
"gitlab.33.cn/chain33/chain33/plugin/dapp/unfreeze/commands"
uf "gitlab.33.cn/chain33/chain33/plugin/dapp/unfreeze/types"
"gitlab.33.cn/chain33/chain33/plugin/dapp/v/executor"
"gitlab.33.cn/chain33/chain33/pluginmgr"
)
func init() {
pluginmgr.Register(&pluginmgr.PluginBase{
Name: uf.PackageName,
ExecName: executor.GetName(),
Exec: executor.Init,
Cmd: commands.Cmd,
RPC: nil,
})
}
all:
./create_protobuf.sh
#!/bin/sh
protoc --go_out=plugins=grpc:../types ./*.proto
syntax = "proto3";
package types;
message Unfreeze {
//开始时间
int64 startTime = 1;
//币种
string tokenName = 2;
//冻结总额
int64 totalCount = 3;
//发币人地址
string senderAddr = 4;
//收币人地址
string receiverAddr = 5;
//解冻间隔
int64 unfreezeGap = 6;
//解冻方式(百分比;固额) 1 百分比 -> 2 固额
int32 unfreezeMeans = 7;
//解冻数量:若为百分比解冻方式该字段值为百分比乘以100,若为固额该字段值为币数量
int64 unfreezeAmount = 8;
//已解冻次数
int32 withdrawTimes = 9;
}
// message for execs.unfreeze
message UnfreezeAction {
oneof value {
UnfreezeCreate create = 1;
UnfreezeWithdraw withdraw = 2;
UnfreezeTerminate terminate = 3;
}
int32 ty = 10;
}
message UnfreezeCreate {
}
message UnfreezeWithdraw {
}
message UnfreezeTerminate {
}
message ReceiptUnfreeze {
}
package types
//unfreeze action ty
const (
UnfreezeActionCreate = iota + 1
UnfreezeActionWithdraw
UnfreezeActionTerminate
//log for unfreeze
TyLogCreateUnfreeze = 2001 // TODO 修改具体编号
TyLogWithdrawUnfreeze = 2002
TyLogTerminateUnfreeze = 2003
)
//包的名字可以通过配置文件来配置
//建议用github的组织名称,或者用户名字开头, 再加上自己的插件的名字
//如果发生重名,可以通过配置文件修改这些名字
var (
PackageName = "chain33.unfreeze"
RpcName = "Chain33.Unfreeze"
UnfreezeX = "unfreeze"
ExecerGame = []byte(UnfreezeX)
)
const (
Action_CreateUnfreeze = "createUnfreeze"
Action_WithdrawUnfreeze = "withdrawUnfreeze"
Action_TerminateUnfreeze = "terminateUnfreeze"
)
//const (
// FuncName_QueryXXX = "QueryXXX"
//)
package types
package types
import (
"reflect"
log "github.com/inconshreveable/log15"
"gitlab.33.cn/chain33/chain33/types"
)
var name string
var tlog = log.New("module", name)
func init() {
name = UnfreezeX
// init executor type
types.RegistorExecutor(name, &UnfreezeType{})
}
//getRealExecName
func getRealExecName(paraName string) string {
return types.ExecName(paraName + UnfreezeX)
}
func NewType() *UnfreezeType {
c := &UnfreezeType{}
c.SetChild(c)
return c
}
// exec
type UnfreezeType struct {
types.ExecTypeBase
}
func (at *UnfreezeType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogCreateUnfreeze: {reflect.TypeOf(ReceiptUnfreeze{}), "LogCreateUnfreeze"},
TyLogWithdrawUnfreeze: {reflect.TypeOf(ReceiptUnfreeze{}), "LogWithdrawUnfreeze"},
TyLogTerminateUnfreeze: {reflect.TypeOf(ReceiptUnfreeze{}), "LogTerminateUnfreeze"},
}
}
func (g *UnfreezeType) GetPayload() types.Message {
return &UnfreezeAction{}
}
func (g *UnfreezeType) GetTypeMap() map[string]int32 {
return map[string]int32{
"Create": UnfreezeActionCreate,
"Withdraw": UnfreezeActionWithdraw,
"Terminate": UnfreezeActionTerminate,
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment