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
60252d13
Commit
60252d13
authored
Nov 26, 2018
by
harrylee2015
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into game
parents
e56fb37a
0ac1f080
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
230 additions
and
196 deletions
+230
-196
exec_local.go
plugin/dapp/cert/executor/exec_local.go
+12
-3
query.go
plugin/dapp/game/executor/query.go
+1
-1
exec_del_local.go
plugin/dapp/hashlock/executor/exec_del_local.go
+12
-3
exec_local.go
plugin/dapp/hashlock/executor/exec_local.go
+12
-3
ticket.go
plugin/dapp/ticket/wallet/ticket.go
+8
-1
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/cert/executor/exec_local.go
100644 → 100755
View file @
60252d13
...
@@ -17,11 +17,14 @@ func calcCertHeightKey(height int64) []byte {
...
@@ -17,11 +17,14 @@ func calcCertHeightKey(height int64) []byte {
}
}
// ExecLocal_New 启用证书交易执行
// ExecLocal_New 启用证书交易执行
func
(
c
*
Cert
)
ExecLocal_New
(
payload
*
ct
.
CertNew
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Cert
)
ExecLocal_New
(
payload
*
ct
.
CertNew
,
tx
*
types
.
Transaction
,
receiptData
types
.
ExecTypeGet
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
!
authority
.
IsAuthEnable
{
if
!
authority
.
IsAuthEnable
{
clog
.
Error
(
"Authority is not available. Please check the authority config or authority initialize error logs."
)
clog
.
Error
(
"Authority is not available. Please check the authority config or authority initialize error logs."
)
return
nil
,
ct
.
ErrInitializeAuthority
return
nil
,
ct
.
ErrInitializeAuthority
}
}
if
receiptData
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
var
set
types
.
LocalDBSet
var
set
types
.
LocalDBSet
historityCertdata
:=
&
types
.
HistoryCertStore
{}
historityCertdata
:=
&
types
.
HistoryCertStore
{}
...
@@ -46,11 +49,14 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt
...
@@ -46,11 +49,14 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt
}
}
// ExecLocal_Update 更新证书交易执行
// ExecLocal_Update 更新证书交易执行
func
(
c
*
Cert
)
ExecLocal_Update
(
payload
*
ct
.
CertUpdate
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Cert
)
ExecLocal_Update
(
payload
*
ct
.
CertUpdate
,
tx
*
types
.
Transaction
,
receiptData
types
.
ExecTypeGet
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
!
authority
.
IsAuthEnable
{
if
!
authority
.
IsAuthEnable
{
clog
.
Error
(
"Authority is not available. Please check the authority config or authority initialize error logs."
)
clog
.
Error
(
"Authority is not available. Please check the authority config or authority initialize error logs."
)
return
nil
,
ct
.
ErrInitializeAuthority
return
nil
,
ct
.
ErrInitializeAuthority
}
}
if
receiptData
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
var
set
types
.
LocalDBSet
var
set
types
.
LocalDBSet
// 写入上一纪录的next-height
// 写入上一纪录的next-height
...
@@ -76,11 +82,14 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r
...
@@ -76,11 +82,14 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r
}
}
// ExecLocal_Normal 非证书变更交易执行
// ExecLocal_Normal 非证书变更交易执行
func
(
c
*
Cert
)
ExecLocal_Normal
(
payload
*
ct
.
CertNormal
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Cert
)
ExecLocal_Normal
(
payload
*
ct
.
CertNormal
,
tx
*
types
.
Transaction
,
receiptData
types
.
ExecTypeGet
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
!
authority
.
IsAuthEnable
{
if
!
authority
.
IsAuthEnable
{
clog
.
Error
(
"Authority is not available. Please check the authority config or authority initialize error logs."
)
clog
.
Error
(
"Authority is not available. Please check the authority config or authority initialize error logs."
)
return
nil
,
ct
.
ErrInitializeAuthority
return
nil
,
ct
.
ErrInitializeAuthority
}
}
if
receiptData
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
var
set
types
.
LocalDBSet
var
set
types
.
LocalDBSet
return
&
set
,
nil
return
&
set
,
nil
...
...
plugin/dapp/game/executor/query.go
View file @
60252d13
...
@@ -30,5 +30,5 @@ func (g *Game) Query_QueryGameById(in *gt.QueryGameInfo) (types.Message, error)
...
@@ -30,5 +30,5 @@ func (g *Game) Query_QueryGameById(in *gt.QueryGameInfo) (types.Message, error)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
&
gt
.
ReplyGame
{
game
},
nil
return
&
gt
.
ReplyGame
{
Game
:
game
},
nil
}
}
plugin/dapp/hashlock/executor/exec_del_local.go
View file @
60252d13
...
@@ -11,7 +11,10 @@ import (
...
@@ -11,7 +11,10 @@ import (
)
)
// ExecDelLocal_Hlock Action
// ExecDelLocal_Hlock Action
func
(
h
*
Hashlock
)
ExecDelLocal_Hlock
(
hlock
*
pty
.
HashlockLock
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
h
*
Hashlock
)
ExecDelLocal_Hlock
(
hlock
*
pty
.
HashlockLock
,
tx
*
types
.
Transaction
,
receipt
types
.
ExecTypeGet
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
info
:=
pty
.
Hashlockquery
{
Time
:
hlock
.
Time
,
Status
:
hashlockLocked
,
Amount
:
hlock
.
Amount
,
CreateTime
:
h
.
GetBlockTime
(),
CurrentTime
:
0
}
info
:=
pty
.
Hashlockquery
{
Time
:
hlock
.
Time
,
Status
:
hashlockLocked
,
Amount
:
hlock
.
Amount
,
CreateTime
:
h
.
GetBlockTime
(),
CurrentTime
:
0
}
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
hlock
.
Hash
,
info
)
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
hlock
.
Hash
,
info
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -21,7 +24,10 @@ func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transac
...
@@ -21,7 +24,10 @@ func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transac
}
}
// ExecDelLocal_Hsend Action
// ExecDelLocal_Hsend Action
func
(
h
*
Hashlock
)
ExecDelLocal_Hsend
(
hsend
*
pty
.
HashlockSend
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
h
*
Hashlock
)
ExecDelLocal_Hsend
(
hsend
*
pty
.
HashlockSend
,
tx
*
types
.
Transaction
,
receipt
types
.
ExecTypeGet
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
info
:=
pty
.
Hashlockquery
{
Time
:
0
,
Status
:
hashlockSent
,
Amount
:
0
,
CreateTime
:
0
,
CurrentTime
:
0
}
info
:=
pty
.
Hashlockquery
{
Time
:
0
,
Status
:
hashlockSent
,
Amount
:
0
,
CreateTime
:
0
,
CurrentTime
:
0
}
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
common
.
Sha256
(
hsend
.
Secret
),
info
)
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
common
.
Sha256
(
hsend
.
Secret
),
info
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -31,7 +37,10 @@ func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transac
...
@@ -31,7 +37,10 @@ func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transac
}
}
// ExecDelLocal_Hunlock Action
// ExecDelLocal_Hunlock Action
func
(
h
*
Hashlock
)
ExecDelLocal_Hunlock
(
hunlock
*
pty
.
HashlockUnlock
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
h
*
Hashlock
)
ExecDelLocal_Hunlock
(
hunlock
*
pty
.
HashlockUnlock
,
tx
*
types
.
Transaction
,
receipt
types
.
ExecTypeGet
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
info
:=
pty
.
Hashlockquery
{
Time
:
0
,
Status
:
hashlockUnlocked
,
Amount
:
0
,
CreateTime
:
0
,
CurrentTime
:
0
}
info
:=
pty
.
Hashlockquery
{
Time
:
0
,
Status
:
hashlockUnlocked
,
Amount
:
0
,
CreateTime
:
0
,
CurrentTime
:
0
}
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
common
.
Sha256
(
hunlock
.
Secret
),
info
)
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
common
.
Sha256
(
hunlock
.
Secret
),
info
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/hashlock/executor/exec_local.go
View file @
60252d13
...
@@ -11,7 +11,10 @@ import (
...
@@ -11,7 +11,10 @@ import (
)
)
// ExecLocal_Hlock Action
// ExecLocal_Hlock Action
func
(
h
*
Hashlock
)
ExecLocal_Hlock
(
hlock
*
pty
.
HashlockLock
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
h
*
Hashlock
)
ExecLocal_Hlock
(
hlock
*
pty
.
HashlockLock
,
tx
*
types
.
Transaction
,
receipt
types
.
ExecTypeGet
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
info
:=
pty
.
Hashlockquery
{
Time
:
hlock
.
Time
,
Status
:
hashlockLocked
,
Amount
:
hlock
.
Amount
,
CreateTime
:
h
.
GetBlockTime
(),
CurrentTime
:
0
}
info
:=
pty
.
Hashlockquery
{
Time
:
hlock
.
Time
,
Status
:
hashlockLocked
,
Amount
:
hlock
.
Amount
,
CreateTime
:
h
.
GetBlockTime
(),
CurrentTime
:
0
}
clog
.
Error
(
"ExecLocal"
,
"info"
,
info
)
clog
.
Error
(
"ExecLocal"
,
"info"
,
info
)
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
hlock
.
Hash
,
info
)
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
hlock
.
Hash
,
info
)
...
@@ -22,7 +25,10 @@ func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transactio
...
@@ -22,7 +25,10 @@ func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transactio
}
}
// ExecLocal_Hsend Action
// ExecLocal_Hsend Action
func
(
h
*
Hashlock
)
ExecLocal_Hsend
(
hsend
*
pty
.
HashlockSend
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
h
*
Hashlock
)
ExecLocal_Hsend
(
hsend
*
pty
.
HashlockSend
,
tx
*
types
.
Transaction
,
receipt
types
.
ExecTypeGet
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
info
:=
pty
.
Hashlockquery
{
Time
:
0
,
Status
:
hashlockSent
,
Amount
:
0
,
CreateTime
:
0
,
CurrentTime
:
0
}
info
:=
pty
.
Hashlockquery
{
Time
:
0
,
Status
:
hashlockSent
,
Amount
:
0
,
CreateTime
:
0
,
CurrentTime
:
0
}
clog
.
Error
(
"ExecLocal"
,
"info"
,
info
)
clog
.
Error
(
"ExecLocal"
,
"info"
,
info
)
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
common
.
Sha256
(
hsend
.
Secret
),
info
)
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
common
.
Sha256
(
hsend
.
Secret
),
info
)
...
@@ -33,7 +39,10 @@ func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transactio
...
@@ -33,7 +39,10 @@ func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transactio
}
}
// ExecLocal_Hunlock Action
// ExecLocal_Hunlock Action
func
(
h
*
Hashlock
)
ExecLocal_Hunlock
(
hunlock
*
pty
.
HashlockUnlock
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
h
*
Hashlock
)
ExecLocal_Hunlock
(
hunlock
*
pty
.
HashlockUnlock
,
tx
*
types
.
Transaction
,
receipt
types
.
ExecTypeGet
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
info
:=
pty
.
Hashlockquery
{
Time
:
0
,
Status
:
hashlockUnlocked
,
Amount
:
0
,
CreateTime
:
0
,
CurrentTime
:
0
}
info
:=
pty
.
Hashlockquery
{
Time
:
0
,
Status
:
hashlockUnlocked
,
Amount
:
0
,
CreateTime
:
0
,
CurrentTime
:
0
}
clog
.
Error
(
"ExecLocal"
,
"info"
,
info
)
clog
.
Error
(
"ExecLocal"
,
"info"
,
info
)
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
common
.
Sha256
(
hunlock
.
Secret
),
info
)
kv
,
err
:=
UpdateHashReciver
(
h
.
GetLocalDB
(),
common
.
Sha256
(
hunlock
.
Secret
),
info
)
...
...
plugin/dapp/ticket/wallet/ticket.go
View file @
60252d13
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
package
wallet
package
wallet
import
(
import
(
"encoding/hex"
"fmt"
"fmt"
"sync"
"sync"
"sync/atomic"
"sync/atomic"
...
@@ -611,17 +612,20 @@ func (policy *ticketPolicy) buyTicket(height int64) ([][]byte, int, error) {
...
@@ -611,17 +612,20 @@ func (policy *ticketPolicy) buyTicket(height int64) ([][]byte, int, error) {
}
}
count
:=
0
count
:=
0
var
hashes
[][]
byte
var
hashes
[][]
byte
bizlog
.
Debug
(
"ticketPolicy buyTicket begin"
)
for
_
,
priv
:=
range
privs
{
for
_
,
priv
:=
range
privs
{
hash
,
n
,
err
:=
policy
.
buyTicketOne
(
height
,
priv
)
hash
,
n
,
err
:=
policy
.
buyTicketOne
(
height
,
priv
)
if
err
!=
nil
{
if
err
!=
nil
{
bizlog
.
Error
(
"buyTicketOne"
,
"err"
,
err
)
bizlog
.
Error
(
"
ticketPolicy buyTicket
buyTicketOne"
,
"err"
,
err
)
continue
continue
}
}
count
+=
n
count
+=
n
if
hash
!=
nil
{
if
hash
!=
nil
{
hashes
=
append
(
hashes
,
hash
)
hashes
=
append
(
hashes
,
hash
)
}
}
bizlog
.
Debug
(
"ticketPolicy buyTicket"
,
"Address"
,
address
.
PubKeyToAddress
(
priv
.
PubKey
()
.
Bytes
())
.
String
(),
"txhash"
,
hex
.
EncodeToString
(
hash
),
"n"
,
n
)
}
}
bizlog
.
Debug
(
"ticketPolicy buyTicket end"
)
return
hashes
,
count
,
nil
return
hashes
,
count
,
nil
}
}
...
@@ -705,6 +709,7 @@ func (policy *ticketPolicy) buyMinerAddrTicket(height int64) ([][]byte, int, err
...
@@ -705,6 +709,7 @@ func (policy *ticketPolicy) buyMinerAddrTicket(height int64) ([][]byte, int, err
}
}
count
:=
0
count
:=
0
var
hashes
[][]
byte
var
hashes
[][]
byte
bizlog
.
Debug
(
"ticketPolicy buyMinerAddrTicket begin"
)
for
_
,
priv
:=
range
privs
{
for
_
,
priv
:=
range
privs
{
hashlist
,
n
,
err
:=
policy
.
buyMinerAddrTicketOne
(
height
,
priv
)
hashlist
,
n
,
err
:=
policy
.
buyMinerAddrTicketOne
(
height
,
priv
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -717,7 +722,9 @@ func (policy *ticketPolicy) buyMinerAddrTicket(height int64) ([][]byte, int, err
...
@@ -717,7 +722,9 @@ func (policy *ticketPolicy) buyMinerAddrTicket(height int64) ([][]byte, int, err
if
hashlist
!=
nil
{
if
hashlist
!=
nil
{
hashes
=
append
(
hashes
,
hashlist
...
)
hashes
=
append
(
hashes
,
hashlist
...
)
}
}
bizlog
.
Debug
(
"ticketPolicy buyMinerAddrTicket"
,
"Address"
,
address
.
PubKeyToAddress
(
priv
.
PubKey
()
.
Bytes
())
.
String
(),
"n"
,
n
)
}
}
bizlog
.
Debug
(
"ticketPolicy buyMinerAddrTicket end"
)
return
hashes
,
count
,
nil
return
hashes
,
count
,
nil
}
}
...
...
plugin/dapp/trade/executor/exec_test.go
View file @
60252d13
...
@@ -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 @
60252d13
...
@@ -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 @
60252d13
...
@@ -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 @
60252d13
...
@@ -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 @
60252d13
...
@@ -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