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
e221a622
Commit
e221a622
authored
Jan 09, 2020
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除手动生成KV的代码
parent
a5a4bc28
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
115 deletions
+3
-115
localdb_v1.go
plugin/dapp/trade/executor/localdb_v1.go
+3
-115
No files found.
plugin/dapp/trade/executor/localdb_v1.go
View file @
e221a622
...
@@ -7,34 +7,13 @@ import (
...
@@ -7,34 +7,13 @@ import (
pty
"github.com/33cn/plugin/plugin/dapp/trade/types"
pty
"github.com/33cn/plugin/plugin/dapp/trade/types"
)
)
// 生成 key -> id 格式的本地数据库数据, 在下个版本这个文件可以全部删除
// 由于数据库精简需要保存具体数据
// 将手动生成的local db 的代码和用table 生成的local db的代码分离出来
// 将手动生成的local db 的代码和用table 生成的local db的代码分离出来
// 手动生成的local db, 将不生成任意资产标价的数据, 保留用coins 生成交易的数据, 来兼容为升级的app 应用
// 手动生成的local db, 将不生成任意资产标价的数据, 保留用coins 生成交易的数据, 来兼容为升级的app 应用
// 希望有全量数据的, 需要调用新的rpc
// 希望有全量数据的, 需要调用新的rpc
// sell limit
func
genSaveSellKv
(
sellorder
*
pty
.
SellOrder
)
[]
*
types
.
KeyValue
{
if
sellorder
.
PriceExec
!=
""
&&
sellorder
.
PriceExec
!=
defaultPriceExec
{
return
nil
}
status
:=
sellorder
.
Status
var
kv
[]
*
types
.
KeyValue
kv
=
saveSellOrderKeyValue
(
kv
,
sellorder
,
status
)
if
pty
.
TradeOrderStatusSoldOut
==
status
||
pty
.
TradeOrderStatusRevoked
==
status
{
tradelog
.
Debug
(
"trade saveSell "
,
"remove old status onsale to soldout or revoked with sellid"
,
sellorder
.
SellID
)
kv
=
deleteSellOrderKeyValue
(
kv
,
sellorder
,
pty
.
TradeOrderStatusOnSale
)
}
return
kv
}
func
saveSellOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
sellorder
*
pty
.
SellOrder
,
status
int32
)
[]
*
types
.
KeyValue
{
sellID
:=
[]
byte
(
sellorder
.
SellID
)
return
genSellOrderKeyValue
(
kv
,
sellorder
,
status
,
sellID
)
}
func
deleteSellOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
sellorder
*
pty
.
SellOrder
,
status
int32
)
[]
*
types
.
KeyValue
{
return
genSellOrderKeyValue
(
kv
,
sellorder
,
status
,
nil
)
}
func
genSellOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
sellorder
*
pty
.
SellOrder
,
status
int32
,
value
[]
byte
)
[]
*
types
.
KeyValue
{
func
genSellOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
sellorder
*
pty
.
SellOrder
,
status
int32
,
value
[]
byte
)
[]
*
types
.
KeyValue
{
newkey
:=
calcTokenSellOrderKey
(
sellorder
.
TokenSymbol
,
sellorder
.
Address
,
status
,
sellorder
.
SellID
,
sellorder
.
Height
)
newkey
:=
calcTokenSellOrderKey
(
sellorder
.
TokenSymbol
,
sellorder
.
Address
,
status
,
sellorder
.
SellID
,
sellorder
.
Height
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
...
@@ -56,16 +35,6 @@ func genSellOrderKeyValue(kv []*types.KeyValue, sellorder *pty.SellOrder, status
...
@@ -56,16 +35,6 @@ func genSellOrderKeyValue(kv []*types.KeyValue, sellorder *pty.SellOrder, status
return
kv
return
kv
}
}
// buy market
func
saveBuyMarketOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
receipt
*
pty
.
ReceiptBuyBase
,
status
int32
,
height
int64
)
[]
*
types
.
KeyValue
{
if
receipt
.
PriceExec
!=
""
&&
receipt
.
PriceExec
!=
defaultPriceExec
{
return
nil
}
txhash
:=
[]
byte
(
receipt
.
TxHash
)
return
genBuyMarketOrderKeyValue
(
kv
,
receipt
,
status
,
height
,
txhash
)
}
func
genBuyMarketOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
receipt
*
pty
.
ReceiptBuyBase
,
func
genBuyMarketOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
receipt
*
pty
.
ReceiptBuyBase
,
status
int32
,
height
int64
,
value
[]
byte
)
[]
*
types
.
KeyValue
{
status
int32
,
height
int64
,
value
[]
byte
)
[]
*
types
.
KeyValue
{
...
@@ -103,31 +72,6 @@ func genBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase
...
@@ -103,31 +72,6 @@ func genBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase
return
kv
return
kv
}
}
// buy limit
func
genSaveBuyLimitKv
(
buyOrder
*
pty
.
BuyLimitOrder
)
[]
*
types
.
KeyValue
{
if
buyOrder
.
PriceExec
!=
""
&&
buyOrder
.
PriceExec
!=
defaultPriceExec
{
return
nil
}
status
:=
buyOrder
.
Status
var
kv
[]
*
types
.
KeyValue
kv
=
saveBuyLimitOrderKeyValue
(
kv
,
buyOrder
,
status
)
if
pty
.
TradeOrderStatusBoughtOut
==
status
||
pty
.
TradeOrderStatusBuyRevoked
==
status
{
tradelog
.
Debug
(
"trade saveBuyLimit "
,
"remove old status with Buyid"
,
buyOrder
.
BuyID
)
kv
=
deleteBuyLimitKeyValue
(
kv
,
buyOrder
,
pty
.
TradeOrderStatusOnBuy
)
}
return
kv
}
func
saveBuyLimitOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
buyOrder
*
pty
.
BuyLimitOrder
,
status
int32
)
[]
*
types
.
KeyValue
{
buyID
:=
[]
byte
(
buyOrder
.
BuyID
)
return
genBuyLimitOrderKeyValue
(
kv
,
buyOrder
,
status
,
buyID
)
}
func
deleteBuyLimitKeyValue
(
kv
[]
*
types
.
KeyValue
,
buyOrder
*
pty
.
BuyLimitOrder
,
status
int32
)
[]
*
types
.
KeyValue
{
return
genBuyLimitOrderKeyValue
(
kv
,
buyOrder
,
status
,
nil
)
}
func
genBuyLimitOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
buyOrder
*
pty
.
BuyLimitOrder
,
status
int32
,
value
[]
byte
)
[]
*
types
.
KeyValue
{
func
genBuyLimitOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
buyOrder
*
pty
.
BuyLimitOrder
,
status
int32
,
value
[]
byte
)
[]
*
types
.
KeyValue
{
newkey
:=
calcTokenBuyOrderKey
(
buyOrder
.
TokenSymbol
,
buyOrder
.
Address
,
status
,
buyOrder
.
BuyID
,
buyOrder
.
Height
)
newkey
:=
calcTokenBuyOrderKey
(
buyOrder
.
TokenSymbol
,
buyOrder
.
Address
,
status
,
buyOrder
.
BuyID
,
buyOrder
.
Height
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
...
@@ -148,59 +92,3 @@ func genBuyLimitOrderKeyValue(kv []*types.KeyValue, buyOrder *pty.BuyLimitOrder,
...
@@ -148,59 +92,3 @@ func genBuyLimitOrderKeyValue(kv []*types.KeyValue, buyOrder *pty.BuyLimitOrder,
return
kv
return
kv
}
}
// sell market
func
saveSellMarketOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
receipt
*
pty
.
ReceiptSellBase
,
status
int32
,
height
int64
)
[]
*
types
.
KeyValue
{
if
receipt
.
PriceExec
!=
""
&&
receipt
.
PriceExec
!=
defaultPriceExec
{
return
nil
}
txhash
:=
[]
byte
(
receipt
.
TxHash
)
return
genSellMarketOrderKeyValue
(
kv
,
receipt
,
status
,
height
,
txhash
)
}
// delete part
// sell limit
func
genDeleteSellKv
(
sellorder
*
pty
.
SellOrder
)
[]
*
types
.
KeyValue
{
if
sellorder
.
PriceExec
!=
""
&&
sellorder
.
PriceExec
!=
defaultPriceExec
{
return
nil
}
status
:=
sellorder
.
Status
var
kv
[]
*
types
.
KeyValue
kv
=
deleteSellOrderKeyValue
(
kv
,
sellorder
,
status
)
if
pty
.
TradeOrderStatusSoldOut
==
status
||
pty
.
TradeOrderStatusRevoked
==
status
{
tradelog
.
Debug
(
"trade saveSell "
,
"remove old status onsale to soldout or revoked with sellID"
,
sellorder
.
SellID
)
kv
=
saveSellOrderKeyValue
(
kv
,
sellorder
,
pty
.
TradeOrderStatusOnSale
)
}
return
kv
}
// buy market
func
deleteBuyMarketOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
receipt
*
pty
.
ReceiptBuyBase
,
status
int32
,
height
int64
)
[]
*
types
.
KeyValue
{
if
receipt
.
PriceExec
!=
""
&&
receipt
.
PriceExec
!=
defaultPriceExec
{
return
nil
}
return
genBuyMarketOrderKeyValue
(
kv
,
receipt
,
status
,
height
,
nil
)
}
// buy limit
func
genDeleteBuyLimitKv
(
buyOrder
*
pty
.
BuyLimitOrder
)
[]
*
types
.
KeyValue
{
if
buyOrder
.
PriceExec
!=
""
&&
buyOrder
.
PriceExec
!=
defaultPriceExec
{
return
nil
}
status
:=
buyOrder
.
Status
var
kv
[]
*
types
.
KeyValue
kv
=
deleteBuyLimitKeyValue
(
kv
,
buyOrder
,
status
)
if
pty
.
TradeOrderStatusBoughtOut
==
status
||
pty
.
TradeOrderStatusBuyRevoked
==
status
{
tradelog
.
Debug
(
"trade saveSell "
,
"remove old status onsale to soldout or revoked with sellid"
,
buyOrder
.
BuyID
)
kv
=
saveBuyLimitOrderKeyValue
(
kv
,
buyOrder
,
pty
.
TradeOrderStatusOnBuy
)
}
return
kv
}
// sell market
func
deleteSellMarketOrderKeyValue
(
kv
[]
*
types
.
KeyValue
,
receipt
*
pty
.
ReceiptSellBase
,
status
int32
,
height
int64
)
[]
*
types
.
KeyValue
{
if
receipt
.
PriceExec
!=
""
&&
receipt
.
PriceExec
!=
defaultPriceExec
{
return
nil
}
return
genSellMarketOrderKeyValue
(
kv
,
receipt
,
status
,
height
,
nil
)
}
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