Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
163efeb9
Commit
163efeb9
authored
Dec 19, 2018
by
hxzqlh
Committed by
33cn
Dec 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ci
parent
42d6de72
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
55 additions
and
41 deletions
+55
-41
echo.go
plugin/dapp/echo/commands/echo.go
+2
-1
check.go
plugin/dapp/echo/executor/check.go
+1
-1
echo.go
plugin/dapp/echo/executor/echo.go
+9
-6
exec.go
plugin/dapp/echo/executor/exec.go
+2
-0
exec_del_local.go
plugin/dapp/echo/executor/exec_del_local.go
+4
-4
exec_local.go
plugin/dapp/echo/executor/exec_local.go
+4
-4
query.go
plugin/dapp/echo/executor/query.go
+3
-0
rpc.go
plugin/dapp/echo/rpc/rpc.go
+4
-3
echo.go
plugin/dapp/echo/types/echo/echo.go
+10
-7
tx.go
plugin/dapp/echo/types/echo/tx.go
+2
-1
types.go
plugin/dapp/echo/types/echo/types.go
+14
-14
No files found.
plugin/dapp/echo/commands/echo.go
View file @
163efeb9
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
// 本执行器的命令行初始化总入口
//
EchoCmd
本执行器的命令行初始化总入口
func
EchoCmd
()
*
cobra
.
Command
{
func
EchoCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"echo"
,
Use
:
"echo"
,
...
@@ -24,6 +24,7 @@ func EchoCmd() *cobra.Command {
...
@@ -24,6 +24,7 @@ func EchoCmd() *cobra.Command {
return
cmd
return
cmd
}
}
// QueryCmd query 命令
func
QueryCmd
()
*
cobra
.
Command
{
func
QueryCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"query"
,
Use
:
"query"
,
...
...
plugin/dapp/echo/executor/check.go
View file @
163efeb9
...
@@ -2,7 +2,7 @@ package executor
...
@@ -2,7 +2,7 @@ package executor
import
"github.com/33cn/chain33/types"
import
"github.com/33cn/chain33/types"
// 本执行器不做任何校验
//
CheckTx
本执行器不做任何校验
func
(
h
*
Echo
)
CheckTx
(
tx
*
types
.
Transaction
,
index
int
)
error
{
func
(
h
*
Echo
)
CheckTx
(
tx
*
types
.
Transaction
,
index
int
)
error
{
return
nil
return
nil
}
}
plugin/dapp/echo/executor/echo.go
View file @
163efeb9
...
@@ -7,26 +7,29 @@ import (
...
@@ -7,26 +7,29 @@ import (
)
)
var
(
var
(
//
执行交易生成的数据KEY
//
KeyPrefixPing ping 前缀
KeyPrefixPing
=
"mavl-echo-ping:%s"
KeyPrefixPing
=
"mavl-echo-ping:%s"
// KeyPrefixPang pang 前缀
KeyPrefixPang
=
"mavl-echo-pang:%s"
KeyPrefixPang
=
"mavl-echo-pang:%s"
// 本地执行生成的数据KEY
// KeyPrefixPingLocal local ping 前缀
KeyPrefixPingLocal
=
"LODB-echo-ping:%s"
KeyPrefixPingLocal
=
"LODB-echo-ping:%s"
// KeyPrefixPangLocal local pang 前缀
KeyPrefixPangLocal
=
"LODB-echo-pang:%s"
KeyPrefixPangLocal
=
"LODB-echo-pang:%s"
)
)
// 初始化时通过反射获取本执行器的方法列表
//
init
初始化时通过反射获取本执行器的方法列表
func
init
()
{
func
init
()
{
ety
:=
types
.
LoadExecutorType
(
echotypes
.
EchoX
)
ety
:=
types
.
LoadExecutorType
(
echotypes
.
EchoX
)
ety
.
InitFuncList
(
types
.
ListMethod
(
&
Echo
{}))
ety
.
InitFuncList
(
types
.
ListMethod
(
&
Echo
{}))
}
}
//本执行器的初始化动作,向系统注册本执行器,这里生效高度暂写为0
//
Init
本执行器的初始化动作,向系统注册本执行器,这里生效高度暂写为0
func
Init
(
name
string
,
sub
[]
byte
)
{
func
Init
(
name
string
,
sub
[]
byte
)
{
dapp
.
Register
(
echotypes
.
EchoX
,
newEcho
,
0
)
dapp
.
Register
(
echotypes
.
EchoX
,
newEcho
,
0
)
}
}
// 定义执行器对象
//
Echo
定义执行器对象
type
Echo
struct
{
type
Echo
struct
{
dapp
.
DriverBase
dapp
.
DriverBase
}
}
...
@@ -39,7 +42,7 @@ func newEcho() dapp.Driver {
...
@@ -39,7 +42,7 @@ func newEcho() dapp.Driver {
return
c
return
c
}
}
// 返回本执行器驱动名称
//
GetDriverName
返回本执行器驱动名称
func
(
h
*
Echo
)
GetDriverName
()
string
{
func
(
h
*
Echo
)
GetDriverName
()
string
{
return
echotypes
.
EchoX
return
echotypes
.
EchoX
}
}
plugin/dapp/echo/executor/exec.go
View file @
163efeb9
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
echotypes
"github.com/33cn/plugin/plugin/dapp/echo/types/echo"
echotypes
"github.com/33cn/plugin/plugin/dapp/echo/types/echo"
)
)
// Exec_Ping 执行 ping 类型交易
func
(
h
*
Echo
)
Exec_Ping
(
ping
*
echotypes
.
Ping
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
h
*
Echo
)
Exec_Ping
(
ping
*
echotypes
.
Ping
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
msg
:=
ping
.
Msg
msg
:=
ping
.
Msg
res
:=
fmt
.
Sprintf
(
"%s, ping ping ping!"
,
msg
)
res
:=
fmt
.
Sprintf
(
"%s, ping ping ping!"
,
msg
)
...
@@ -17,6 +18,7 @@ func (h *Echo) Exec_Ping(ping *echotypes.Ping, tx *types.Transaction, index int)
...
@@ -17,6 +18,7 @@ func (h *Echo) Exec_Ping(ping *echotypes.Ping, tx *types.Transaction, index int)
return
receipt
,
nil
return
receipt
,
nil
}
}
// Exec_Pang 执行 pang 类型交易
func
(
h
*
Echo
)
Exec_Pang
(
ping
*
echotypes
.
Pang
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
h
*
Echo
)
Exec_Pang
(
ping
*
echotypes
.
Pang
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
msg
:=
ping
.
Msg
msg
:=
ping
.
Msg
res
:=
fmt
.
Sprintf
(
"%s, pang pang pang!"
,
msg
)
res
:=
fmt
.
Sprintf
(
"%s, pang pang pang!"
,
msg
)
...
...
plugin/dapp/echo/executor/exec_del_local.go
View file @
163efeb9
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
echotypes
"github.com/33cn/plugin/plugin/dapp/echo/types/echo"
echotypes
"github.com/33cn/plugin/plugin/dapp/echo/types/echo"
)
)
// 交易执行成功,将本消息对应的数值减1
//
ExecDelLocal_Ping
交易执行成功,将本消息对应的数值减1
func
(
h
*
Echo
)
ExecDelLocal_Ping
(
ping
*
echotypes
.
Ping
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
h
*
Echo
)
ExecDelLocal_Ping
(
ping
*
echotypes
.
Ping
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
// 这里简化处理,不做基本的零值及错误检查了
// 这里简化处理,不做基本的零值及错误检查了
var
pingLog
echotypes
.
PingLog
var
pingLog
echotypes
.
PingLog
...
@@ -19,7 +19,7 @@ func (h *Echo) ExecDelLocal_Ping(ping *echotypes.Ping, tx *types.Transaction, re
...
@@ -19,7 +19,7 @@ func (h *Echo) ExecDelLocal_Ping(ping *echotypes.Ping, tx *types.Transaction, re
}
}
types
.
Decode
(
oldValue
,
&
pingLog
)
types
.
Decode
(
oldValue
,
&
pingLog
)
if
pingLog
.
Count
>
0
{
if
pingLog
.
Count
>
0
{
pingLog
.
Count
-=
1
pingLog
.
Count
--
}
}
val
:=
types
.
Encode
(
&
pingLog
)
val
:=
types
.
Encode
(
&
pingLog
)
if
pingLog
.
Count
==
0
{
if
pingLog
.
Count
==
0
{
...
@@ -29,7 +29,7 @@ func (h *Echo) ExecDelLocal_Ping(ping *echotypes.Ping, tx *types.Transaction, re
...
@@ -29,7 +29,7 @@ func (h *Echo) ExecDelLocal_Ping(ping *echotypes.Ping, tx *types.Transaction, re
return
&
types
.
LocalDBSet
{
KV
:
kv
},
nil
return
&
types
.
LocalDBSet
{
KV
:
kv
},
nil
}
}
// 交易执行成功,将本消息对应的数值减1
//
ExecDelLocal_Pang
交易执行成功,将本消息对应的数值减1
func
(
h
*
Echo
)
ExecDelLocal_Pang
(
ping
*
echotypes
.
Pang
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
h
*
Echo
)
ExecDelLocal_Pang
(
ping
*
echotypes
.
Pang
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
// 这里简化处理,不做基本的零值及错误检查了
// 这里简化处理,不做基本的零值及错误检查了
var
pangLog
echotypes
.
PangLog
var
pangLog
echotypes
.
PangLog
...
@@ -41,7 +41,7 @@ func (h *Echo) ExecDelLocal_Pang(ping *echotypes.Pang, tx *types.Transaction, re
...
@@ -41,7 +41,7 @@ func (h *Echo) ExecDelLocal_Pang(ping *echotypes.Pang, tx *types.Transaction, re
}
}
types
.
Decode
(
oldValue
,
&
pangLog
)
types
.
Decode
(
oldValue
,
&
pangLog
)
if
pangLog
.
Count
>
0
{
if
pangLog
.
Count
>
0
{
pangLog
.
Count
-=
1
pangLog
.
Count
--
}
}
val
:=
types
.
Encode
(
&
pangLog
)
val
:=
types
.
Encode
(
&
pangLog
)
if
pangLog
.
Count
==
0
{
if
pangLog
.
Count
==
0
{
...
...
plugin/dapp/echo/executor/exec_local.go
View file @
163efeb9
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
echotypes
"github.com/33cn/plugin/plugin/dapp/echo/types/echo"
echotypes
"github.com/33cn/plugin/plugin/dapp/echo/types/echo"
)
)
// 交易执行成功,将本消息对应的数值加1
//
ExecLocal_Ping
交易执行成功,将本消息对应的数值加1
func
(
h
*
Echo
)
ExecLocal_Ping
(
ping
*
echotypes
.
Ping
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
h
*
Echo
)
ExecLocal_Ping
(
ping
*
echotypes
.
Ping
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
// 这里简化处理,不做基本的零值及错误检查了
// 这里简化处理,不做基本的零值及错误检查了
var
pingLog
echotypes
.
PingLog
var
pingLog
echotypes
.
PingLog
...
@@ -20,12 +20,12 @@ func (h *Echo) ExecLocal_Ping(ping *echotypes.Ping, tx *types.Transaction, recei
...
@@ -20,12 +20,12 @@ func (h *Echo) ExecLocal_Ping(ping *echotypes.Ping, tx *types.Transaction, recei
if
err
==
nil
{
if
err
==
nil
{
types
.
Decode
(
oldValue
,
&
pingLog
)
types
.
Decode
(
oldValue
,
&
pingLog
)
}
}
pingLog
.
Count
+=
1
pingLog
.
Count
++
kv
:=
[]
*
types
.
KeyValue
{{
Key
:
localKey
,
Value
:
types
.
Encode
(
&
pingLog
)}}
kv
:=
[]
*
types
.
KeyValue
{{
Key
:
localKey
,
Value
:
types
.
Encode
(
&
pingLog
)}}
return
&
types
.
LocalDBSet
{
KV
:
kv
},
nil
return
&
types
.
LocalDBSet
{
KV
:
kv
},
nil
}
}
// 交易执行成功,将本消息对应的数值加1
//
ExecLocal_Pang
交易执行成功,将本消息对应的数值加1
func
(
h
*
Echo
)
ExecLocal_Pang
(
ping
*
echotypes
.
Pang
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
h
*
Echo
)
ExecLocal_Pang
(
ping
*
echotypes
.
Pang
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
// 这里简化处理,不做基本的零值及错误检查了
// 这里简化处理,不做基本的零值及错误检查了
var
pangLog
echotypes
.
PangLog
var
pangLog
echotypes
.
PangLog
...
@@ -38,7 +38,7 @@ func (h *Echo) ExecLocal_Pang(ping *echotypes.Pang, tx *types.Transaction, recei
...
@@ -38,7 +38,7 @@ func (h *Echo) ExecLocal_Pang(ping *echotypes.Pang, tx *types.Transaction, recei
if
err
==
nil
{
if
err
==
nil
{
types
.
Decode
(
oldValue
,
&
pangLog
)
types
.
Decode
(
oldValue
,
&
pangLog
)
}
}
pangLog
.
Count
+=
1
pangLog
.
Count
++
kv
:=
[]
*
types
.
KeyValue
{{
Key
:
localKey
,
Value
:
types
.
Encode
(
&
pangLog
)}}
kv
:=
[]
*
types
.
KeyValue
{{
Key
:
localKey
,
Value
:
types
.
Encode
(
&
pangLog
)}}
return
&
types
.
LocalDBSet
{
KV
:
kv
},
nil
return
&
types
.
LocalDBSet
{
KV
:
kv
},
nil
}
}
plugin/dapp/echo/executor/query.go
View file @
163efeb9
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
echotypes
"github.com/33cn/plugin/plugin/dapp/echo/types/echo"
echotypes
"github.com/33cn/plugin/plugin/dapp/echo/types/echo"
)
)
// Query_GetPing 查询 ping 次数
func
(
h
*
Echo
)
Query_GetPing
(
in
*
echotypes
.
Query
)
(
types
.
Message
,
error
)
{
func
(
h
*
Echo
)
Query_GetPing
(
in
*
echotypes
.
Query
)
(
types
.
Message
,
error
)
{
var
pingLog
echotypes
.
PingLog
var
pingLog
echotypes
.
PingLog
localKey
:=
[]
byte
(
fmt
.
Sprintf
(
KeyPrefixPingLocal
,
in
.
Msg
))
localKey
:=
[]
byte
(
fmt
.
Sprintf
(
KeyPrefixPingLocal
,
in
.
Msg
))
...
@@ -18,6 +19,8 @@ func (h *Echo) Query_GetPing(in *echotypes.Query) (types.Message, error) {
...
@@ -18,6 +19,8 @@ func (h *Echo) Query_GetPing(in *echotypes.Query) (types.Message, error) {
res
:=
echotypes
.
QueryResult
{
Msg
:
in
.
Msg
,
Count
:
pingLog
.
Count
}
res
:=
echotypes
.
QueryResult
{
Msg
:
in
.
Msg
,
Count
:
pingLog
.
Count
}
return
&
res
,
nil
return
&
res
,
nil
}
}
// Query_GetPang 查询 pang 次数
func
(
h
*
Echo
)
Query_GetPang
(
in
*
echotypes
.
Query
)
(
types
.
Message
,
error
)
{
func
(
h
*
Echo
)
Query_GetPang
(
in
*
echotypes
.
Query
)
(
types
.
Message
,
error
)
{
var
pangLog
echotypes
.
PangLog
var
pangLog
echotypes
.
PangLog
localKey
:=
[]
byte
(
fmt
.
Sprintf
(
KeyPrefixPangLocal
,
in
.
Msg
))
localKey
:=
[]
byte
(
fmt
.
Sprintf
(
KeyPrefixPangLocal
,
in
.
Msg
))
...
...
plugin/dapp/echo/rpc/rpc.go
View file @
163efeb9
...
@@ -8,7 +8,7 @@ import (
...
@@ -8,7 +8,7 @@ import (
echotypes
"github.com/33cn/plugin/plugin/dapp/echo/types/echo"
echotypes
"github.com/33cn/plugin/plugin/dapp/echo/types/echo"
)
)
// 对外提供服务的RPC接口总体定义
//
Jrpc
对外提供服务的RPC接口总体定义
type
Jrpc
struct
{
type
Jrpc
struct
{
cli
*
channelClient
cli
*
channelClient
}
}
...
@@ -18,13 +18,14 @@ type channelClient struct {
...
@@ -18,13 +18,14 @@ type channelClient struct {
rpctypes
.
ChannelClient
rpctypes
.
ChannelClient
}
}
// Init 注册 rpc 接口
func
Init
(
name
string
,
s
rpctypes
.
RPCServer
)
{
func
Init
(
name
string
,
s
rpctypes
.
RPCServer
)
{
cli
:=
&
channelClient
{}
cli
:=
&
channelClient
{}
// 为了简单起见,这里只注册Jrpc,如果提供grpc的话也在这里注册
// 为了简单起见,这里只注册Jrpc,如果提供grpc的话也在这里注册
cli
.
Init
(
name
,
s
,
&
Jrpc
{
cli
:
cli
},
nil
)
cli
.
Init
(
name
,
s
,
&
Jrpc
{
cli
:
cli
},
nil
)
}
}
// 本合约的查询操作可以使用通用的Query接口,这里单独封装rpc的Query接口只是为了说明实现方式
//
QueryPing
本合约的查询操作可以使用通用的Query接口,这里单独封装rpc的Query接口只是为了说明实现方式
// 接收客户端请求,并调用本地具体实现逻辑,然后返回结果
// 接收客户端请求,并调用本地具体实现逻辑,然后返回结果
func
(
c
*
Jrpc
)
QueryPing
(
param
*
echotypes
.
Query
,
result
*
interface
{})
error
{
func
(
c
*
Jrpc
)
QueryPing
(
param
*
echotypes
.
Query
,
result
*
interface
{})
error
{
if
param
==
nil
{
if
param
==
nil
{
...
@@ -39,7 +40,7 @@ func (c *Jrpc) QueryPing(param *echotypes.Query, result *interface{}) error {
...
@@ -39,7 +40,7 @@ func (c *Jrpc) QueryPing(param *echotypes.Query, result *interface{}) error {
return
nil
return
nil
}
}
// 本地具体实现逻辑
//
QueryPing
本地具体实现逻辑
func
(
c
*
channelClient
)
QueryPing
(
ctx
context
.
Context
,
queryParam
*
echotypes
.
Query
)
(
types
.
Message
,
error
)
{
func
(
c
*
channelClient
)
QueryPing
(
ctx
context
.
Context
,
queryParam
*
echotypes
.
Query
)
(
types
.
Message
,
error
)
{
return
c
.
Query
(
echotypes
.
EchoX
,
"GetPing"
,
queryParam
)
return
c
.
Query
(
echotypes
.
EchoX
,
"GetPing"
,
queryParam
)
}
}
plugin/dapp/echo/types/echo/echo.go
View file @
163efeb9
...
@@ -10,22 +10,23 @@ import (
...
@@ -10,22 +10,23 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
)
)
func
(
e
EchoType
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
// CreateTx 创建交易
func
(
e
*
Type
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
elog
.
Debug
(
"echo.CreateTx"
,
"action"
,
action
)
elog
.
Debug
(
"echo.CreateTx"
,
"action"
,
action
)
// 只接受ping/pang两种交易操作
// 只接受ping/pang两种交易操作
if
action
==
"ping"
||
action
==
"pang"
{
if
action
==
"ping"
||
action
==
"pang"
{
var
param
Echo
Tx
var
param
Tx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
err
:=
json
.
Unmarshal
(
message
,
&
param
)
if
err
!=
nil
{
if
err
!=
nil
{
elog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
elog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
return
createPingTx
(
action
,
&
param
)
return
createPingTx
(
action
,
&
param
)
}
else
{
return
nil
,
types
.
ErrNotSupport
}
}
return
nil
,
types
.
ErrNotSupport
}
}
func
createPingTx
(
op
string
,
parm
*
EchoTx
)
(
*
types
.
Transaction
,
error
)
{
func
createPingTx
(
op
string
,
parm
*
Tx
)
(
*
types
.
Transaction
,
error
)
{
var
action
*
EchoAction
var
action
*
EchoAction
var
err
error
var
err
error
if
strings
.
EqualFold
(
op
,
"ping"
)
{
if
strings
.
EqualFold
(
op
,
"ping"
)
{
...
@@ -44,7 +45,8 @@ func createPingTx(op string, parm *EchoTx) (*types.Transaction, error) {
...
@@ -44,7 +45,8 @@ func createPingTx(op string, parm *EchoTx) (*types.Transaction, error) {
}
}
return
tx
,
nil
return
tx
,
nil
}
}
func
getPingAction
(
parm
*
EchoTx
)
(
*
EchoAction
,
error
)
{
func
getPingAction
(
parm
*
Tx
)
(
*
EchoAction
,
error
)
{
pingAction
:=
&
Ping
{
Msg
:
parm
.
Message
}
pingAction
:=
&
Ping
{
Msg
:
parm
.
Message
}
action
:=
&
EchoAction
{
action
:=
&
EchoAction
{
Value
:
&
EchoAction_Ping
{
Ping
:
pingAction
},
Value
:
&
EchoAction_Ping
{
Ping
:
pingAction
},
...
@@ -52,7 +54,8 @@ func getPingAction(parm *EchoTx) (*EchoAction, error) {
...
@@ -52,7 +54,8 @@ func getPingAction(parm *EchoTx) (*EchoAction, error) {
}
}
return
action
,
nil
return
action
,
nil
}
}
func
getPangAction
(
parm
*
EchoTx
)
(
*
EchoAction
,
error
)
{
func
getPangAction
(
parm
*
Tx
)
(
*
EchoAction
,
error
)
{
pangAction
:=
&
Pang
{
Msg
:
parm
.
Message
}
pangAction
:=
&
Pang
{
Msg
:
parm
.
Message
}
action
:=
&
EchoAction
{
action
:=
&
EchoAction
{
Value
:
&
EchoAction_Pang
{
Pang
:
pangAction
},
Value
:
&
EchoAction_Pang
{
Pang
:
pangAction
},
...
...
plugin/dapp/echo/types/echo/tx.go
View file @
163efeb9
package
echo
package
echo
type
EchoTx
struct
{
// Tx echo 交易结构
type
Tx
struct
{
Message
string
`json:"msg"`
Message
string
`json:"msg"`
}
}
plugin/dapp/echo/types/echo/types.go
View file @
163efeb9
...
@@ -20,7 +20,7 @@ const (
...
@@ -20,7 +20,7 @@ const (
)
)
var
(
var
(
// 本执行器名称
//
EchoX
本执行器名称
EchoX
=
"echo"
EchoX
=
"echo"
// 定义本执行器支持的Action对应关系
// 定义本执行器支持的Action对应关系
actionName
=
map
[
string
]
int32
{
actionName
=
map
[
string
]
int32
{
...
@@ -42,34 +42,34 @@ func init() {
...
@@ -42,34 +42,34 @@ func init() {
types
.
RegistorExecutor
(
EchoX
,
NewType
())
types
.
RegistorExecutor
(
EchoX
,
NewType
())
}
}
// 定义本执行器类型
//
Type
定义本执行器类型
type
Echo
Type
struct
{
type
Type
struct
{
types
.
ExecTypeBase
types
.
ExecTypeBase
}
}
// 初始化本执行器类型
//
NewType
初始化本执行器类型
func
NewType
()
*
Echo
Type
{
func
NewType
()
*
Type
{
c
:=
&
Echo
Type
{}
c
:=
&
Type
{}
c
.
SetChild
(
c
)
c
.
SetChild
(
c
)
return
c
return
c
}
}
// 返回本执行器的负载类型
//
GetPayload
返回本执行器的负载类型
func
(
b
*
Echo
Type
)
GetPayload
()
types
.
Message
{
func
(
b
*
Type
)
GetPayload
()
types
.
Message
{
return
&
EchoAction
{}
return
&
EchoAction
{}
}
}
// 返回本执行器名称
//
GetName
返回本执行器名称
func
(
b
*
Echo
Type
)
GetName
()
string
{
func
(
b
*
Type
)
GetName
()
string
{
return
EchoX
return
EchoX
}
}
// 返回本执行器中的action字典,支持双向查找
//
GetTypeMap
返回本执行器中的action字典,支持双向查找
func
(
b
*
Echo
Type
)
GetTypeMap
()
map
[
string
]
int32
{
func
(
b
*
Type
)
GetTypeMap
()
map
[
string
]
int32
{
return
actionName
return
actionName
}
}
// 返回本执行器的日志类型信息,用于rpc解析日志数据
//
GetLogMap
返回本执行器的日志类型信息,用于rpc解析日志数据
func
(
b
*
Echo
Type
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
func
(
b
*
Type
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
logInfo
return
logInfo
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment