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
8253c6eb
Commit
8253c6eb
authored
Jan 08, 2020
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove code : convert types from receipt
parent
4b959aa2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
115 deletions
+0
-115
query_v1.go
plugin/dapp/trade/executor/query_v1.go
+0
-115
No files found.
plugin/dapp/trade/executor/query_v1.go
View file @
8253c6eb
...
...
@@ -183,121 +183,6 @@ func (t *trade) GetOnesBuyOrdersWithStatus(req *pty.ReqAddrAssets) (types.Messag
}
// utils
func
(
t
*
trade
)
loadOrderFromKey
(
key
[]
byte
)
*
pty
.
ReplyTradeOrder
{
tradelog
.
Debug
(
"trade Query"
,
"id"
,
string
(
key
),
"check-prefix"
,
sellIDPrefix
)
if
strings
.
HasPrefix
(
string
(
key
),
sellIDPrefix
)
{
txHash
:=
strings
.
Replace
(
string
(
key
),
sellIDPrefix
,
"0x"
,
1
)
txResult
,
err
:=
getTx
([]
byte
(
txHash
),
t
.
GetLocalDB
(),
t
.
GetAPI
())
tradelog
.
Debug
(
"loadOrderFromKey "
,
"load txhash"
,
txResult
)
if
err
!=
nil
{
return
nil
}
reply
:=
limitOrderTxResult2Order
(
txResult
)
sellOrder
,
err
:=
getSellOrderFromID
(
key
,
t
.
GetStateDB
())
tradelog
.
Debug
(
"trade Query"
,
"getSellOrderFromID"
,
string
(
key
))
if
err
!=
nil
{
return
nil
}
reply
.
TradedBoardlot
=
sellOrder
.
SoldBoardlot
reply
.
Status
=
sellOrder
.
Status
return
reply
}
else
if
strings
.
HasPrefix
(
string
(
key
),
buyIDPrefix
)
{
txHash
:=
strings
.
Replace
(
string
(
key
),
buyIDPrefix
,
"0x"
,
1
)
txResult
,
err
:=
getTx
([]
byte
(
txHash
),
t
.
GetLocalDB
(),
t
.
GetAPI
())
tradelog
.
Debug
(
"loadOrderFromKey "
,
"load txhash"
,
txResult
)
if
err
!=
nil
{
return
nil
}
reply
:=
limitOrderTxResult2Order
(
txResult
)
buyOrder
,
err
:=
getBuyOrderFromID
(
key
,
t
.
GetStateDB
())
if
err
!=
nil
{
return
nil
}
reply
.
TradedBoardlot
=
buyOrder
.
BoughtBoardlot
reply
.
Status
=
buyOrder
.
Status
return
reply
}
txResult
,
err
:=
getTx
(
key
,
t
.
GetLocalDB
(),
t
.
GetAPI
())
tradelog
.
Debug
(
"loadOrderFromKey "
,
"load txhash"
,
string
(
key
))
if
err
!=
nil
{
return
nil
}
return
txResult2OrderReply
(
txResult
)
}
func
limitOrderTxResult2Order
(
txResult
*
types
.
TxResult
)
*
pty
.
ReplyTradeOrder
{
logs
:=
txResult
.
Receiptdate
.
Logs
tradelog
.
Debug
(
"txResult2sellOrderReply"
,
"show logs"
,
logs
)
for
_
,
log
:=
range
logs
{
if
log
.
Ty
==
pty
.
TyLogTradeSellLimit
{
var
receipt
pty
.
ReceiptTradeSellLimit
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
tradelog
.
Error
(
"txResult2sellOrderReply"
,
"decode receipt"
,
err
)
return
nil
}
tradelog
.
Debug
(
"txResult2sellOrderReply"
,
"show logs 1 "
,
receipt
)
return
sellBase2Order
(
receipt
.
Base
,
common
.
ToHex
(
txResult
.
GetTx
()
.
Hash
()),
txResult
.
Blocktime
)
}
else
if
log
.
Ty
==
pty
.
TyLogTradeBuyLimit
{
var
receipt
pty
.
ReceiptTradeBuyLimit
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
tradelog
.
Error
(
"txResult2sellOrderReply"
,
"decode receipt"
,
err
)
return
nil
}
tradelog
.
Debug
(
"txResult2sellOrderReply"
,
"show logs 1 "
,
receipt
)
return
buyBase2Order
(
receipt
.
Base
,
common
.
ToHex
(
txResult
.
GetTx
()
.
Hash
()),
txResult
.
Blocktime
)
}
}
return
nil
}
func
txResult2OrderReply
(
txResult
*
types
.
TxResult
)
*
pty
.
ReplyTradeOrder
{
logs
:=
txResult
.
Receiptdate
.
Logs
tradelog
.
Debug
(
"txResult2sellOrderReply"
,
"show logs"
,
logs
)
for
_
,
log
:=
range
logs
{
if
log
.
Ty
==
pty
.
TyLogTradeBuyMarket
{
var
receipt
pty
.
ReceiptTradeBuyMarket
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
tradelog
.
Error
(
"txResult2sellOrderReply"
,
"decode receipt"
,
err
)
return
nil
}
tradelog
.
Debug
(
"txResult2sellOrderReply"
,
"show logs 1 "
,
receipt
)
return
buyBase2Order
(
receipt
.
Base
,
common
.
ToHex
(
txResult
.
GetTx
()
.
Hash
()),
txResult
.
Blocktime
)
}
else
if
log
.
Ty
==
pty
.
TyLogTradeBuyRevoke
{
var
receipt
pty
.
ReceiptTradeBuyRevoke
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
tradelog
.
Error
(
"txResult2sellOrderReply"
,
"decode receipt"
,
err
)
return
nil
}
tradelog
.
Debug
(
"txResult2sellOrderReply"
,
"show logs 1 "
,
receipt
)
return
buyBase2Order
(
receipt
.
Base
,
common
.
ToHex
(
txResult
.
GetTx
()
.
Hash
()),
txResult
.
Blocktime
)
}
else
if
log
.
Ty
==
pty
.
TyLogTradeSellRevoke
{
var
receipt
pty
.
ReceiptTradeSellRevoke
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
tradelog
.
Error
(
"txResult2sellOrderReply"
,
"decode receipt"
,
err
)
return
nil
}
tradelog
.
Debug
(
"txResult2sellOrderReply"
,
"show revoke 1 "
,
receipt
)
return
sellBase2Order
(
receipt
.
Base
,
common
.
ToHex
(
txResult
.
GetTx
()
.
Hash
()),
txResult
.
Blocktime
)
}
else
if
log
.
Ty
==
pty
.
TyLogTradeSellMarket
{
var
receipt
pty
.
ReceiptSellMarket
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
tradelog
.
Error
(
"txResult2sellOrderReply"
,
"decode receipt"
,
err
)
return
nil
}
tradelog
.
Debug
(
"txResult2sellOrderReply"
,
"show logs 1 "
,
receipt
)
return
sellBase2Order
(
receipt
.
Base
,
common
.
ToHex
(
txResult
.
GetTx
()
.
Hash
()),
txResult
.
Blocktime
)
}
}
return
nil
}
// SellMarkMarket BuyMarket 没有tradeOrder 需要调用这个函数进行转化
// BuyRevoke, SellRevoke 也需要
...
...
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