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
0c67134a
Commit
0c67134a
authored
Dec 11, 2018
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trade 为了支持更广义的资产, 不仅限于tokne 资产,去掉了对token 合约的依赖.
删除了判断token资产是否存在的步骤, 导致了新老版本执行结果不 一致, 现在回滚代码
parent
cc8b634f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
tradedb.go
plugin/dapp/trade/executor/tradedb.go
+26
-0
No files found.
plugin/dapp/trade/executor/tradedb.go
View file @
0c67134a
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
package
executor
package
executor
import
(
import
(
"errors"
"fmt"
"strconv"
"strconv"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/account"
...
@@ -412,10 +414,34 @@ func (action *tradeAction) tradeRevokeSell(revoke *pty.TradeForRevokeSell) (*typ
...
@@ -412,10 +414,34 @@ func (action *tradeAction) tradeRevokeSell(revoke *pty.TradeForRevokeSell) (*typ
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
//不同合约之间查询的需求后面要考虑,现在先重复处理一下,原则上不能直接引用其他合约的代码
//后面可能会有一套查询规则 和 写规则, 合约对其他合约只读
func
calcTokenKey
(
token
string
)
(
key
[]
byte
)
{
tokenCreated
:=
"mavl-token-"
return
[]
byte
(
fmt
.
Sprintf
(
tokenCreated
+
"%s"
,
token
))
}
func
checkTokenExist
(
token
string
,
db
dbm
.
KV
)
bool
{
_
,
err
:=
db
.
Get
(
calcTokenKey
(
token
))
return
err
==
nil
}
func
(
action
*
tradeAction
)
tradeBuyLimit
(
buy
*
pty
.
TradeForBuyLimit
)
(
*
types
.
Receipt
,
error
)
{
func
(
action
*
tradeAction
)
tradeBuyLimit
(
buy
*
pty
.
TradeForBuyLimit
)
(
*
types
.
Receipt
,
error
)
{
// ErrTokenNotExist error token symbol not exist
errTokenNotExist
:=
errors
.
New
(
"ErrTokenSymbolNotExist"
)
if
buy
.
TotalBoardlot
<
0
||
buy
.
PricePerBoardlot
<
0
||
buy
.
MinBoardlot
<
0
||
buy
.
AmountPerBoardlot
<
0
{
if
buy
.
TotalBoardlot
<
0
||
buy
.
PricePerBoardlot
<
0
||
buy
.
MinBoardlot
<
0
||
buy
.
AmountPerBoardlot
<
0
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
// 这个检查会比较鸡肋, 按目前的想法的能支持更多的资产, 各种资产检查不一样
// 可以先让订单成功, 如果不合适, 自己撤单也行
// 或后续跨合约注册一个检测的函数
if
buy
.
AssetExec
==
""
||
buy
.
AssetExec
==
defaultAssetExec
{
// check token exist
if
!
checkTokenExist
(
buy
.
TokenSymbol
,
action
.
db
)
{
return
nil
,
errTokenNotExist
}
}
if
!
checkAsset
(
action
.
height
,
buy
.
AssetExec
,
buy
.
TokenSymbol
)
{
if
!
checkAsset
(
action
.
height
,
buy
.
AssetExec
,
buy
.
TokenSymbol
)
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
...
...
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