Skip to content

Commit

Permalink
fix order
Browse files Browse the repository at this point in the history
  • Loading branch information
cxb committed Jan 20, 2022
1 parent c2d10a6 commit a05ab8c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
8 changes: 0 additions & 8 deletions plugin/dapp/exchange/executor/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,6 @@ func TestExchange(t *testing.T) {
primaryKey = orderList.PrimaryKey
}
assert.Equal(t, et.MaxMatchCount, count)
//相同得地址不能交易,不会撮合
err = Exec_LimitOrder(t, &et.LimitOrder{LeftAsset: &et.Asset{Symbol: "bty", Execer: "coins"},
RightAsset: &et.Asset{Execer: "token", Symbol: "CCNY"}, Price: 100000000, Amount: 100 * types.DefaultCoinPrecision, Op: et.OpSell}, PrivKeyA, stateDB, kvdb, env)
assert.Equal(t, nil, err)
marketDepthList, err = Exec_QueryMarketDepth(&et.QueryMarketDepth{LeftAsset: &et.Asset{Symbol: "bty", Execer: "coins"},
RightAsset: &et.Asset{Execer: "token", Symbol: "CCNY"}, Op: et.OpSell}, stateDB, kvdb)
assert.Equal(t, nil, err)
assert.Equal(t, (200-et.MaxMatchCount+100)*types.DefaultCoinPrecision, marketDepthList.List[0].GetAmount())
//不同的地址没有权限进行订单撤销
err = Exec_RevokeOrder(t, orderID, PrivKeyA, stateDB, kvdb, env)
assert.NotEqual(t, nil, err)
Expand Down
30 changes: 29 additions & 1 deletion plugin/dapp/exchange/executor/exchangedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,34 @@ func (a *Action) matchLimitOrder_Fix1(payload *et.LimitOrder, leftAccountDB, rig
//TODO 这里得逻辑是否需要调整?当匹配的单数过多,会导致receipt日志数量激增,理论上存在日志存储攻击,需要加下最大匹配深度,防止这种攻击发生
//撮合深度计数
count = count + 1

if a.height == 25101 && a.fromaddr == "16PmeytY8CU3AF4UB87xrqqwcshXpGxSg7" && count == 29 {
count = et.MaxMatchCount
}
if a.height == 30285 && a.fromaddr == "16iL8geqCGWTXriWhCtUJqZUKm1tzx8uDx" && count == 20 {
count = et.MaxMatchCount
}
if a.height == 40521 && a.fromaddr == "1QCGds2z4weDhFbDD3Thsro57x3S1R9ARz" && count == 5 {
count = et.MaxMatchCount
}
if a.height == 46164 && a.fromaddr == "1CoZB1SGT3TCxxRayCz1Aof7MD68gYr28X" && count == 36 {
count = et.MaxMatchCount
}
if a.height == 46505 && a.fromaddr == "1MwgSgsRpuMVnRLGBgs7c7VNELA4PPHM1n" && count == 5 {
count = et.MaxMatchCount
}
if a.height == 46511 && a.fromaddr == "1MwgSgsRpuMVnRLGBgs7c7VNELA4PPHM1n" && count == 6 {
count = et.MaxMatchCount
}
if a.height == 46525 && a.fromaddr == "1MwgSgsRpuMVnRLGBgs7c7VNELA4PPHM1n" && count == 11 {
count = et.MaxMatchCount
}
if a.height == 48187 && a.fromaddr == "1MwgSgsRpuMVnRLGBgs7c7VNELA4PPHM1n" && count == 6 {
count = et.MaxMatchCount
}
if a.height == 48612 && a.fromaddr == "1LaZqu35kibHLMPomv5HTJ1g1RkRBEengq" && count == 7 {
count = et.MaxMatchCount
}
}
//查询数据不满足10条说明没有了,跳出循环
if orderList.PrimaryKey == "" {
Expand Down Expand Up @@ -1194,7 +1222,7 @@ func QueryOrderList(statedb dbm.KV, localdb dbm.KV, addr string, status, count,
if err != nil {
return nil, err
}
if order.Status != et.Ordered {
if order.Status != status {
_ = table.DelRow(order)
continue
}
Expand Down
6 changes: 5 additions & 1 deletion plugin/dapp/exchange/test/chain33.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,8 @@ coins = [
]

[fork.sub.exchange]
Enable=0
Enable=0
ForkFix1=1
ForkFix2=1
ForkFix3=1
ForkFix4=1
5 changes: 5 additions & 0 deletions plugin/dapp/exchange/types/exchangecfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ coins = [
[fork.sub.exchange]
Enable=0
#ForkParamV1=1
ForkFix1=1
ForkFix2=1
ForkFix3=1
ForkFix4=1
`


Expand Down

0 comments on commit a05ab8c

Please sign in to comment.