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
8d517298
Commit
8d517298
authored
Sep 27, 2021
by
harrylee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add broker dapp
parent
614c36d2
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
1463 additions
and
0 deletions
+1463
-0
Makefile
plugin/dapp/broker/cmd/Makefile
+2
-0
build.sh
plugin/dapp/broker/cmd/build.sh
+11
-0
commands.go
plugin/dapp/broker/commands/commands.go
+23
-0
broker.go
plugin/dapp/broker/executor/broker.go
+58
-0
brokerdb.go
plugin/dapp/broker/executor/brokerdb.go
+115
-0
exec.go
plugin/dapp/broker/executor/exec.go
+31
-0
exec_del_local.go
plugin/dapp/broker/executor/exec_del_local.go
+20
-0
exec_local.go
plugin/dapp/broker/executor/exec_local.go
+74
-0
kv.go
plugin/dapp/broker/executor/kv.go
+14
-0
query,go.go
plugin/dapp/broker/executor/query,go.go
+1
-0
tables.go
plugin/dapp/broker/executor/tables.go
+66
-0
plugin.go
plugin/dapp/broker/plugin.go
+23
-0
Makefile
plugin/dapp/broker/proto/Makefile
+2
-0
broker.proto
plugin/dapp/broker/proto/broker.proto
+100
-0
create_protobuf.sh
plugin/dapp/broker/proto/create_protobuf.sh
+4
-0
rpc.go
plugin/dapp/broker/rpc/rpc.go
+7
-0
types.go
plugin/dapp/broker/rpc/types.go
+34
-0
broker.go
plugin/dapp/broker/types/broker.go
+122
-0
broker.pb.go
plugin/dapp/broker/types/broker.pb.go
+745
-0
errors.go
plugin/dapp/broker/types/errors.go
+10
-0
init.go
plugin/dapp/init/init.go
+1
-0
No files found.
plugin/dapp/broker/cmd/Makefile
0 → 100644
View file @
8d517298
all
:
bash build.sh
$(OUT)
$(FLAG)
plugin/dapp/broker/cmd/build.sh
0 → 100644
View file @
8d517298
#!/bin/bash
# 官方ci集成脚本
strpwd
=
$(
pwd
)
strcmd
=
${
strpwd
##*dapp/
}
strapp
=
${
strcmd
%/cmd*
}
OUT_DIR
=
"
${
1
}
/
$strapp
"
#FLAG=$2
mkdir
-p
"
${
OUT_DIR
}
"
cp
./build/
*
"
${
OUT_DIR
}
"
plugin/dapp/broker/commands/commands.go
0 → 100644
View file @
8d517298
/*Package commands implement dapp client commands*/
package
commands
import
(
"github.com/spf13/cobra"
)
/*
* 实现合约对应客户端
*/
// Cmd broker client command
func
Cmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"broker"
,
Short
:
"broker command"
,
Args
:
cobra
.
MinimumNArgs
(
1
),
}
cmd
.
AddCommand
(
//add sub command
)
return
cmd
}
plugin/dapp/broker/executor/broker.go
0 → 100644
View file @
8d517298
package
executor
import
(
log
"github.com/33cn/chain33/common/log/log15"
drivers
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
brokertypes
"github.com/33cn/plugin/plugin/dapp/broker/types"
)
/*
* 执行器相关定义
* 重载基类相关接口
*/
var
(
//日志
elog
=
log
.
New
(
"module"
,
"broker.executor"
)
)
var
driverName
=
brokertypes
.
BrokerX
// Init register dapp
func
Init
(
name
string
,
cfg
*
types
.
Chain33Config
,
sub
[]
byte
)
{
drivers
.
Register
(
cfg
,
GetName
(),
newBroker
,
cfg
.
GetDappFork
(
driverName
,
"Enable"
))
InitExecType
()
}
// InitExecType Init Exec Type
func
InitExecType
()
{
ety
:=
types
.
LoadExecutorType
(
driverName
)
ety
.
InitFuncList
(
types
.
ListMethod
(
&
broker
{}))
}
type
broker
struct
{
drivers
.
DriverBase
}
func
newBroker
()
drivers
.
Driver
{
t
:=
&
broker
{}
t
.
SetChild
(
t
)
t
.
SetExecutorType
(
types
.
LoadExecutorType
(
driverName
))
return
t
}
// GetName get driver name
func
GetName
()
string
{
return
newBroker
()
.
GetName
()
}
func
(
b
*
broker
)
GetDriverName
()
string
{
return
driverName
}
// CheckTx 实现自定义检验交易接口,供框架调用
func
(
b
*
broker
)
CheckTx
(
tx
*
types
.
Transaction
,
index
int
)
error
{
// implement code
return
nil
}
plugin/dapp/broker/executor/brokerdb.go
0 → 100644
View file @
8d517298
package
executor
import
(
"fmt"
"github.com/33cn/chain33/client"
dbm
"github.com/33cn/chain33/common/db"
tab
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/types"
brokertypes
"github.com/33cn/plugin/plugin/dapp/broker/types"
storagetypes
"github.com/33cn/plugin/plugin/dapp/storage/types"
)
//BrokerDB ...
type
BrokerDB
struct
{
api
client
.
QueueProtocolAPI
db
dbm
.
KV
localdb
dbm
.
KV
txhash
[]
byte
fromaddr
string
blocktime
int64
height
int64
index
int
}
func
newBrokerDB
(
b
*
broker
,
tx
*
types
.
Transaction
,
index
int
)
*
BrokerDB
{
hash
:=
tx
.
Hash
()
fromaddr
:=
tx
.
From
()
return
&
BrokerDB
{
b
.
GetAPI
(),
b
.
GetStateDB
(),
b
.
GetLocalDB
(),
hash
,
fromaddr
,
b
.
GetBlockTime
(),
b
.
GetHeight
(),
index
}
}
////GetKVSet ...
//func (b *BrokerDB) GetKVSet() (kvset []*types.KeyValue) {
// kvset = append(kvset, &types.KeyValue{Key: Key(common.ToHex(s.txhash)), Value: types.Encode(payload)})
// return kvset
//}
func
(
b
*
BrokerDB
)
register
(
payload
*
brokertypes
.
Register
)(
*
types
.
Receipt
,
error
){
return
nil
,
nil
}
func
(
b
*
BrokerDB
)
audit
(
payload
*
brokertypes
.
Audit
)(
*
types
.
Receipt
,
error
){
return
nil
,
nil
}
func
(
b
*
BrokerDB
)
updateEventStatus
(
payload
*
brokertypes
.
UpdateEventStatus
)(
*
types
.
Receipt
,
error
){
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
log
:=&
brokertypes
.
ReceiptBrokerLog
{
Value
:&
brokertypes
.
ReceiptBrokerLog_UpdateEventStatus
{
payload
},
Ty
:
brokertypes
.
TyEmitInterchainEventAction
}
receiptlog
:=
&
types
.
ReceiptLog
{
Ty
:
brokertypes
.
TyUpdateEventStatusLog
,
Log
:
types
.
Encode
(
log
)}
receipt
.
Logs
=
append
(
receipt
.
Logs
,
receiptlog
)
return
receipt
,
nil
}
func
(
b
*
BrokerDB
)
emitInterchainEvent
(
payload
*
brokertypes
.
InterchainEvent
)(
*
types
.
Receipt
,
error
){
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
//发布跨链事件 分为1.信息跨链 2.代币跨链,代币跨链需要在这步将所需金额冻结在broker下面
if
payload
.
ReqType
==
brokertypes
.
Req_Type_Storage
{
//校验存在交易是否存在
params
:=&
storagetypes
.
QueryStorage
{
TxHash
:
payload
.
Args
[
0
]}
_
,
err
:=
b
.
api
.
Query
(
storagetypes
.
StorageX
,
payload
.
GetFunc
(),
params
)
if
err
!=
nil
{
return
nil
,
brokertypes
.
ErrBrokerStorageTx
}
log
:=&
brokertypes
.
ReceiptBrokerLog
{
Value
:&
brokertypes
.
ReceiptBrokerLog_EmitInterchainEvent
{
payload
},
Ty
:
brokertypes
.
TyEmitInterchainEventAction
}
receiptlog
:=
&
types
.
ReceiptLog
{
Ty
:
brokertypes
.
TyEmitInterchainEventLog
,
Log
:
types
.
Encode
(
log
)}
receipt
.
Logs
=
append
(
receipt
.
Logs
,
receiptlog
)
}
if
payload
.
ReqType
==
brokertypes
.
Req_Type_Coins
{
//TODO 跨链转账
}
return
receipt
,
nil
}
//根据状态遍历时间列表(可通过定时轮循这个接口,获取跨链时间)
func
findInterChainEventListByStatus
(
localdb
dbm
.
KV
,
status
,
direction
int32
,
primaryKey
string
)
(
*
brokertypes
.
InterchainEventList
,
error
)
{
table
:=
NewInterchainEventTable
(
localdb
)
prefix
:=
[]
byte
(
fmt
.
Sprintf
(
"%d"
,
status
))
var
rows
[]
*
tab
.
Row
var
err
error
if
primaryKey
==
""
{
//第一次查询,默认展示最新得成交记录
rows
,
err
=
table
.
ListIndex
(
"status"
,
prefix
,
nil
,
brokertypes
.
PageSize
,
direction
)
}
else
{
rows
,
err
=
table
.
ListIndex
(
"status"
,
prefix
,
[]
byte
(
primaryKey
),
brokertypes
.
PageSize
,
direction
)
}
if
err
!=
nil
{
elog
.
Error
(
"findInterChainEventListByStatus."
,
"err"
,
err
.
Error
())
return
nil
,
err
}
var
eventList
brokertypes
.
InterchainEventList
for
_
,
row
:=
range
rows
{
event
:=
row
.
Data
.
(
*
brokertypes
.
InterchainEvent
)
eventList
.
List
=
append
(
eventList
.
List
,
event
)
}
//设置主键索引
if
len
(
rows
)
==
int
(
brokertypes
.
PageSize
)
{
eventList
.
PrimaryKey
=
string
(
rows
[
len
(
rows
)
-
1
]
.
Primary
)
}
return
&
eventList
,
nil
}
//根据index查询event
func
findInterChainEventByIndex
(
localdb
dbm
.
KV
,
index
uint64
)(
*
brokertypes
.
InterchainEvent
,
error
){
table
:=
NewInterchainEventTable
(
localdb
)
primaryKey
:=
[]
byte
(
fmt
.
Sprintf
(
"%018d"
,
index
))
row
,
err
:=
table
.
GetData
(
primaryKey
)
if
err
!=
nil
{
return
nil
,
err
}
return
row
.
Data
.
(
*
brokertypes
.
InterchainEvent
),
nil
}
\ No newline at end of file
plugin/dapp/broker/executor/exec.go
0 → 100644
View file @
8d517298
package
executor
import
(
"github.com/33cn/chain33/types"
brokertypes
"github.com/33cn/plugin/plugin/dapp/broker/types"
)
/*
* 实现交易的链上执行接口
* 关键数据上链(statedb)并生成交易回执(log)
*/
func
(
b
*
broker
)
Exec_Register
(
payload
*
brokertypes
.
Register
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
db
:=
newBrokerDB
(
b
,
tx
,
index
)
return
db
.
register
(
payload
)
}
func
(
b
*
broker
)
Exec_Audit
(
payload
*
brokertypes
.
Audit
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
db
:=
newBrokerDB
(
b
,
tx
,
index
)
//implement code 1.授权执行器 2.跨链账户是否需要授权
return
db
.
audit
(
payload
)
}
func
(
b
*
broker
)
Exec_UpdateEventStatus
(
payload
*
brokertypes
.
UpdateEventStatus
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
db
:=
newBrokerDB
(
b
,
tx
,
index
)
return
db
.
updateEventStatus
(
payload
)
}
func
(
b
*
broker
)
Exec_EmitInterchainEvent
(
payload
*
brokertypes
.
InterchainEvent
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
db
:=
newBrokerDB
(
b
,
tx
,
index
)
return
db
.
emitInterchainEvent
(
payload
)
}
plugin/dapp/broker/executor/exec_del_local.go
0 → 100644
View file @
8d517298
package
executor
import
(
"github.com/33cn/chain33/types"
)
/*
* 实现区块回退时本地执行的数据清除
*/
// ExecDelLocal localdb kv数据自动回滚接口
func
(
b
*
broker
)
ExecDelLocal
(
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
kvs
,
err
:=
b
.
DelRollbackKV
(
tx
,
tx
.
Execer
)
if
err
!=
nil
{
return
nil
,
err
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
}
plugin/dapp/broker/executor/exec_local.go
0 → 100644
View file @
8d517298
package
executor
import
(
"fmt"
"github.com/33cn/chain33/types"
brokertypes
"github.com/33cn/plugin/plugin/dapp/broker/types"
)
/*
* 实现交易相关数据本地执行,数据不上链
* 非关键数据,本地存储(localDB), 用于辅助查询,效率高
*/
func
(
b
*
broker
)
ExecLocal_Register
(
payload
*
brokertypes
.
Register
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
//implement code, add customize kv to dbSet...
//auto gen for localdb auto rollback
return
b
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
}
func
(
b
*
broker
)
ExecLocal_Audit
(
payload
*
brokertypes
.
Audit
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
//implement code, add customize kv to dbSet...
//auto gen for localdb auto rollback
return
b
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
}
func
(
b
*
broker
)
ExecLocal_UpdateEventStatus
(
payload
*
brokertypes
.
UpdateEventStatus
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
table
:=
NewInterchainEventTable
(
b
.
GetLocalDB
())
primaryKey
:=
[]
byte
(
fmt
.
Sprintf
(
"%018d"
,
payload
.
Index
))
row
,
err
:=
table
.
GetData
(
primaryKey
)
if
err
!=
nil
{
return
nil
,
err
}
event
:=
row
.
Data
.
(
*
brokertypes
.
InterchainEvent
)
//更新状态
event
.
Status
=
payload
.
Status
table
.
Replace
(
event
)
kvs
,
err
:=
table
.
Save
()
if
err
!=
nil
{
return
nil
,
err
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
b
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
}
func
(
b
*
broker
)
ExecLocal_EmitInterchainEvent
(
payload
*
brokertypes
.
InterchainEvent
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
table
:=
NewInterchainEventTable
(
b
.
GetLocalDB
())
payload
.
Index
=
b
.
GetIndex
(
index
)
table
.
Add
(
payload
)
kvs
,
err
:=
table
.
Save
()
if
err
!=
nil
{
return
nil
,
err
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
b
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
}
//GetIndex get index
func
(
b
*
broker
)
GetIndex
(
index
int
)
uint64
{
return
uint64
(
int
(
b
.
GetHeight
())
*
types
.
MaxTxsPerBlock
+
index
)
}
//当区块回滚时,框架支持自动回滚localdb kv,需要对exec-local返回的kv进行封装
func
(
b
*
broker
)
addAutoRollBack
(
tx
*
types
.
Transaction
,
kv
[]
*
types
.
KeyValue
)
*
types
.
LocalDBSet
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
b
.
AddRollbackKV
(
tx
,
tx
.
Execer
,
kv
)
return
dbSet
}
plugin/dapp/broker/executor/kv.go
0 → 100644
View file @
8d517298
package
executor
/*
* 用户合约存取kv数据时,key值前缀需要满足一定规范
* 即key = keyPrefix + userKey
* 需要字段前缀查询时,使用’-‘作为分割符号
*/
var
(
//KeyPrefixStateDB state db key必须前缀
KeyPrefixStateDB
=
"mavl-broker-"
//KeyPrefixLocalDB local db的key必须前缀
KeyPrefixLocalDB
=
"LODB-broker-"
)
plugin/dapp/broker/executor/query,go.go
0 → 100644
View file @
8d517298
package
executor
plugin/dapp/broker/executor/tables.go
0 → 100644
View file @
8d517298
package
executor
import
(
"fmt"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/types"
ety
"github.com/33cn/plugin/plugin/dapp/broker/types"
)
//重新设计表,list查询全部在跨链事件localdb查询中
var
opt_broker_event
=
&
table
.
Option
{
Prefix
:
KeyPrefixLocalDB
,
Name
:
"broker"
,
Primary
:
"index"
,
Index
:
[]
string
{
"dstChainID"
,
"status"
,
"reqType"
},
}
//InterchainEventRow table meta 结构
type
InterchainEventRow
struct
{
*
ety
.
InterchainEvent
}
//NewInterchainEventRow ...
func
NewInterchainEventRow
()
*
InterchainEventRow
{
return
&
InterchainEventRow
{
&
ety
.
InterchainEvent
{}}
}
//CreateRow ...
func
(
m
*
InterchainEventRow
)
CreateRow
()
*
table
.
Row
{
return
&
table
.
Row
{
Data
:
&
ety
.
InterchainEvent
{}}
}
//SetPayload 设置数据
func
(
m
*
InterchainEventRow
)
SetPayload
(
data
types
.
Message
)
error
{
if
txdata
,
ok
:=
data
.
(
*
ety
.
InterchainEvent
);
ok
{
m
.
InterchainEvent
=
txdata
return
nil
}
return
ety
.
ErrData
}
//Get 按照indexName 查询 indexValue
func
(
m
*
InterchainEventRow
)
Get
(
key
string
)
([]
byte
,
error
)
{
if
key
==
"index"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%018d"
,
m
.
Index
)),
nil
}
else
if
key
==
"dstChainID"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s"
,
m
.
GetDstChainID
())),
nil
}
else
if
key
==
"status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%d"
,
m
.
GetStatus
())),
nil
}
else
if
key
==
"reqType"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%d"
,
m
.
GetReqType
())),
nil
}
return
nil
,
types
.
ErrNotFound
}
//NewInterchainEventTable
func
NewInterchainEventTable
(
kvdb
db
.
KV
)
*
table
.
Table
{
rowmeta
:=
NewInterchainEventRow
()
table
,
err
:=
table
.
NewTable
(
rowmeta
,
kvdb
,
opt_broker_event
)
if
err
!=
nil
{
panic
(
err
)
}
return
table
}
\ No newline at end of file
plugin/dapp/broker/plugin.go
0 → 100644
View file @
8d517298
package
types
import
(
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/plugin/plugin/dapp/broker/commands"
"github.com/33cn/plugin/plugin/dapp/broker/executor"
"github.com/33cn/plugin/plugin/dapp/broker/rpc"
brokertypes
"github.com/33cn/plugin/plugin/dapp/broker/types"
)
/*
* 初始化dapp相关的组件
*/
func
init
()
{
pluginmgr
.
Register
(
&
pluginmgr
.
PluginBase
{
Name
:
brokertypes
.
BrokerX
,
ExecName
:
executor
.
GetName
(),
Exec
:
executor
.
Init
,
Cmd
:
commands
.
Cmd
,
RPC
:
rpc
.
Init
,
})
}
plugin/dapp/broker/proto/Makefile
0 → 100644
View file @
8d517298
all
:
bash ./create_protobuf.sh
plugin/dapp/broker/proto/broker.proto
0 → 100644
View file @
8d517298
syntax
=
"proto3"
;
package
types
;
option
go_package
=
"../types"
;
message
BrokerAction
{
oneof
value
{
Register
register
=
1
;
Audit
audit
=
2
;
InterchainEvent
emitInterchainEvent
=
3
;
UpdateEventStatus
updateEventStatus
=
4
;
}
int32
ty
=
5
;
}
// 业务合约注册模型: 0表示正在审核,1表示审核通过,2表示审核失败
message
Register
{
//业务合约名称
string
exectorName
=
1
;
}
//审核
message
Audit
{
//业务合约名称
string
exectorName
=
1
;
//状态码 0表示正在审核,1表示审核通过,2表示审核失败
string
status
=
2
;
}
// 轮循事件
message
PollingEvent
{
string
outMeta
=
1
;
}
// 更新状态
message
UpdateEventStatus
{
//源链ID
string
index
=
1
;
//状态 0表示开始处理 1表示跨链成功 2表示跨链失败
int32
status
=
2
;
}
////发布跨链事件
//message EmitInterchainEvent{
// //目的链ID,固定格式0x000001
// string dstChainID = 1;
// //源链ID,固定格式0x000002
// string srcChainID = 2;
// //跨链交易类型 0表示storage,1表示coins,2表示token......
// uint64 reqType =3;
// //调用方法
// string func = 4;
// //参数列表
// repeated string args = 6;
//}
// 跨链事件
message
InterchainEvent
{
//索引值,这个有系统自动生成
uint64
index
=
1
;
//目的链ID,固定格式0x000001
string
dstChainID
=
2
;
//源链ID,固定格式0x000002
string
srcChainID
=
3
;
//跨链交易类型 0表示storage,1表示coins,2表示token......
uint64
reqType
=
4
;
//调用方法
string
func
=
5
;
//参数列表
repeated
string
args
=
6
;
//状态 0表示开始处理 1表示跨链成功 2表示跨链失败
int32
status
=
7
;
}
//ReceiptBrokerLog
message
ReceiptBrokerLog
{
oneof
value
{
Register
register
=
1
;
Audit
audit
=
2
;
InterchainEvent
emitInterchainEvent
=
3
;
UpdateEventStatus
updateEventStatus
=
4
;
}
int32
ty
=
5
;
}
service
broker
{}
//根据状态查看跨链事件
message
QueryInterchainEventList
{
//事件状态必填(默认是0,只查询待处理状态的事件)
int32
status
=
1
;
// 主键索引
string
primaryKey
=
2
;
//单页返回多少条记录,默认返回10条,为了系统安全最多单次只能返回20条
int32
count
=
3
;
// 0降序,1升序,默认降序
int32
direction
=
4
;
}
//跨链事件列表
message
InterchainEventList
{
repeated
InterchainEvent
list
=
1
;
string
primaryKey
=
2
;
}
plugin/dapp/broker/proto/create_protobuf.sh
0 → 100644
View file @
8d517298
#!/bin/bash
# proto生成命令,将pb.go文件生成到types/目录下, chain33_path支持引用chain33框架的proto文件
chain33_path
=
$(
go list
-f
'{{.Dir}}'
"github.com/33cn/chain33"
)
protoc
--go_out
=
plugins
=
grpc:../types ./
*
.proto
--proto_path
=
.
--proto_path
=
"
${
chain33_path
}
/types/proto/"
plugin/dapp/broker/rpc/rpc.go
0 → 100644
View file @
8d517298
package
rpc
/*
* 实现json rpc和grpc service接口
* json rpc用Jrpc结构作为接收实例
* grpc使用channelClient结构作为接收实例
*/
plugin/dapp/broker/rpc/types.go
0 → 100644
View file @
8d517298
package
rpc
import
(
rpctypes
"github.com/33cn/chain33/rpc/types"
brokertypes
"github.com/33cn/plugin/plugin/dapp/broker/types"
)
/*
* rpc相关结构定义和初始化
*/
// 实现grpc的service接口
type
channelClient
struct
{
rpctypes
.
ChannelClient
}
// Jrpc 实现json rpc调用实例
type
Jrpc
struct
{
cli
*
channelClient
}
// Grpc grpc
type
Grpc
struct
{
*
channelClient
}
// Init init rpc
func
Init
(
name
string
,
s
rpctypes
.
RPCServer
)
{
cli
:=
&
channelClient
{}
grpc
:=
&
Grpc
{
channelClient
:
cli
}
cli
.
Init
(
name
,
s
,
&
Jrpc
{
cli
:
cli
},
grpc
)
//存在grpc service时注册grpc server,需要生成对应的pb.go文件
brokertypes
.
RegisterBrokerServer
(
s
.
GRPC
(),
grpc
)
}
plugin/dapp/broker/types/broker.go
0 → 100644
View file @
8d517298
package
types
import
(
log
"github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
)
/*
* 交易相关类型定义
* 交易action通常有对应的log结构,用于交易回执日志记录
* 每一种action和log需要用id数值和name名称加以区分
*/
// action类型id和name,这些常量可以自定义修改
const
(
TyUnknowAction
=
iota
+
100
TyRegisterAction
TyAuditAction
TyUpdateEventStatusAction
TyEmitInterchainEventAction
NameRegisterAction
=
"Register"
NameAuditAction
=
"Audit"
NameUpdateEventStatusAction
=
"UpdateEventStatus"
NameEmitInterchainEventAction
=
"EmitInterchainEvent"
)
// 请求类型
const
(
Req_Type_Storage
=
iota
Req_Type_Coins
Req_Type_Token
)
// 跨链事件状态
const
(
Pending
=
iota
Success
Fail
)
//查询方向
const
(
ListDESC
=
int32
(
0
)
ListASC
=
int32
(
1
)
ListSeek
=
int32
(
2
)
)
const
(
//Count 单次list还回条数
PageSize
=
int32
(
10
)
MaxPageSize
=
100
)
// log类型id值
const
(
TyUnknownLog
=
iota
+
100
TyRegisterLog
TyAuditLog
TyUpdateEventStatusLog
TyEmitInterchainEventLog
)
var
(
//BrokerX 执行器名称定义
BrokerX
=
"broker"
//定义actionMap
actionMap
=
map
[
string
]
int32
{
NameRegisterAction
:
TyRegisterAction
,
NameAuditAction
:
TyAuditAction
,
NameUpdateEventStatusAction
:
TyUpdateEventStatusAction
,
NameEmitInterchainEventAction
:
TyEmitInterchainEventAction
,
}
//定义log的id和具体log类型及名称,填入具体自定义log类型
logMap
=
map
[
int64
]
*
types
.
LogInfo
{
//LogID: {Ty: reflect.TypeOf(LogStruct), Name: LogName},
}
tlog
=
log
.
New
(
"module"
,
"broker.types"
)
)
// init defines a register function
func
init
()
{
types
.
AllowUserExec
=
append
(
types
.
AllowUserExec
,
[]
byte
(
BrokerX
))
//注册合约启用高度
types
.
RegFork
(
BrokerX
,
InitFork
)
types
.
RegExec
(
BrokerX
,
InitExecutor
)
}
// InitFork defines register fork
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
cfg
.
RegisterDappFork
(
BrokerX
,
"Enable"
,
0
)
}
// InitExecutor defines register executor
func
InitExecutor
(
cfg
*
types
.
Chain33Config
)
{
types
.
RegistorExecutor
(
BrokerX
,
NewType
(
cfg
))
}
type
brokerType
struct
{
types
.
ExecTypeBase
}
func
NewType
(
cfg
*
types
.
Chain33Config
)
*
brokerType
{
c
:=
&
brokerType
{}
c
.
SetChild
(
c
)
c
.
SetConfig
(
cfg
)
return
c
}
// GetPayload 获取合约action结构
func
(
b
*
brokerType
)
GetPayload
()
types
.
Message
{
return
&
BrokerAction
{}
}
// GeTypeMap 获取合约action的id和name信息
func
(
b
*
brokerType
)
GetTypeMap
()
map
[
string
]
int32
{
return
actionMap
}
// GetLogMap 获取合约log相关信息
func
(
b
*
brokerType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
logMap
}
plugin/dapp/broker/types/broker.pb.go
0 → 100644
View file @
8d517298
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: broker.proto
package
types
import
(
context
"context"
fmt
"fmt"
proto
"github.com/golang/protobuf/proto"
grpc
"google.golang.org/grpc"
math
"math"
)
// Reference imports to suppress errors if they are not otherwise used.
var
_
=
proto
.
Marshal
var
_
=
fmt
.
Errorf
var
_
=
math
.
Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const
_
=
proto
.
ProtoPackageIsVersion3
// please upgrade the proto package
type
BrokerAction
struct
{
// Types that are valid to be assigned to Value:
// *BrokerAction_Register
// *BrokerAction_Audit
// *BrokerAction_EmitInterchainEvent
// *BrokerAction_UpdateEventStatus
Value
isBrokerAction_Value
`protobuf_oneof:"value"`
Ty
int32
`protobuf:"varint,5,opt,name=ty,proto3" json:"ty,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
func
(
m
*
BrokerAction
)
Reset
()
{
*
m
=
BrokerAction
{}
}
func
(
m
*
BrokerAction
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
BrokerAction
)
ProtoMessage
()
{}
func
(
*
BrokerAction
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_f209535e190f2bed
,
[]
int
{
0
}
}
func
(
m
*
BrokerAction
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_BrokerAction
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
BrokerAction
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_BrokerAction
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
BrokerAction
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_BrokerAction
.
Merge
(
m
,
src
)
}
func
(
m
*
BrokerAction
)
XXX_Size
()
int
{
return
xxx_messageInfo_BrokerAction
.
Size
(
m
)
}
func
(
m
*
BrokerAction
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_BrokerAction
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_BrokerAction
proto
.
InternalMessageInfo
type
isBrokerAction_Value
interface
{
isBrokerAction_Value
()
}
type
BrokerAction_Register
struct
{
Register
*
Register
`protobuf:"bytes,1,opt,name=register,proto3,oneof"`
}
type
BrokerAction_Audit
struct
{
Audit
*
Audit
`protobuf:"bytes,2,opt,name=audit,proto3,oneof"`
}
type
BrokerAction_EmitInterchainEvent
struct
{
EmitInterchainEvent
*
InterchainEvent
`protobuf:"bytes,3,opt,name=emitInterchainEvent,proto3,oneof"`
}
type
BrokerAction_UpdateEventStatus
struct
{
UpdateEventStatus
*
UpdateEventStatus
`protobuf:"bytes,4,opt,name=updateEventStatus,proto3,oneof"`
}
func
(
*
BrokerAction_Register
)
isBrokerAction_Value
()
{}
func
(
*
BrokerAction_Audit
)
isBrokerAction_Value
()
{}
func
(
*
BrokerAction_EmitInterchainEvent
)
isBrokerAction_Value
()
{}
func
(
*
BrokerAction_UpdateEventStatus
)
isBrokerAction_Value
()
{}
func
(
m
*
BrokerAction
)
GetValue
()
isBrokerAction_Value
{
if
m
!=
nil
{
return
m
.
Value
}
return
nil
}
func
(
m
*
BrokerAction
)
GetRegister
()
*
Register
{
if
x
,
ok
:=
m
.
GetValue
()
.
(
*
BrokerAction_Register
);
ok
{
return
x
.
Register
}
return
nil
}
func
(
m
*
BrokerAction
)
GetAudit
()
*
Audit
{
if
x
,
ok
:=
m
.
GetValue
()
.
(
*
BrokerAction_Audit
);
ok
{
return
x
.
Audit
}
return
nil
}
func
(
m
*
BrokerAction
)
GetEmitInterchainEvent
()
*
InterchainEvent
{
if
x
,
ok
:=
m
.
GetValue
()
.
(
*
BrokerAction_EmitInterchainEvent
);
ok
{
return
x
.
EmitInterchainEvent
}
return
nil
}
func
(
m
*
BrokerAction
)
GetUpdateEventStatus
()
*
UpdateEventStatus
{
if
x
,
ok
:=
m
.
GetValue
()
.
(
*
BrokerAction_UpdateEventStatus
);
ok
{
return
x
.
UpdateEventStatus
}
return
nil
}
func
(
m
*
BrokerAction
)
GetTy
()
int32
{
if
m
!=
nil
{
return
m
.
Ty
}
return
0
}
// XXX_OneofWrappers is for the internal use of the proto package.
func
(
*
BrokerAction
)
XXX_OneofWrappers
()
[]
interface
{}
{
return
[]
interface
{}{
(
*
BrokerAction_Register
)(
nil
),
(
*
BrokerAction_Audit
)(
nil
),
(
*
BrokerAction_EmitInterchainEvent
)(
nil
),
(
*
BrokerAction_UpdateEventStatus
)(
nil
),
}
}
// 业务合约注册模型: 0表示正在审核,1表示审核通过,2表示审核失败
type
Register
struct
{
//业务合约名称
ExectorName
string
`protobuf:"bytes,1,opt,name=exectorName,proto3" json:"exectorName,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
func
(
m
*
Register
)
Reset
()
{
*
m
=
Register
{}
}
func
(
m
*
Register
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
Register
)
ProtoMessage
()
{}
func
(
*
Register
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_f209535e190f2bed
,
[]
int
{
1
}
}
func
(
m
*
Register
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_Register
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
Register
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_Register
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
Register
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_Register
.
Merge
(
m
,
src
)
}
func
(
m
*
Register
)
XXX_Size
()
int
{
return
xxx_messageInfo_Register
.
Size
(
m
)
}
func
(
m
*
Register
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_Register
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_Register
proto
.
InternalMessageInfo
func
(
m
*
Register
)
GetExectorName
()
string
{
if
m
!=
nil
{
return
m
.
ExectorName
}
return
""
}
//审核
type
Audit
struct
{
//业务合约名称
ExectorName
string
`protobuf:"bytes,1,opt,name=exectorName,proto3" json:"exectorName,omitempty"`
//状态码 0表示正在审核,1表示审核通过,2表示审核失败
Status
string
`protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
func
(
m
*
Audit
)
Reset
()
{
*
m
=
Audit
{}
}
func
(
m
*
Audit
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
Audit
)
ProtoMessage
()
{}
func
(
*
Audit
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_f209535e190f2bed
,
[]
int
{
2
}
}
func
(
m
*
Audit
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_Audit
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
Audit
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_Audit
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
Audit
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_Audit
.
Merge
(
m
,
src
)
}
func
(
m
*
Audit
)
XXX_Size
()
int
{
return
xxx_messageInfo_Audit
.
Size
(
m
)
}
func
(
m
*
Audit
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_Audit
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_Audit
proto
.
InternalMessageInfo
func
(
m
*
Audit
)
GetExectorName
()
string
{
if
m
!=
nil
{
return
m
.
ExectorName
}
return
""
}
func
(
m
*
Audit
)
GetStatus
()
string
{
if
m
!=
nil
{
return
m
.
Status
}
return
""
}
// 轮循事件
type
PollingEvent
struct
{
OutMeta
string
`protobuf:"bytes,1,opt,name=outMeta,proto3" json:"outMeta,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
func
(
m
*
PollingEvent
)
Reset
()
{
*
m
=
PollingEvent
{}
}
func
(
m
*
PollingEvent
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
PollingEvent
)
ProtoMessage
()
{}
func
(
*
PollingEvent
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_f209535e190f2bed
,
[]
int
{
3
}
}
func
(
m
*
PollingEvent
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_PollingEvent
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
PollingEvent
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_PollingEvent
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
PollingEvent
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_PollingEvent
.
Merge
(
m
,
src
)
}
func
(
m
*
PollingEvent
)
XXX_Size
()
int
{
return
xxx_messageInfo_PollingEvent
.
Size
(
m
)
}
func
(
m
*
PollingEvent
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_PollingEvent
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_PollingEvent
proto
.
InternalMessageInfo
func
(
m
*
PollingEvent
)
GetOutMeta
()
string
{
if
m
!=
nil
{
return
m
.
OutMeta
}
return
""
}
// 更新状态
type
UpdateEventStatus
struct
{
//源链ID
Index
string
`protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"`
//状态 0表示开始处理 1表示跨链成功 2表示跨链失败
Status
int32
`protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
func
(
m
*
UpdateEventStatus
)
Reset
()
{
*
m
=
UpdateEventStatus
{}
}
func
(
m
*
UpdateEventStatus
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
UpdateEventStatus
)
ProtoMessage
()
{}
func
(
*
UpdateEventStatus
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_f209535e190f2bed
,
[]
int
{
4
}
}
func
(
m
*
UpdateEventStatus
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_UpdateEventStatus
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
UpdateEventStatus
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_UpdateEventStatus
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
UpdateEventStatus
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_UpdateEventStatus
.
Merge
(
m
,
src
)
}
func
(
m
*
UpdateEventStatus
)
XXX_Size
()
int
{
return
xxx_messageInfo_UpdateEventStatus
.
Size
(
m
)
}
func
(
m
*
UpdateEventStatus
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_UpdateEventStatus
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_UpdateEventStatus
proto
.
InternalMessageInfo
func
(
m
*
UpdateEventStatus
)
GetIndex
()
string
{
if
m
!=
nil
{
return
m
.
Index
}
return
""
}
func
(
m
*
UpdateEventStatus
)
GetStatus
()
int32
{
if
m
!=
nil
{
return
m
.
Status
}
return
0
}
// 跨链事件
type
InterchainEvent
struct
{
//索引值,这个有系统自动生成
Index
uint64
`protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
//目的链ID,固定格式0x000001
DstChainID
string
`protobuf:"bytes,2,opt,name=dstChainID,proto3" json:"dstChainID,omitempty"`
//源链ID,固定格式0x000002
SrcChainID
string
`protobuf:"bytes,3,opt,name=srcChainID,proto3" json:"srcChainID,omitempty"`
//跨链交易类型 0表示storage,1表示coins,2表示token......
ReqType
uint64
`protobuf:"varint,4,opt,name=reqType,proto3" json:"reqType,omitempty"`
//调用方法
Func
string
`protobuf:"bytes,5,opt,name=func,proto3" json:"func,omitempty"`
//参数列表
Args
[]
string
`protobuf:"bytes,6,rep,name=args,proto3" json:"args,omitempty"`
//状态 0表示开始处理 1表示跨链成功 2表示跨链失败
Status
int32
`protobuf:"varint,7,opt,name=status,proto3" json:"status,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
func
(
m
*
InterchainEvent
)
Reset
()
{
*
m
=
InterchainEvent
{}
}
func
(
m
*
InterchainEvent
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
InterchainEvent
)
ProtoMessage
()
{}
func
(
*
InterchainEvent
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_f209535e190f2bed
,
[]
int
{
5
}
}
func
(
m
*
InterchainEvent
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_InterchainEvent
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
InterchainEvent
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_InterchainEvent
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
InterchainEvent
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_InterchainEvent
.
Merge
(
m
,
src
)
}
func
(
m
*
InterchainEvent
)
XXX_Size
()
int
{
return
xxx_messageInfo_InterchainEvent
.
Size
(
m
)
}
func
(
m
*
InterchainEvent
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_InterchainEvent
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_InterchainEvent
proto
.
InternalMessageInfo
func
(
m
*
InterchainEvent
)
GetIndex
()
uint64
{
if
m
!=
nil
{
return
m
.
Index
}
return
0
}
func
(
m
*
InterchainEvent
)
GetDstChainID
()
string
{
if
m
!=
nil
{
return
m
.
DstChainID
}
return
""
}
func
(
m
*
InterchainEvent
)
GetSrcChainID
()
string
{
if
m
!=
nil
{
return
m
.
SrcChainID
}
return
""
}
func
(
m
*
InterchainEvent
)
GetReqType
()
uint64
{
if
m
!=
nil
{
return
m
.
ReqType
}
return
0
}
func
(
m
*
InterchainEvent
)
GetFunc
()
string
{
if
m
!=
nil
{
return
m
.
Func
}
return
""
}
func
(
m
*
InterchainEvent
)
GetArgs
()
[]
string
{
if
m
!=
nil
{
return
m
.
Args
}
return
nil
}
func
(
m
*
InterchainEvent
)
GetStatus
()
int32
{
if
m
!=
nil
{
return
m
.
Status
}
return
0
}
//ReceiptBrokerLog
type
ReceiptBrokerLog
struct
{
// Types that are valid to be assigned to Value:
// *ReceiptBrokerLog_Register
// *ReceiptBrokerLog_Audit
// *ReceiptBrokerLog_EmitInterchainEvent
// *ReceiptBrokerLog_UpdateEventStatus
Value
isReceiptBrokerLog_Value
`protobuf_oneof:"value"`
Ty
int32
`protobuf:"varint,5,opt,name=ty,proto3" json:"ty,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
func
(
m
*
ReceiptBrokerLog
)
Reset
()
{
*
m
=
ReceiptBrokerLog
{}
}
func
(
m
*
ReceiptBrokerLog
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
ReceiptBrokerLog
)
ProtoMessage
()
{}
func
(
*
ReceiptBrokerLog
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_f209535e190f2bed
,
[]
int
{
6
}
}
func
(
m
*
ReceiptBrokerLog
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_ReceiptBrokerLog
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
ReceiptBrokerLog
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_ReceiptBrokerLog
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
ReceiptBrokerLog
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_ReceiptBrokerLog
.
Merge
(
m
,
src
)
}
func
(
m
*
ReceiptBrokerLog
)
XXX_Size
()
int
{
return
xxx_messageInfo_ReceiptBrokerLog
.
Size
(
m
)
}
func
(
m
*
ReceiptBrokerLog
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_ReceiptBrokerLog
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_ReceiptBrokerLog
proto
.
InternalMessageInfo
type
isReceiptBrokerLog_Value
interface
{
isReceiptBrokerLog_Value
()
}
type
ReceiptBrokerLog_Register
struct
{
Register
*
Register
`protobuf:"bytes,1,opt,name=register,proto3,oneof"`
}
type
ReceiptBrokerLog_Audit
struct
{
Audit
*
Audit
`protobuf:"bytes,2,opt,name=audit,proto3,oneof"`
}
type
ReceiptBrokerLog_EmitInterchainEvent
struct
{
EmitInterchainEvent
*
InterchainEvent
`protobuf:"bytes,3,opt,name=emitInterchainEvent,proto3,oneof"`
}
type
ReceiptBrokerLog_UpdateEventStatus
struct
{
UpdateEventStatus
*
UpdateEventStatus
`protobuf:"bytes,4,opt,name=updateEventStatus,proto3,oneof"`
}
func
(
*
ReceiptBrokerLog_Register
)
isReceiptBrokerLog_Value
()
{}
func
(
*
ReceiptBrokerLog_Audit
)
isReceiptBrokerLog_Value
()
{}
func
(
*
ReceiptBrokerLog_EmitInterchainEvent
)
isReceiptBrokerLog_Value
()
{}
func
(
*
ReceiptBrokerLog_UpdateEventStatus
)
isReceiptBrokerLog_Value
()
{}
func
(
m
*
ReceiptBrokerLog
)
GetValue
()
isReceiptBrokerLog_Value
{
if
m
!=
nil
{
return
m
.
Value
}
return
nil
}
func
(
m
*
ReceiptBrokerLog
)
GetRegister
()
*
Register
{
if
x
,
ok
:=
m
.
GetValue
()
.
(
*
ReceiptBrokerLog_Register
);
ok
{
return
x
.
Register
}
return
nil
}
func
(
m
*
ReceiptBrokerLog
)
GetAudit
()
*
Audit
{
if
x
,
ok
:=
m
.
GetValue
()
.
(
*
ReceiptBrokerLog_Audit
);
ok
{
return
x
.
Audit
}
return
nil
}
func
(
m
*
ReceiptBrokerLog
)
GetEmitInterchainEvent
()
*
InterchainEvent
{
if
x
,
ok
:=
m
.
GetValue
()
.
(
*
ReceiptBrokerLog_EmitInterchainEvent
);
ok
{
return
x
.
EmitInterchainEvent
}
return
nil
}
func
(
m
*
ReceiptBrokerLog
)
GetUpdateEventStatus
()
*
UpdateEventStatus
{
if
x
,
ok
:=
m
.
GetValue
()
.
(
*
ReceiptBrokerLog_UpdateEventStatus
);
ok
{
return
x
.
UpdateEventStatus
}
return
nil
}
func
(
m
*
ReceiptBrokerLog
)
GetTy
()
int32
{
if
m
!=
nil
{
return
m
.
Ty
}
return
0
}
// XXX_OneofWrappers is for the internal use of the proto package.
func
(
*
ReceiptBrokerLog
)
XXX_OneofWrappers
()
[]
interface
{}
{
return
[]
interface
{}{
(
*
ReceiptBrokerLog_Register
)(
nil
),
(
*
ReceiptBrokerLog_Audit
)(
nil
),
(
*
ReceiptBrokerLog_EmitInterchainEvent
)(
nil
),
(
*
ReceiptBrokerLog_UpdateEventStatus
)(
nil
),
}
}
//根据状态查看跨链事件
type
QueryInterchainEventList
struct
{
//事件状态必填(默认是0,只查询待处理状态的事件)
Status
int32
`protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"`
// 主键索引
PrimaryKey
string
`protobuf:"bytes,2,opt,name=primaryKey,proto3" json:"primaryKey,omitempty"`
//单页返回多少条记录,默认返回10条,为了系统安全最多单次只能返回20条
Count
int32
`protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`
// 0降序,1升序,默认降序
Direction
int32
`protobuf:"varint,4,opt,name=direction,proto3" json:"direction,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
func
(
m
*
QueryInterchainEventList
)
Reset
()
{
*
m
=
QueryInterchainEventList
{}
}
func
(
m
*
QueryInterchainEventList
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
QueryInterchainEventList
)
ProtoMessage
()
{}
func
(
*
QueryInterchainEventList
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_f209535e190f2bed
,
[]
int
{
7
}
}
func
(
m
*
QueryInterchainEventList
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_QueryInterchainEventList
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
QueryInterchainEventList
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_QueryInterchainEventList
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
QueryInterchainEventList
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_QueryInterchainEventList
.
Merge
(
m
,
src
)
}
func
(
m
*
QueryInterchainEventList
)
XXX_Size
()
int
{
return
xxx_messageInfo_QueryInterchainEventList
.
Size
(
m
)
}
func
(
m
*
QueryInterchainEventList
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_QueryInterchainEventList
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_QueryInterchainEventList
proto
.
InternalMessageInfo
func
(
m
*
QueryInterchainEventList
)
GetStatus
()
int32
{
if
m
!=
nil
{
return
m
.
Status
}
return
0
}
func
(
m
*
QueryInterchainEventList
)
GetPrimaryKey
()
string
{
if
m
!=
nil
{
return
m
.
PrimaryKey
}
return
""
}
func
(
m
*
QueryInterchainEventList
)
GetCount
()
int32
{
if
m
!=
nil
{
return
m
.
Count
}
return
0
}
func
(
m
*
QueryInterchainEventList
)
GetDirection
()
int32
{
if
m
!=
nil
{
return
m
.
Direction
}
return
0
}
//跨链事件列表
type
InterchainEventList
struct
{
List
[]
*
InterchainEvent
`protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"`
PrimaryKey
string
`protobuf:"bytes,2,opt,name=primaryKey,proto3" json:"primaryKey,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
func
(
m
*
InterchainEventList
)
Reset
()
{
*
m
=
InterchainEventList
{}
}
func
(
m
*
InterchainEventList
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
InterchainEventList
)
ProtoMessage
()
{}
func
(
*
InterchainEventList
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_f209535e190f2bed
,
[]
int
{
8
}
}
func
(
m
*
InterchainEventList
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_InterchainEventList
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
InterchainEventList
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_InterchainEventList
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
InterchainEventList
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_InterchainEventList
.
Merge
(
m
,
src
)
}
func
(
m
*
InterchainEventList
)
XXX_Size
()
int
{
return
xxx_messageInfo_InterchainEventList
.
Size
(
m
)
}
func
(
m
*
InterchainEventList
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_InterchainEventList
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_InterchainEventList
proto
.
InternalMessageInfo
func
(
m
*
InterchainEventList
)
GetList
()
[]
*
InterchainEvent
{
if
m
!=
nil
{
return
m
.
List
}
return
nil
}
func
(
m
*
InterchainEventList
)
GetPrimaryKey
()
string
{
if
m
!=
nil
{
return
m
.
PrimaryKey
}
return
""
}
func
init
()
{
proto
.
RegisterType
((
*
BrokerAction
)(
nil
),
"types.BrokerAction"
)
proto
.
RegisterType
((
*
Register
)(
nil
),
"types.Register"
)
proto
.
RegisterType
((
*
Audit
)(
nil
),
"types.Audit"
)
proto
.
RegisterType
((
*
PollingEvent
)(
nil
),
"types.PollingEvent"
)
proto
.
RegisterType
((
*
UpdateEventStatus
)(
nil
),
"types.UpdateEventStatus"
)
proto
.
RegisterType
((
*
InterchainEvent
)(
nil
),
"types.InterchainEvent"
)
proto
.
RegisterType
((
*
ReceiptBrokerLog
)(
nil
),
"types.ReceiptBrokerLog"
)
proto
.
RegisterType
((
*
QueryInterchainEventList
)(
nil
),
"types.QueryInterchainEventList"
)
proto
.
RegisterType
((
*
InterchainEventList
)(
nil
),
"types.InterchainEventList"
)
}
func
init
()
{
proto
.
RegisterFile
(
"broker.proto"
,
fileDescriptor_f209535e190f2bed
)
}
var
fileDescriptor_f209535e190f2bed
=
[]
byte
{
// 491 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,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,
0xbb
,
0xdf
,
0x5e
,
0xfc
,
0x0b
,
0x00
,
0x00
,
0xff
,
0xff
,
0x60
,
0x67
,
0x5e
,
0xab
,
0xef
,
0x04
,
0x00
,
0x00
,
}
// Reference imports to suppress errors if they are not otherwise used.
var
_
context
.
Context
var
_
grpc
.
ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const
_
=
grpc
.
SupportPackageIsVersion6
// BrokerClient is the client API for Broker service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type
BrokerClient
interface
{
}
type
brokerClient
struct
{
cc
grpc
.
ClientConnInterface
}
func
NewBrokerClient
(
cc
grpc
.
ClientConnInterface
)
BrokerClient
{
return
&
brokerClient
{
cc
}
}
// BrokerServer is the server API for Broker service.
type
BrokerServer
interface
{
}
// UnimplementedBrokerServer can be embedded to have forward compatible implementations.
type
UnimplementedBrokerServer
struct
{
}
func
RegisterBrokerServer
(
s
*
grpc
.
Server
,
srv
BrokerServer
)
{
s
.
RegisterService
(
&
_Broker_serviceDesc
,
srv
)
}
var
_Broker_serviceDesc
=
grpc
.
ServiceDesc
{
ServiceName
:
"types.broker"
,
HandlerType
:
(
*
BrokerServer
)(
nil
),
Methods
:
[]
grpc
.
MethodDesc
{},
Streams
:
[]
grpc
.
StreamDesc
{},
Metadata
:
"broker.proto"
,
}
plugin/dapp/broker/types/errors.go
0 → 100644
View file @
8d517298
package
types
import
"fmt"
// some errors definition
var
(
ErrBrokerStorageTx
=
fmt
.
Errorf
(
"%s"
,
"The key doesn't exist!"
)
ErrInterChainEvent
=
fmt
.
Errorf
(
"%s"
,
"wrong interchain tx!"
)
ErrData
=
fmt
.
Errorf
(
"%s"
,
"err interchain event data."
)
)
\ No newline at end of file
plugin/dapp/init/init.go
View file @
8d517298
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
_
"github.com/33cn/plugin/plugin/dapp/accountmanager"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/accountmanager"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/autonomy"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/autonomy"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/blackwhite"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/blackwhite"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/broker"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/cert"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/cert"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/coinsx"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/coinsx"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/collateralize"
//auto gen
_
"github.com/33cn/plugin/plugin/dapp/collateralize"
//auto gen
...
...
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