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
e2f6160a
Commit
e2f6160a
authored
Nov 23, 2018
by
sanghg
Committed by
vipwzw
Nov 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issues #58
修复make vet 提示错误
parent
40589b8e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
185 additions
and
185 deletions
+185
-185
exec_test.go
plugin/dapp/trade/executor/exec_test.go
+20
-20
kv.go
plugin/dapp/trade/executor/kv.go
+20
-20
trade_test.go
plugin/dapp/trade/executor/trade_test.go
+42
-42
tradedb.go
plugin/dapp/trade/executor/tradedb.go
+98
-98
rpc.go
plugin/dapp/trade/rpc/rpc.go
+5
-5
No files found.
plugin/dapp/trade/executor/exec_test.go
View file @
e2f6160a
...
@@ -88,13 +88,13 @@ func TestTrade_Exec_SellLimit(t *testing.T) {
...
@@ -88,13 +88,13 @@ func TestTrade_Exec_SellLimit(t *testing.T) {
driver
.
SetStateDB
(
stateDB
)
driver
.
SetStateDB
(
stateDB
)
sell
:=
&
pty
.
TradeSellTx
{
sell
:=
&
pty
.
TradeSellTx
{
Symbol
,
TokenSymbol
:
Symbol
,
sellArgs
.
amount
,
AmountPerBoardlot
:
sellArgs
.
amount
,
sellArgs
.
min
,
MinBoardlot
:
sellArgs
.
min
,
sellArgs
.
price
,
PricePerBoardlot
:
sellArgs
.
price
,
sellArgs
.
total
,
TotalBoardlot
:
sellArgs
.
total
,
0
,
Fee
:
0
,
AssetExecToken
,
AssetExec
:
AssetExec
Token
,
}
}
tx
,
_
:=
pty
.
CreateRawTradeSellTx
(
sell
)
tx
,
_
:=
pty
.
CreateRawTradeSellTx
(
sell
)
tx
,
_
=
signTx
(
tx
,
PrivKeyA
)
tx
,
_
=
signTx
(
tx
,
PrivKeyA
)
...
@@ -125,9 +125,9 @@ func TestTrade_Exec_SellLimit(t *testing.T) {
...
@@ -125,9 +125,9 @@ func TestTrade_Exec_SellLimit(t *testing.T) {
assert
.
Equal
(
t
,
string
(
Nodes
[
0
]),
sellOrder
.
Address
)
assert
.
Equal
(
t
,
string
(
Nodes
[
0
]),
sellOrder
.
Address
)
buy
:=
&
pty
.
TradeBuyTx
{
buy
:=
&
pty
.
TradeBuyTx
{
sellOrder
.
SellID
,
SellID
:
sellOrder
.
SellID
,
buyArgs
.
total
,
BoardlotCnt
:
buyArgs
.
total
,
0
,
Fee
:
0
,
}
}
tx
,
_
=
pty
.
CreateRawTradeBuyTx
(
buy
)
tx
,
_
=
pty
.
CreateRawTradeBuyTx
(
buy
)
tx
,
_
=
signTx
(
tx
,
PrivKeyB
)
tx
,
_
=
signTx
(
tx
,
PrivKeyB
)
...
@@ -197,13 +197,13 @@ func TestTrade_Exec_BuyLimit(t *testing.T) {
...
@@ -197,13 +197,13 @@ func TestTrade_Exec_BuyLimit(t *testing.T) {
driver
.
SetStateDB
(
stateDB
)
driver
.
SetStateDB
(
stateDB
)
buy
:=
&
pty
.
TradeBuyLimitTx
{
buy
:=
&
pty
.
TradeBuyLimitTx
{
Symbol
,
TokenSymbol
:
Symbol
,
buyArgs
.
amount
,
AmountPerBoardlot
:
buyArgs
.
amount
,
buyArgs
.
min
,
MinBoardlot
:
buyArgs
.
min
,
buyArgs
.
price
,
PricePerBoardlot
:
buyArgs
.
price
,
buyArgs
.
total
,
TotalBoardlot
:
buyArgs
.
total
,
0
,
Fee
:
0
,
AssetExecPara
,
AssetExec
:
AssetExec
Para
,
}
}
tx
,
_
:=
pty
.
CreateRawTradeBuyLimitTx
(
buy
)
tx
,
_
:=
pty
.
CreateRawTradeBuyLimitTx
(
buy
)
tx
,
_
=
signTx
(
tx
,
PrivKeyB
)
tx
,
_
=
signTx
(
tx
,
PrivKeyB
)
...
@@ -234,9 +234,9 @@ func TestTrade_Exec_BuyLimit(t *testing.T) {
...
@@ -234,9 +234,9 @@ func TestTrade_Exec_BuyLimit(t *testing.T) {
assert
.
Equal
(
t
,
string
(
Nodes
[
1
]),
buyLimitOrder
.
Address
)
assert
.
Equal
(
t
,
string
(
Nodes
[
1
]),
buyLimitOrder
.
Address
)
sell
:=
&
pty
.
TradeSellMarketTx
{
sell
:=
&
pty
.
TradeSellMarketTx
{
buyLimitOrder
.
BuyID
,
BuyID
:
buyLimitOrder
.
BuyID
,
sellArgs
.
total
,
BoardlotCnt
:
sellArgs
.
total
,
0
,
Fee
:
0
,
}
}
tx
,
_
=
pty
.
CreateRawTradeSellMarketTx
(
sell
)
tx
,
_
=
pty
.
CreateRawTradeSellMarketTx
(
sell
)
tx
,
_
=
signTx
(
tx
,
PrivKeyA
)
tx
,
_
=
signTx
(
tx
,
PrivKeyA
)
...
...
plugin/dapp/trade/executor/kv.go
View file @
e2f6160a
...
@@ -158,13 +158,13 @@ func genBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase
...
@@ -158,13 +158,13 @@ func genBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase
keyID
:=
receipt
.
TxHash
keyID
:=
receipt
.
TxHash
newkey
:=
calcTokenBuyOrderKey
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
,
height
)
newkey
:=
calcTokenBuyOrderKey
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
,
height
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
newkey
=
calcOnesBuyOrderKeyStatus
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
)
newkey
=
calcOnesBuyOrderKeyStatus
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
newkey
=
calcOnesBuyOrderKeyToken
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
)
newkey
=
calcOnesBuyOrderKeyToken
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
priceBoardlot
,
err
:=
strconv
.
ParseFloat
(
receipt
.
PricePerBoardlot
,
64
)
priceBoardlot
,
err
:=
strconv
.
ParseFloat
(
receipt
.
PricePerBoardlot
,
64
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -180,11 +180,11 @@ func genBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase
...
@@ -180,11 +180,11 @@ func genBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase
newkey
=
calcTokensBuyOrderKeyStatus
(
receipt
.
TokenSymbol
,
status
,
newkey
=
calcTokensBuyOrderKeyStatus
(
receipt
.
TokenSymbol
,
status
,
price
,
receipt
.
Owner
,
keyID
)
price
,
receipt
.
Owner
,
keyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
st
,
ty
:=
fromStatus
(
status
)
st
,
ty
:=
fromStatus
(
status
)
newkey
=
calcOnesOrderKey
(
receipt
.
Owner
,
st
,
ty
,
height
,
keyID
)
newkey
=
calcOnesOrderKey
(
receipt
.
Owner
,
st
,
ty
,
height
,
keyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
return
kv
return
kv
}
}
...
@@ -195,13 +195,13 @@ func genSellMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptSellBa
...
@@ -195,13 +195,13 @@ func genSellMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptSellBa
keyID
:=
receipt
.
TxHash
keyID
:=
receipt
.
TxHash
newkey
:=
calcTokenSellOrderKey
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
,
height
)
newkey
:=
calcTokenSellOrderKey
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
,
height
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
newkey
=
calcOnesSellOrderKeyStatus
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
)
newkey
=
calcOnesSellOrderKeyStatus
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
newkey
=
calcOnesSellOrderKeyToken
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
)
newkey
=
calcOnesSellOrderKeyToken
(
receipt
.
TokenSymbol
,
receipt
.
Owner
,
status
,
keyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
priceBoardlot
,
err
:=
strconv
.
ParseFloat
(
receipt
.
PricePerBoardlot
,
64
)
priceBoardlot
,
err
:=
strconv
.
ParseFloat
(
receipt
.
PricePerBoardlot
,
64
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -217,11 +217,11 @@ func genSellMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptSellBa
...
@@ -217,11 +217,11 @@ func genSellMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptSellBa
newkey
=
calcTokensSellOrderKeyStatus
(
receipt
.
TokenSymbol
,
status
,
newkey
=
calcTokensSellOrderKeyStatus
(
receipt
.
TokenSymbol
,
status
,
price
,
receipt
.
Owner
,
keyID
)
price
,
receipt
.
Owner
,
keyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
st
,
ty
:=
fromStatus
(
status
)
st
,
ty
:=
fromStatus
(
status
)
newkey
=
calcOnesOrderKey
(
receipt
.
Owner
,
st
,
ty
,
height
,
keyID
)
newkey
=
calcOnesOrderKey
(
receipt
.
Owner
,
st
,
ty
,
height
,
keyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
return
kv
return
kv
}
}
...
@@ -235,42 +235,42 @@ func calcPriceOfToken(priceBoardlot, AmountPerBoardlot int64) int64 {
...
@@ -235,42 +235,42 @@ func calcPriceOfToken(priceBoardlot, AmountPerBoardlot int64) int64 {
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
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
newkey
=
calcOnesBuyOrderKeyStatus
(
buyOrder
.
TokenSymbol
,
buyOrder
.
Address
,
status
,
buyOrder
.
BuyID
)
newkey
=
calcOnesBuyOrderKeyStatus
(
buyOrder
.
TokenSymbol
,
buyOrder
.
Address
,
status
,
buyOrder
.
BuyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
newkey
=
calcOnesBuyOrderKeyToken
(
buyOrder
.
TokenSymbol
,
buyOrder
.
Address
,
status
,
buyOrder
.
BuyID
)
newkey
=
calcOnesBuyOrderKeyToken
(
buyOrder
.
TokenSymbol
,
buyOrder
.
Address
,
status
,
buyOrder
.
BuyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
newkey
=
calcTokensBuyOrderKeyStatus
(
buyOrder
.
TokenSymbol
,
status
,
newkey
=
calcTokensBuyOrderKeyStatus
(
buyOrder
.
TokenSymbol
,
status
,
calcPriceOfToken
(
buyOrder
.
PricePerBoardlot
,
buyOrder
.
AmountPerBoardlot
),
buyOrder
.
Address
,
buyOrder
.
BuyID
)
calcPriceOfToken
(
buyOrder
.
PricePerBoardlot
,
buyOrder
.
AmountPerBoardlot
),
buyOrder
.
Address
,
buyOrder
.
BuyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
st
,
ty
:=
fromStatus
(
status
)
st
,
ty
:=
fromStatus
(
status
)
newkey
=
calcOnesOrderKey
(
buyOrder
.
Address
,
st
,
ty
,
buyOrder
.
Height
,
buyOrder
.
BuyID
)
newkey
=
calcOnesOrderKey
(
buyOrder
.
Address
,
st
,
ty
,
buyOrder
.
Height
,
buyOrder
.
BuyID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
return
kv
return
kv
}
}
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
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
newkey
=
calcOnesSellOrderKeyStatus
(
sellorder
.
TokenSymbol
,
sellorder
.
Address
,
status
,
sellorder
.
SellID
)
newkey
=
calcOnesSellOrderKeyStatus
(
sellorder
.
TokenSymbol
,
sellorder
.
Address
,
status
,
sellorder
.
SellID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
newkey
=
calcOnesSellOrderKeyToken
(
sellorder
.
TokenSymbol
,
sellorder
.
Address
,
status
,
sellorder
.
SellID
)
newkey
=
calcOnesSellOrderKeyToken
(
sellorder
.
TokenSymbol
,
sellorder
.
Address
,
status
,
sellorder
.
SellID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
newkey
=
calcTokensSellOrderKeyStatus
(
sellorder
.
TokenSymbol
,
status
,
newkey
=
calcTokensSellOrderKeyStatus
(
sellorder
.
TokenSymbol
,
status
,
calcPriceOfToken
(
sellorder
.
PricePerBoardlot
,
sellorder
.
AmountPerBoardlot
),
sellorder
.
Address
,
sellorder
.
SellID
)
calcPriceOfToken
(
sellorder
.
PricePerBoardlot
,
sellorder
.
AmountPerBoardlot
),
sellorder
.
Address
,
sellorder
.
SellID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
st
,
ty
:=
fromStatus
(
status
)
st
,
ty
:=
fromStatus
(
status
)
newkey
=
calcOnesOrderKey
(
sellorder
.
Address
,
st
,
ty
,
sellorder
.
Height
,
sellorder
.
SellID
)
newkey
=
calcOnesOrderKey
(
sellorder
.
Address
,
st
,
ty
,
sellorder
.
Height
,
sellorder
.
SellID
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
newkey
,
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
newkey
,
Value
:
value
})
return
kv
return
kv
}
}
plugin/dapp/trade/executor/trade_test.go
View file @
e2f6160a
...
@@ -15,54 +15,54 @@ import (
...
@@ -15,54 +15,54 @@ import (
var
(
var
(
sellorderOnsale
=
pty
.
SellOrder
{
sellorderOnsale
=
pty
.
SellOrder
{
"Tokensymbol"
,
TokenSymbol
:
"Tokensymbol"
,
"Address"
,
Address
:
"Address"
,
20
*
1e8
,
// Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"`
AmountPerBoardlot
:
20
*
1e8
,
// Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"`
2
,
// Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"`
MinBoardlot
:
2
,
// Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"`
1
*
1e8
,
//Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"`
PricePerBoardlot
:
1
*
1e8
,
//Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"`
60
,
// Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"`
TotalBoardlot
:
60
,
// Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"`
2
,
// Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"`
SoldBoardlot
:
2
,
// Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"`
0
,
//Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"`
Starttime
:
0
,
//Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"`
0
,
//Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"`
Stoptime
:
0
,
//Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"`
false
,
//Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"`
Crowdfund
:
false
,
//Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"`
"IAMSELLID"
,
// Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"`
SellID
:
"IAMSELLID"
,
// Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"`
pty
.
TradeOrderStatusOnSale
,
//Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"`
Status
:
pty
.
TradeOrderStatusOnSale
,
//Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"`
100
,
//Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"`
Height
:
100
,
//Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"`
"token"
,
AssetExec
:
"token"
,
}
}
sellorderSoldOut
=
pty
.
SellOrder
{
sellorderSoldOut
=
pty
.
SellOrder
{
"Tokensymbol"
,
TokenSymbol
:
"Tokensymbol"
,
"Address"
,
Address
:
"Address"
,
20
*
1e8
,
// Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"`
AmountPerBoardlot
:
20
*
1e8
,
// Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"`
2
,
// Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"`
MinBoardlot
:
2
,
// Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"`
1
*
1e8
,
//Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"`
PricePerBoardlot
:
1
*
1e8
,
//Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"`
60
,
// Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"`
TotalBoardlot
:
60
,
// Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"`
2
,
// Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"`
SoldBoardlot
:
2
,
// Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"`
0
,
//Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"`
Starttime
:
0
,
//Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"`
0
,
//Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"`
Stoptime
:
0
,
//Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"`
false
,
//Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"`
Crowdfund
:
false
,
//Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"`
"IAMSELLID"
,
// Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"`
SellID
:
"IAMSELLID"
,
// Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"`
pty
.
TradeOrderStatusSoldOut
,
//Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"`
Status
:
pty
.
TradeOrderStatusSoldOut
,
//Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"`
100
,
//Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"`
Height
:
100
,
//Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"`
"token"
,
AssetExec
:
"token"
,
}
}
sellorderRevoked
=
pty
.
SellOrder
{
sellorderRevoked
=
pty
.
SellOrder
{
"Tokensymbol"
,
TokenSymbol
:
"Tokensymbol"
,
"Address"
,
Address
:
"Address"
,
20
*
1e8
,
// Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"`
AmountPerBoardlot
:
20
*
1e8
,
// Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"`
2
,
// Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"`
MinBoardlot
:
2
,
// Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"`
1
*
1e8
,
//Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"`
PricePerBoardlot
:
1
*
1e8
,
//Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"`
60
,
// Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"`
TotalBoardlot
:
60
,
// Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"`
2
,
// Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"`
SoldBoardlot
:
2
,
// Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"`
0
,
//Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"`
Starttime
:
0
,
//Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"`
0
,
//Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"`
Stoptime
:
0
,
//Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"`
false
,
//Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"`
Crowdfund
:
false
,
//Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"`
"IAMSELLID"
,
// Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"`
SellID
:
"IAMSELLID"
,
// Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"`
pty
.
TradeOrderStatusRevoked
,
//Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"`
Status
:
pty
.
TradeOrderStatusRevoked
,
//Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"`
100
,
//Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"`
Height
:
100
,
//Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"`
"token"
,
AssetExec
:
"token"
,
}
}
)
)
...
...
plugin/dapp/trade/executor/tradedb.go
View file @
e2f6160a
...
@@ -40,29 +40,29 @@ func (selldb *sellDB) getSellLogs(tradeType int32, txhash string) *types.Receipt
...
@@ -40,29 +40,29 @@ func (selldb *sellDB) getSellLogs(tradeType int32, txhash string) *types.Receipt
log
:=
&
types
.
ReceiptLog
{}
log
:=
&
types
.
ReceiptLog
{}
log
.
Ty
=
tradeType
log
.
Ty
=
tradeType
base
:=
&
pty
.
ReceiptSellBase
{
base
:=
&
pty
.
ReceiptSellBase
{
selldb
.
TokenSymbol
,
TokenSymbol
:
selldb
.
TokenSymbol
,
selldb
.
Address
,
Owner
:
selldb
.
Address
,
strconv
.
FormatFloat
(
float64
(
selldb
.
AmountPerBoardlot
)
/
float64
(
types
.
TokenPrecision
),
'f'
,
8
,
64
),
AmountPerBoardlot
:
strconv
.
FormatFloat
(
float64
(
selldb
.
AmountPerBoardlot
)
/
float64
(
types
.
TokenPrecision
),
'f'
,
8
,
64
),
selldb
.
MinBoardlot
,
MinBoardlot
:
selldb
.
MinBoardlot
,
strconv
.
FormatFloat
(
float64
(
selldb
.
PricePerBoardlot
)
/
float64
(
types
.
Coin
),
'f'
,
8
,
64
),
PricePerBoardlot
:
strconv
.
FormatFloat
(
float64
(
selldb
.
PricePerBoardlot
)
/
float64
(
types
.
Coin
),
'f'
,
8
,
64
),
selldb
.
TotalBoardlot
,
TotalBoardlot
:
selldb
.
TotalBoardlot
,
selldb
.
SoldBoardlot
,
SoldBoardlot
:
selldb
.
SoldBoardlot
,
selldb
.
Starttime
,
Starttime
:
selldb
.
Starttime
,
selldb
.
Stoptime
,
Stoptime
:
selldb
.
Stoptime
,
selldb
.
Crowdfund
,
Crowdfund
:
selldb
.
Crowdfund
,
selldb
.
SellID
,
SellID
:
selldb
.
SellID
,
pty
.
SellOrderStatus
[
selldb
.
Status
],
Status
:
pty
.
SellOrderStatus
[
selldb
.
Status
],
""
,
BuyID
:
""
,
txhash
,
TxHash
:
txhash
,
selldb
.
Height
,
Height
:
selldb
.
Height
,
selldb
.
AssetExec
,
AssetExec
:
selldb
.
AssetExec
,
}
}
if
pty
.
TyLogTradeSellLimit
==
tradeType
{
if
pty
.
TyLogTradeSellLimit
==
tradeType
{
receiptTrade
:=
&
pty
.
ReceiptTradeSellLimit
{
base
}
receiptTrade
:=
&
pty
.
ReceiptTradeSellLimit
{
Base
:
base
}
log
.
Log
=
types
.
Encode
(
receiptTrade
)
log
.
Log
=
types
.
Encode
(
receiptTrade
)
}
else
if
pty
.
TyLogTradeSellRevoke
==
tradeType
{
}
else
if
pty
.
TyLogTradeSellRevoke
==
tradeType
{
receiptTrade
:=
&
pty
.
ReceiptTradeSellRevoke
{
base
}
receiptTrade
:=
&
pty
.
ReceiptTradeSellRevoke
{
Base
:
base
}
log
.
Log
=
types
.
Encode
(
receiptTrade
)
log
.
Log
=
types
.
Encode
(
receiptTrade
)
}
}
...
@@ -73,22 +73,22 @@ func (selldb *sellDB) getBuyLogs(buyerAddr string, boardlotcnt int64, txhash str
...
@@ -73,22 +73,22 @@ func (selldb *sellDB) getBuyLogs(buyerAddr string, boardlotcnt int64, txhash str
log
:=
&
types
.
ReceiptLog
{}
log
:=
&
types
.
ReceiptLog
{}
log
.
Ty
=
pty
.
TyLogTradeBuyMarket
log
.
Ty
=
pty
.
TyLogTradeBuyMarket
base
:=
&
pty
.
ReceiptBuyBase
{
base
:=
&
pty
.
ReceiptBuyBase
{
selldb
.
TokenSymbol
,
TokenSymbol
:
selldb
.
TokenSymbol
,
buyerAddr
,
Owner
:
buyerAddr
,
strconv
.
FormatFloat
(
float64
(
selldb
.
AmountPerBoardlot
)
/
float64
(
types
.
TokenPrecision
),
'f'
,
8
,
64
),
AmountPerBoardlot
:
strconv
.
FormatFloat
(
float64
(
selldb
.
AmountPerBoardlot
)
/
float64
(
types
.
TokenPrecision
),
'f'
,
8
,
64
),
selldb
.
MinBoardlot
,
MinBoardlot
:
selldb
.
MinBoardlot
,
strconv
.
FormatFloat
(
float64
(
selldb
.
PricePerBoardlot
)
/
float64
(
types
.
Coin
),
'f'
,
8
,
64
),
PricePerBoardlot
:
strconv
.
FormatFloat
(
float64
(
selldb
.
PricePerBoardlot
)
/
float64
(
types
.
Coin
),
'f'
,
8
,
64
),
boardlotcnt
,
TotalBoardlot
:
boardlotcnt
,
boardlotcnt
,
BoughtBoardlot
:
boardlotcnt
,
""
,
BuyID
:
""
,
pty
.
SellOrderStatus
[
pty
.
TradeOrderStatusBoughtOut
],
Status
:
pty
.
SellOrderStatus
[
pty
.
TradeOrderStatusBoughtOut
],
selldb
.
SellID
,
SellID
:
selldb
.
SellID
,
txhash
,
TxHash
:
txhash
,
selldb
.
Height
,
Height
:
selldb
.
Height
,
selldb
.
AssetExec
,
AssetExec
:
selldb
.
AssetExec
,
}
}
receipt
:=
&
pty
.
ReceiptTradeBuyMarket
{
base
}
receipt
:=
&
pty
.
ReceiptTradeBuyMarket
{
Base
:
base
}
log
.
Log
=
types
.
Encode
(
receipt
)
log
.
Log
=
types
.
Encode
(
receipt
)
return
log
return
log
}
}
...
@@ -131,7 +131,7 @@ func getTx(txHash []byte, db dbm.KV) (*types.TxResult, error) {
...
@@ -131,7 +131,7 @@ func getTx(txHash []byte, db dbm.KV) (*types.TxResult, error) {
func
(
selldb
*
sellDB
)
getKVSet
()
(
kvset
[]
*
types
.
KeyValue
)
{
func
(
selldb
*
sellDB
)
getKVSet
()
(
kvset
[]
*
types
.
KeyValue
)
{
value
:=
types
.
Encode
(
&
selldb
.
SellOrder
)
value
:=
types
.
Encode
(
&
selldb
.
SellOrder
)
key
:=
[]
byte
(
selldb
.
SellID
)
key
:=
[]
byte
(
selldb
.
SellID
)
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
key
,
value
})
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
return
kvset
return
kvset
}
}
...
@@ -156,7 +156,7 @@ func (buydb *buyDB) save(db dbm.KV) []*types.KeyValue {
...
@@ -156,7 +156,7 @@ func (buydb *buyDB) save(db dbm.KV) []*types.KeyValue {
func
(
buydb
*
buyDB
)
getKVSet
()
(
kvset
[]
*
types
.
KeyValue
)
{
func
(
buydb
*
buyDB
)
getKVSet
()
(
kvset
[]
*
types
.
KeyValue
)
{
value
:=
types
.
Encode
(
&
buydb
.
BuyLimitOrder
)
value
:=
types
.
Encode
(
&
buydb
.
BuyLimitOrder
)
key
:=
[]
byte
(
buydb
.
BuyID
)
key
:=
[]
byte
(
buydb
.
BuyID
)
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
key
,
value
})
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
return
kvset
return
kvset
}
}
...
@@ -164,26 +164,26 @@ func (buydb *buyDB) getBuyLogs(tradeType int32, txhash string) *types.ReceiptLog
...
@@ -164,26 +164,26 @@ func (buydb *buyDB) getBuyLogs(tradeType int32, txhash string) *types.ReceiptLog
log
:=
&
types
.
ReceiptLog
{}
log
:=
&
types
.
ReceiptLog
{}
log
.
Ty
=
tradeType
log
.
Ty
=
tradeType
base
:=
&
pty
.
ReceiptBuyBase
{
base
:=
&
pty
.
ReceiptBuyBase
{
buydb
.
TokenSymbol
,
TokenSymbol
:
buydb
.
TokenSymbol
,
buydb
.
Address
,
Owner
:
buydb
.
Address
,
strconv
.
FormatFloat
(
float64
(
buydb
.
AmountPerBoardlot
)
/
float64
(
types
.
TokenPrecision
),
'f'
,
8
,
64
),
AmountPerBoardlot
:
strconv
.
FormatFloat
(
float64
(
buydb
.
AmountPerBoardlot
)
/
float64
(
types
.
TokenPrecision
),
'f'
,
8
,
64
),
buydb
.
MinBoardlot
,
MinBoardlot
:
buydb
.
MinBoardlot
,
strconv
.
FormatFloat
(
float64
(
buydb
.
PricePerBoardlot
)
/
float64
(
types
.
Coin
),
'f'
,
8
,
64
),
PricePerBoardlot
:
strconv
.
FormatFloat
(
float64
(
buydb
.
PricePerBoardlot
)
/
float64
(
types
.
Coin
),
'f'
,
8
,
64
),
buydb
.
TotalBoardlot
,
TotalBoardlot
:
buydb
.
TotalBoardlot
,
buydb
.
BoughtBoardlot
,
BoughtBoardlot
:
buydb
.
BoughtBoardlot
,
buydb
.
BuyID
,
BuyID
:
buydb
.
BuyID
,
pty
.
SellOrderStatus
[
buydb
.
Status
],
Status
:
pty
.
SellOrderStatus
[
buydb
.
Status
],
""
,
SellID
:
""
,
txhash
,
TxHash
:
txhash
,
buydb
.
Height
,
Height
:
buydb
.
Height
,
buydb
.
AssetExec
,
AssetExec
:
buydb
.
AssetExec
,
}
}
if
pty
.
TyLogTradeBuyLimit
==
tradeType
{
if
pty
.
TyLogTradeBuyLimit
==
tradeType
{
receiptTrade
:=
&
pty
.
ReceiptTradeBuyLimit
{
base
}
receiptTrade
:=
&
pty
.
ReceiptTradeBuyLimit
{
Base
:
base
}
log
.
Log
=
types
.
Encode
(
receiptTrade
)
log
.
Log
=
types
.
Encode
(
receiptTrade
)
}
else
if
pty
.
TyLogTradeBuyRevoke
==
tradeType
{
}
else
if
pty
.
TyLogTradeBuyRevoke
==
tradeType
{
receiptTrade
:=
&
pty
.
ReceiptTradeBuyRevoke
{
base
}
receiptTrade
:=
&
pty
.
ReceiptTradeBuyRevoke
{
Base
:
base
}
log
.
Log
=
types
.
Encode
(
receiptTrade
)
log
.
Log
=
types
.
Encode
(
receiptTrade
)
}
}
...
@@ -209,22 +209,22 @@ func (buydb *buyDB) getSellLogs(sellerAddr string, sellID string, boardlotCnt in
...
@@ -209,22 +209,22 @@ func (buydb *buyDB) getSellLogs(sellerAddr string, sellID string, boardlotCnt in
log
:=
&
types
.
ReceiptLog
{}
log
:=
&
types
.
ReceiptLog
{}
log
.
Ty
=
pty
.
TyLogTradeSellMarket
log
.
Ty
=
pty
.
TyLogTradeSellMarket
base
:=
&
pty
.
ReceiptSellBase
{
base
:=
&
pty
.
ReceiptSellBase
{
buydb
.
TokenSymbol
,
TokenSymbol
:
buydb
.
TokenSymbol
,
sellerAddr
,
Owner
:
sellerAddr
,
strconv
.
FormatFloat
(
float64
(
buydb
.
AmountPerBoardlot
)
/
float64
(
types
.
TokenPrecision
),
'f'
,
8
,
64
),
AmountPerBoardlot
:
strconv
.
FormatFloat
(
float64
(
buydb
.
AmountPerBoardlot
)
/
float64
(
types
.
TokenPrecision
),
'f'
,
8
,
64
),
buydb
.
MinBoardlot
,
MinBoardlot
:
buydb
.
MinBoardlot
,
strconv
.
FormatFloat
(
float64
(
buydb
.
PricePerBoardlot
)
/
float64
(
types
.
Coin
),
'f'
,
8
,
64
),
PricePerBoardlot
:
strconv
.
FormatFloat
(
float64
(
buydb
.
PricePerBoardlot
)
/
float64
(
types
.
Coin
),
'f'
,
8
,
64
),
boardlotCnt
,
TotalBoardlot
:
boardlotCnt
,
boardlotCnt
,
SoldBoardlot
:
boardlotCnt
,
0
,
Starttime
:
0
,
0
,
Stoptime
:
0
,
false
,
Crowdfund
:
false
,
""
,
SellID
:
""
,
pty
.
SellOrderStatus
[
pty
.
TradeOrderStatusSoldOut
],
Status
:
pty
.
SellOrderStatus
[
pty
.
TradeOrderStatusSoldOut
],
buydb
.
BuyID
,
BuyID
:
buydb
.
BuyID
,
txhash
,
TxHash
:
txhash
,
buydb
.
Height
,
Height
:
buydb
.
Height
,
buydb
.
AssetExec
,
AssetExec
:
buydb
.
AssetExec
,
}
}
receiptSellMarket
:=
&
pty
.
ReceiptSellMarket
{
Base
:
base
}
receiptSellMarket
:=
&
pty
.
ReceiptSellMarket
{
Base
:
base
}
log
.
Log
=
types
.
Encode
(
receiptSellMarket
)
log
.
Log
=
types
.
Encode
(
receiptSellMarket
)
...
@@ -272,20 +272,20 @@ func (action *tradeAction) tradeSell(sell *pty.TradeForSell) (*types.Receipt, er
...
@@ -272,20 +272,20 @@ func (action *tradeAction) tradeSell(sell *pty.TradeForSell) (*types.Receipt, er
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
sellOrder
:=
pty
.
SellOrder
{
sellOrder
:=
pty
.
SellOrder
{
sell
.
GetTokenSymbol
(),
TokenSymbol
:
sell
.
GetTokenSymbol
(),
action
.
fromaddr
,
Address
:
action
.
fromaddr
,
sell
.
GetAmountPerBoardlot
(),
AmountPerBoardlot
:
sell
.
GetAmountPerBoardlot
(),
sell
.
GetMinBoardlot
(),
MinBoardlot
:
sell
.
GetMinBoardlot
(),
sell
.
GetPricePerBoardlot
(),
PricePerBoardlot
:
sell
.
GetPricePerBoardlot
(),
sell
.
GetTotalBoardlot
(),
TotalBoardlot
:
sell
.
GetTotalBoardlot
(),
0
,
SoldBoardlot
:
0
,
sell
.
GetStarttime
(),
Starttime
:
sell
.
GetStarttime
(),
sell
.
GetStoptime
(),
Stoptime
:
sell
.
GetStoptime
(),
sell
.
GetCrowdfund
(),
Crowdfund
:
sell
.
GetCrowdfund
(),
calcTokenSellID
(
action
.
txhash
),
SellID
:
calcTokenSellID
(
action
.
txhash
),
pty
.
TradeOrderStatusOnSale
,
Status
:
pty
.
TradeOrderStatusOnSale
,
action
.
height
,
Height
:
action
.
height
,
sell
.
AssetExec
,
AssetExec
:
sell
.
AssetExec
,
}
}
tokendb
:=
newSellDB
(
sellOrder
)
tokendb
:=
newSellDB
(
sellOrder
)
...
@@ -295,7 +295,7 @@ func (action *tradeAction) tradeSell(sell *pty.TradeForSell) (*types.Receipt, er
...
@@ -295,7 +295,7 @@ func (action *tradeAction) tradeSell(sell *pty.TradeForSell) (*types.Receipt, er
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
sellOrderKV
...
)
kv
=
append
(
kv
,
sellOrderKV
...
)
receipt
=
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
}
receipt
=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -366,7 +366,7 @@ func (action *tradeAction) tradeBuy(buyOrder *pty.TradeForBuy) (*types.Receipt,
...
@@ -366,7 +366,7 @@ func (action *tradeAction) tradeBuy(buyOrder *pty.TradeForBuy) (*types.Receipt,
kv
=
append
(
kv
,
receiptFromAcc
.
KV
...
)
kv
=
append
(
kv
,
receiptFromAcc
.
KV
...
)
kv
=
append
(
kv
,
receiptFromExecAcc
.
KV
...
)
kv
=
append
(
kv
,
receiptFromExecAcc
.
KV
...
)
kv
=
append
(
kv
,
sellOrderKV
...
)
kv
=
append
(
kv
,
sellOrderKV
...
)
return
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
func
(
action
*
tradeAction
)
tradeRevokeSell
(
revoke
*
pty
.
TradeForRevokeSell
)
(
*
types
.
Receipt
,
error
)
{
func
(
action
*
tradeAction
)
tradeRevokeSell
(
revoke
*
pty
.
TradeForRevokeSell
)
(
*
types
.
Receipt
,
error
)
{
...
@@ -409,7 +409,7 @@ func (action *tradeAction) tradeRevokeSell(revoke *pty.TradeForRevokeSell) (*typ
...
@@ -409,7 +409,7 @@ func (action *tradeAction) tradeRevokeSell(revoke *pty.TradeForRevokeSell) (*typ
logs
=
append
(
logs
,
tokendb
.
getSellLogs
(
pty
.
TyLogTradeSellRevoke
,
action
.
txhash
))
logs
=
append
(
logs
,
tokendb
.
getSellLogs
(
pty
.
TyLogTradeSellRevoke
,
action
.
txhash
))
kv
=
append
(
kv
,
receiptFromExecAcc
.
KV
...
)
kv
=
append
(
kv
,
receiptFromExecAcc
.
KV
...
)
kv
=
append
(
kv
,
sellOrderKV
...
)
kv
=
append
(
kv
,
sellOrderKV
...
)
return
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
func
(
action
*
tradeAction
)
tradeBuyLimit
(
buy
*
pty
.
TradeForBuyLimit
)
(
*
types
.
Receipt
,
error
)
{
func
(
action
*
tradeAction
)
tradeBuyLimit
(
buy
*
pty
.
TradeForBuyLimit
)
(
*
types
.
Receipt
,
error
)
{
...
@@ -432,17 +432,17 @@ func (action *tradeAction) tradeBuyLimit(buy *pty.TradeForBuyLimit) (*types.Rece
...
@@ -432,17 +432,17 @@ func (action *tradeAction) tradeBuyLimit(buy *pty.TradeForBuyLimit) (*types.Rece
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
buyOrder
:=
pty
.
BuyLimitOrder
{
buyOrder
:=
pty
.
BuyLimitOrder
{
buy
.
GetTokenSymbol
(),
TokenSymbol
:
buy
.
GetTokenSymbol
(),
action
.
fromaddr
,
Address
:
action
.
fromaddr
,
buy
.
GetAmountPerBoardlot
(),
AmountPerBoardlot
:
buy
.
GetAmountPerBoardlot
(),
buy
.
GetMinBoardlot
(),
MinBoardlot
:
buy
.
GetMinBoardlot
(),
buy
.
GetPricePerBoardlot
(),
PricePerBoardlot
:
buy
.
GetPricePerBoardlot
(),
buy
.
GetTotalBoardlot
(),
TotalBoardlot
:
buy
.
GetTotalBoardlot
(),
0
,
BoughtBoardlot
:
0
,
calcTokenBuyID
(
action
.
txhash
),
BuyID
:
calcTokenBuyID
(
action
.
txhash
),
pty
.
TradeOrderStatusOnBuy
,
Status
:
pty
.
TradeOrderStatusOnBuy
,
action
.
height
,
Height
:
action
.
height
,
buy
.
AssetExec
,
AssetExec
:
buy
.
AssetExec
,
}
}
tokendb
:=
newBuyDB
(
buyOrder
)
tokendb
:=
newBuyDB
(
buyOrder
)
...
@@ -452,7 +452,7 @@ func (action *tradeAction) tradeBuyLimit(buy *pty.TradeForBuyLimit) (*types.Rece
...
@@ -452,7 +452,7 @@ func (action *tradeAction) tradeBuyLimit(buy *pty.TradeForBuyLimit) (*types.Rece
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
buyOrderKV
...
)
kv
=
append
(
kv
,
buyOrderKV
...
)
receipt
=
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
}
receipt
=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -523,7 +523,7 @@ func (action *tradeAction) tradeSellMarket(sellOrder *pty.TradeForSellMarket) (*
...
@@ -523,7 +523,7 @@ func (action *tradeAction) tradeSellMarket(sellOrder *pty.TradeForSellMarket) (*
kv
=
append
(
kv
,
receiptFromAcc
.
KV
...
)
kv
=
append
(
kv
,
receiptFromAcc
.
KV
...
)
kv
=
append
(
kv
,
receiptFromExecAcc
.
KV
...
)
kv
=
append
(
kv
,
receiptFromExecAcc
.
KV
...
)
kv
=
append
(
kv
,
sellOrderKV
...
)
kv
=
append
(
kv
,
sellOrderKV
...
)
return
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
func
(
action
*
tradeAction
)
tradeRevokeBuyLimit
(
revoke
*
pty
.
TradeForRevokeBuy
)
(
*
types
.
Receipt
,
error
)
{
func
(
action
*
tradeAction
)
tradeRevokeBuyLimit
(
revoke
*
pty
.
TradeForRevokeBuy
)
(
*
types
.
Receipt
,
error
)
{
...
@@ -562,5 +562,5 @@ func (action *tradeAction) tradeRevokeBuyLimit(revoke *pty.TradeForRevokeBuy) (*
...
@@ -562,5 +562,5 @@ func (action *tradeAction) tradeRevokeBuyLimit(revoke *pty.TradeForRevokeBuy) (*
logs
=
append
(
logs
,
tokendb
.
getBuyLogs
(
pty
.
TyLogTradeBuyRevoke
,
action
.
txhash
))
logs
=
append
(
logs
,
tokendb
.
getBuyLogs
(
pty
.
TyLogTradeBuyRevoke
,
action
.
txhash
))
kv
=
append
(
kv
,
receiptFromExecAcc
.
KV
...
)
kv
=
append
(
kv
,
receiptFromExecAcc
.
KV
...
)
kv
=
append
(
kv
,
sellOrderKV
...
)
kv
=
append
(
kv
,
sellOrderKV
...
)
return
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
plugin/dapp/trade/rpc/rpc.go
View file @
e2f6160a
...
@@ -35,7 +35,7 @@ func (cc *channelClient) CreateRawTradeBuyTx(ctx context.Context, in *ptypes.Tra
...
@@ -35,7 +35,7 @@ func (cc *channelClient) CreateRawTradeBuyTx(ctx context.Context, in *ptypes.Tra
}
}
buy
:=
&
ptypes
.
Trade
{
buy
:=
&
ptypes
.
Trade
{
Ty
:
ptypes
.
TradeBuyMarket
,
Ty
:
ptypes
.
TradeBuyMarket
,
Value
:
&
ptypes
.
Trade_BuyMarket
{
in
},
Value
:
&
ptypes
.
Trade_BuyMarket
{
BuyMarket
:
in
},
}
}
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
ptypes
.
TradeX
),
types
.
Encode
(
buy
))
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
ptypes
.
TradeX
),
types
.
Encode
(
buy
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -52,7 +52,7 @@ func (cc *channelClient) CreateRawTradeRevokeTx(ctx context.Context, in *ptypes.
...
@@ -52,7 +52,7 @@ func (cc *channelClient) CreateRawTradeRevokeTx(ctx context.Context, in *ptypes.
}
}
buy
:=
&
ptypes
.
Trade
{
buy
:=
&
ptypes
.
Trade
{
Ty
:
ptypes
.
TradeRevokeSell
,
Ty
:
ptypes
.
TradeRevokeSell
,
Value
:
&
ptypes
.
Trade_RevokeSell
{
in
},
Value
:
&
ptypes
.
Trade_RevokeSell
{
RevokeSell
:
in
},
}
}
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
ptypes
.
TradeX
),
types
.
Encode
(
buy
))
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
ptypes
.
TradeX
),
types
.
Encode
(
buy
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -69,7 +69,7 @@ func (cc *channelClient) CreateRawTradeBuyLimitTx(ctx context.Context, in *ptype
...
@@ -69,7 +69,7 @@ func (cc *channelClient) CreateRawTradeBuyLimitTx(ctx context.Context, in *ptype
}
}
buy
:=
&
ptypes
.
Trade
{
buy
:=
&
ptypes
.
Trade
{
Ty
:
ptypes
.
TradeBuyLimit
,
Ty
:
ptypes
.
TradeBuyLimit
,
Value
:
&
ptypes
.
Trade_BuyLimit
{
in
},
Value
:
&
ptypes
.
Trade_BuyLimit
{
BuyLimit
:
in
},
}
}
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
ptypes
.
TradeX
),
types
.
Encode
(
buy
))
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
ptypes
.
TradeX
),
types
.
Encode
(
buy
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -86,7 +86,7 @@ func (cc *channelClient) CreateRawTradeSellMarketTx(ctx context.Context, in *pty
...
@@ -86,7 +86,7 @@ func (cc *channelClient) CreateRawTradeSellMarketTx(ctx context.Context, in *pty
}
}
buy
:=
&
ptypes
.
Trade
{
buy
:=
&
ptypes
.
Trade
{
Ty
:
ptypes
.
TradeSellMarket
,
Ty
:
ptypes
.
TradeSellMarket
,
Value
:
&
ptypes
.
Trade_SellMarket
{
in
},
Value
:
&
ptypes
.
Trade_SellMarket
{
SellMarket
:
in
},
}
}
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
ptypes
.
TradeX
),
types
.
Encode
(
buy
))
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
ptypes
.
TradeX
),
types
.
Encode
(
buy
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -103,7 +103,7 @@ func (cc *channelClient) CreateRawTradeRevokeBuyTx(ctx context.Context, in *ptyp
...
@@ -103,7 +103,7 @@ func (cc *channelClient) CreateRawTradeRevokeBuyTx(ctx context.Context, in *ptyp
}
}
buy
:=
&
ptypes
.
Trade
{
buy
:=
&
ptypes
.
Trade
{
Ty
:
ptypes
.
TradeRevokeBuy
,
Ty
:
ptypes
.
TradeRevokeBuy
,
Value
:
&
ptypes
.
Trade_RevokeBuy
{
in
},
Value
:
&
ptypes
.
Trade_RevokeBuy
{
RevokeBuy
:
in
},
}
}
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
ptypes
.
TradeX
),
types
.
Encode
(
buy
))
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
ptypes
.
TradeX
),
types
.
Encode
(
buy
))
if
err
!=
nil
{
if
err
!=
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