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
fbcda598
Commit
fbcda598
authored
Dec 28, 2018
by
linj
Committed by
vipwzw
Dec 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix get tx by hash when query order
parent
43d38be7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
query.go
plugin/dapp/trade/executor/query.go
+6
-6
tradedb.go
plugin/dapp/trade/executor/tradedb.go
+10
-8
No files found.
plugin/dapp/trade/executor/query.go
View file @
fbcda598
...
...
@@ -254,7 +254,7 @@ func (t *trade) replyReplySellOrderfromID(key []byte) *pty.ReplySellOrder {
return
sellOrder2reply
(
sellorder
)
}
}
else
{
// txhash as key
txResult
,
err
:=
getTx
(
key
,
t
.
GetLocalDB
())
txResult
,
err
:=
getTx
(
key
,
t
.
GetLocalDB
()
,
t
.
GetAPI
()
)
tradelog
.
Debug
(
"GetOnesSellOrder "
,
"load txhash"
,
string
(
key
))
if
err
!=
nil
{
return
nil
...
...
@@ -272,7 +272,7 @@ func (t *trade) replyReplyBuyOrderfromID(key []byte) *pty.ReplyBuyOrder {
return
buyOrder2reply
(
buyOrder
)
}
}
else
{
// txhash as key
txResult
,
err
:=
getTx
(
key
,
t
.
GetLocalDB
())
txResult
,
err
:=
getTx
(
key
,
t
.
GetLocalDB
()
,
t
.
GetAPI
()
)
tradelog
.
Debug
(
"replyReplyBuyOrderfromID "
,
"load txhash"
,
string
(
key
))
if
err
!=
nil
{
return
nil
...
...
@@ -601,7 +601,7 @@ 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
())
txResult
,
err
:=
getTx
([]
byte
(
txHash
),
t
.
GetLocalDB
()
,
t
.
GetAPI
()
)
tradelog
.
Debug
(
"loadOrderFromKey "
,
"load txhash"
,
txResult
)
if
err
!=
nil
{
return
nil
...
...
@@ -618,7 +618,7 @@ func (t *trade) loadOrderFromKey(key []byte) *pty.ReplyTradeOrder {
return
reply
}
else
if
strings
.
HasPrefix
(
string
(
key
),
buyIDPrefix
)
{
txHash
:=
strings
.
Replace
(
string
(
key
),
buyIDPrefix
,
"0x"
,
1
)
txResult
,
err
:=
getTx
([]
byte
(
txHash
),
t
.
GetLocalDB
())
txResult
,
err
:=
getTx
([]
byte
(
txHash
),
t
.
GetLocalDB
()
,
t
.
GetAPI
()
)
tradelog
.
Debug
(
"loadOrderFromKey "
,
"load txhash"
,
txResult
)
if
err
!=
nil
{
return
nil
...
...
@@ -633,7 +633,7 @@ func (t *trade) loadOrderFromKey(key []byte) *pty.ReplyTradeOrder {
reply
.
Status
=
buyOrder
.
Status
return
reply
}
txResult
,
err
:=
getTx
(
key
,
t
.
GetLocalDB
())
txResult
,
err
:=
getTx
(
key
,
t
.
GetLocalDB
()
,
t
.
GetAPI
()
)
tradelog
.
Debug
(
"loadOrderFromKey "
,
"load txhash"
,
string
(
key
))
if
err
!=
nil
{
return
nil
...
...
@@ -644,7 +644,7 @@ func (t *trade) loadOrderFromKey(key []byte) *pty.ReplyTradeOrder {
func
(
t
*
trade
)
GetOnesOrderWithStatus
(
req
*
pty
.
ReqAddrAssets
)
(
types
.
Message
,
error
)
{
fromKey
:=
[]
byte
(
""
)
if
len
(
req
.
FromKey
)
!=
0
{
order
:=
t
.
loadOrderFromKey
(
fromKey
)
order
:=
t
.
loadOrderFromKey
(
[]
byte
(
req
.
FromKey
)
)
if
order
==
nil
{
tradelog
.
Error
(
"GetOnesOrderWithStatus"
,
"key not exist"
,
req
.
FromKey
)
return
nil
,
types
.
ErrInvalidParam
...
...
plugin/dapp/trade/executor/tradedb.go
View file @
fbcda598
...
...
@@ -10,6 +10,7 @@ import (
"strconv"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
...
...
@@ -110,22 +111,23 @@ func getSellOrderFromID(sellID []byte, db dbm.KV) (*pty.SellOrder, error) {
return
&
sellOrder
,
nil
}
func
getTx
(
txHash
[]
byte
,
db
dbm
.
KV
)
(
*
types
.
TxResult
,
error
)
{
func
getTx
(
txHash
[]
byte
,
db
dbm
.
KV
,
api
client
.
QueueProtocolAPI
)
(
*
types
.
TxResult
,
error
)
{
hash
,
err
:=
common
.
FromHex
(
string
(
txHash
))
if
err
!=
nil
{
return
nil
,
err
}
value
,
err
:=
db
.
Get
(
hash
)
value
,
err
:=
api
.
QueryTx
(
&
types
.
ReqHash
{
Hash
:
hash
}
)
if
err
!=
nil
{
tradelog
.
Error
(
"getTx"
,
"Failed to get value from db with getTx"
,
string
(
txHash
))
return
nil
,
err
}
var
txResult
types
.
TxResult
err
=
types
.
Decode
(
value
,
&
txResult
)
if
err
!=
nil
{
tradelog
.
Error
(
"getTx"
,
"Failed to decode TxResult"
,
string
(
txHash
))
return
nil
,
err
txResult
:=
types
.
TxResult
{
Height
:
value
.
Height
,
Index
:
int32
(
value
.
Index
),
Tx
:
value
.
Tx
,
Receiptdate
:
value
.
Receipt
,
Blocktime
:
value
.
Blocktime
,
ActionName
:
value
.
ActionName
,
}
return
&
txResult
,
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