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
61485a4a
Commit
61485a4a
authored
Oct 28, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify newAccountDB Adaptive
parent
dc4202e3
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
80 additions
and
68 deletions
+80
-68
game_test.go
plugin/dapp/game/executor/game_test.go
+4
-4
account.go
plugin/dapp/js/executor/account.go
+2
-1
action.go
plugin/dapp/multisig/executor/action.go
+4
-2
multisig.go
plugin/dapp/multisig/executor/multisig.go
+2
-3
account.go
plugin/dapp/paracross/executor/account.go
+4
-4
action.go
plugin/dapp/paracross/executor/action.go
+7
-4
asset.go
plugin/dapp/paracross/executor/asset.go
+5
-5
assettransfer_test.go
plugin/dapp/paracross/executor/assettransfer_test.go
+3
-3
assetwithdraw_test.go
plugin/dapp/paracross/executor/assetwithdraw_test.go
+1
-1
exec.go
plugin/dapp/privacy/executor/exec.go
+2
-2
retrievedb.go
plugin/dapp/retrieve/executor/retrievedb.go
+1
-1
ticketdb.go
plugin/dapp/ticket/executor/ticketdb.go
+3
-3
exec.go
plugin/dapp/token/executor/exec.go
+6
-3
exec_del_local.go
plugin/dapp/token/executor/exec_del_local.go
+3
-3
exec_local.go
plugin/dapp/token/executor/exec_local.go
+3
-3
query.go
plugin/dapp/token/executor/query.go
+1
-1
token.go
plugin/dapp/token/executor/token.go
+4
-3
token_test.go
plugin/dapp/token/executor/token_test.go
+3
-3
tokendb.go
plugin/dapp/token/executor/tokendb.go
+5
-4
rpc.go
plugin/dapp/token/rpc/rpc.go
+3
-2
exec_test.go
plugin/dapp/trade/executor/exec_test.go
+4
-4
util.go
plugin/dapp/trade/executor/util.go
+4
-4
exec.go
plugin/dapp/unfreeze/executor/exec.go
+4
-3
exec_test.go
plugin/dapp/unfreeze/executor/exec_test.go
+2
-2
No files found.
plugin/dapp/game/executor/game_test.go
View file @
61485a4a
...
...
@@ -66,16 +66,16 @@ func TestGame(t *testing.T) {
stateDB
,
_
:=
dbm
.
NewGoMemDB
(
"1"
,
"2"
,
1000
)
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
accA
,
_
:=
account
.
NewAccountDB
(
"coins"
,
"bty"
,
stateDB
)
accA
,
_
:=
account
.
NewAccountDB
(
cfg
,
"coins"
,
"bty"
,
stateDB
)
accA
.
SaveExecAccount
(
execAddr
,
&
accountA
)
accB
,
_
:=
account
.
NewAccountDB
(
"coins"
,
"bty"
,
stateDB
)
accB
,
_
:=
account
.
NewAccountDB
(
cfg
,
"coins"
,
"bty"
,
stateDB
)
accB
.
SaveExecAccount
(
execAddr
,
&
accountB
)
accC
,
_
:=
account
.
NewAccountDB
(
"coins"
,
"bty"
,
stateDB
)
accC
,
_
:=
account
.
NewAccountDB
(
cfg
,
"coins"
,
"bty"
,
stateDB
)
accC
.
SaveExecAccount
(
execAddr
,
&
accountC
)
accD
,
_
:=
account
.
NewAccountDB
(
"coins"
,
"bty"
,
stateDB
)
accD
,
_
:=
account
.
NewAccountDB
(
cfg
,
"coins"
,
"bty"
,
stateDB
)
accD
.
SaveExecAccount
(
execAddr
,
&
accountD
)
env
:=
execEnv
{
10
,
...
...
plugin/dapp/js/executor/account.go
View file @
61485a4a
...
...
@@ -65,7 +65,8 @@ func (u *js) getAccount(args otto.Value) (*account.DB, error) {
if
err
!=
nil
{
return
nil
,
err
}
return
account
.
NewAccountDB
(
execer
,
symbol
,
u
.
GetStateDB
())
cfg
:=
u
.
GetAPI
()
.
GetConfig
()
return
account
.
NewAccountDB
(
cfg
,
execer
,
symbol
,
u
.
GetStateDB
())
}
func
(
u
*
js
)
genesisInitExecFunc
(
vm
*
otto
.
Otto
)
{
...
...
plugin/dapp/multisig/executor/action.go
View file @
61485a4a
...
...
@@ -269,7 +269,8 @@ func (a *action) MultiSigExecTransferTo(execTransfer *mty.MultiSigExecTransferTo
//将指定账户上的资产从balance转账到多重签名账户的balance上
symbol
:=
getRealSymbol
(
execTransfer
.
Symbol
)
newAccountDB
,
err
:=
account
.
NewAccountDB
(
execTransfer
.
Execname
,
symbol
,
a
.
db
)
cfg
:=
a
.
api
.
GetConfig
()
newAccountDB
,
err
:=
account
.
NewAccountDB
(
cfg
,
execTransfer
.
Execname
,
symbol
,
a
.
db
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -768,7 +769,8 @@ func (a *action) executeTransferTx(multiSigAcc *mty.MultiSig, newMultiSigTx *mty
//执行此交易,从多重签名账户转币到指定账户,在multiSig合约中转账
symbol
:=
getRealSymbol
(
transfer
.
Symbol
)
execerAccDB
,
err
:=
account
.
NewAccountDB
(
transfer
.
Execname
,
symbol
,
a
.
db
)
cfg
:=
a
.
api
.
GetConfig
()
execerAccDB
,
err
:=
account
.
NewAccountDB
(
cfg
,
transfer
.
Execname
,
symbol
,
a
.
db
)
if
err
!=
nil
{
multisiglog
.
Error
(
"executeTransaction:NewAccountDB"
,
"From"
,
transfer
.
From
,
"To"
,
transfer
.
To
,
"execaddr"
,
a
.
execaddr
,
"amount"
,
amount
,
"Execer"
,
transfer
.
Execname
,
"Symbol"
,
transfer
.
Symbol
,
"error"
,
err
)
...
...
plugin/dapp/multisig/executor/multisig.go
View file @
61485a4a
...
...
@@ -881,14 +881,13 @@ func (m *MultiSig) saveMultiSigTxCountUpdate(accTxCount mty.ReceiptTxCountUpdate
//获取多重签名账户的指定资产
func
(
m
*
MultiSig
)
getMultiSigAccAssets
(
multiSigAddr
string
,
assets
*
mty
.
Assets
)
(
*
types
.
Account
,
error
)
{
symbol
:=
getRealSymbol
(
assets
.
Symbol
)
acc
,
err
:=
account
.
NewAccountDB
(
assets
.
Execer
,
symbol
,
m
.
GetStateDB
())
cfg
:=
m
.
GetAPI
()
.
GetConfig
()
acc
,
err
:=
account
.
NewAccountDB
(
cfg
,
assets
.
Execer
,
symbol
,
m
.
GetStateDB
())
if
err
!=
nil
{
return
&
types
.
Account
{},
err
}
var
acc1
*
types
.
Account
cfg
:=
m
.
GetAPI
()
.
GetConfig
()
execaddress
:=
dapp
.
ExecAddress
(
cfg
.
ExecName
(
m
.
GetName
()))
acc1
=
acc
.
LoadExecAccount
(
multiSigAddr
,
execaddress
)
return
acc1
,
nil
...
...
plugin/dapp/paracross/executor/account.go
View file @
61485a4a
...
...
@@ -20,13 +20,13 @@ import (
// symbol: coins.bty, token.{TEST}
// 完整的帐号地址 mavl-{paracross}-coins.bty-{user-address} 不带title{paracross}
// 对应主链上paracross 子帐号 malv-coins-bty-exec-{Address(paracross)}:{Address(user.p.{guodun}.paracross)}
func
NewParaAccount
(
paraTitle
,
mainExecName
,
mainSymbol
string
,
db
db
.
KV
)
(
*
account
.
DB
,
error
)
{
func
NewParaAccount
(
cfg
*
types
.
Chain33Config
,
paraTitle
,
mainExecName
,
mainSymbol
string
,
db
db
.
KV
)
(
*
account
.
DB
,
error
)
{
// 按照现在的配置, title 是 带 "." 做结尾
// paraExec := paraTitle + types.ParaX
paraExec
:=
pt
.
ParaX
// 现在平行链是执行器注册和算地址是不带前缀的,
// 如果能确保(或规定) tokne 的 symbol 和 coins 中的 symbol 不会混淆, localExecName 可以不要
paraSymbol
:=
mainExecName
+
"."
+
mainSymbol
return
account
.
NewAccountDB
(
paraExec
,
paraSymbol
,
db
)
return
account
.
NewAccountDB
(
cfg
,
paraExec
,
paraSymbol
,
db
)
}
//NewMainAccount create new Main account
...
...
@@ -35,9 +35,9 @@ func NewParaAccount(paraTitle, mainExecName, mainSymbol string, db db.KV) (*acco
// symbol: user.p.{guodun}.coins.{guodun} user.p.{guodun}.token.{TEST}
// 完整的帐号地址 mavl-paracross-user.p.{guodun}.coins.guodun-{user-address}
// 对应平行链上子地址 mavl-coins-{guodun}-exec-{Address(paracross)}:{Address(paracross)}
func
NewMainAccount
(
paraTitle
,
paraExecName
,
paraSymbol
string
,
db
db
.
KV
)
(
*
account
.
DB
,
error
)
{
func
NewMainAccount
(
cfg
*
types
.
Chain33Config
,
paraTitle
,
paraExecName
,
paraSymbol
string
,
db
db
.
KV
)
(
*
account
.
DB
,
error
)
{
mainSymbol
:=
paraTitle
+
paraExecName
+
"."
+
paraSymbol
return
account
.
NewAccountDB
(
pt
.
ParaX
,
mainSymbol
,
db
)
return
account
.
NewAccountDB
(
cfg
,
pt
.
ParaX
,
mainSymbol
,
db
)
}
func
assetDepositBalance
(
acc
*
account
.
DB
,
addr
string
,
amount
int64
)
(
*
types
.
Receipt
,
error
)
{
...
...
plugin/dapp/paracross/executor/action.go
View file @
61485a4a
...
...
@@ -965,7 +965,7 @@ func (a *action) Miner(miner *pt.ParacrossMinerAction) (*types.Receipt, error) {
totalReward
*=
types
.
Coin
if
totalReward
>
0
{
issueReceipt
,
err
:=
a
.
coinsAccount
.
ExecIssueCoins
(
cfg
,
a
.
execaddr
,
totalReward
)
issueReceipt
,
err
:=
a
.
coinsAccount
.
ExecIssueCoins
(
a
.
execaddr
,
totalReward
)
if
err
!=
nil
{
clog
.
Error
(
"paracross miner issue err"
,
"height"
,
miner
.
Status
.
Height
,
...
...
@@ -1016,7 +1016,8 @@ func (a *action) Transfer(transfer *types.AssetsTransfer, tx *types.Transaction,
transfer
.
Amount
,
"to"
,
tx
.
To
)
from
:=
tx
.
From
()
acc
,
err
:=
account
.
NewAccountDB
(
pt
.
ParaX
,
transfer
.
Cointoken
,
a
.
db
)
cfg
:=
a
.
api
.
GetConfig
()
acc
,
err
:=
account
.
NewAccountDB
(
cfg
,
pt
.
ParaX
,
transfer
.
Cointoken
,
a
.
db
)
if
err
!=
nil
{
clog
.
Error
(
"Transfer failed"
,
"err"
,
err
)
return
nil
,
err
...
...
@@ -1031,7 +1032,8 @@ func (a *action) Transfer(transfer *types.AssetsTransfer, tx *types.Transaction,
func
(
a
*
action
)
Withdraw
(
withdraw
*
types
.
AssetsWithdraw
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
clog
.
Debug
(
"Paracross.Exec Withdraw"
,
"symbol"
,
withdraw
.
Cointoken
,
"amount"
,
withdraw
.
Amount
,
"to"
,
tx
.
To
)
acc
,
err
:=
account
.
NewAccountDB
(
pt
.
ParaX
,
withdraw
.
Cointoken
,
a
.
db
)
cfg
:=
a
.
api
.
GetConfig
()
acc
,
err
:=
account
.
NewAccountDB
(
cfg
,
pt
.
ParaX
,
withdraw
.
Cointoken
,
a
.
db
)
if
err
!=
nil
{
clog
.
Error
(
"Withdraw failed"
,
"err"
,
err
)
return
nil
,
err
...
...
@@ -1047,7 +1049,8 @@ func (a *action) TransferToExec(transfer *types.AssetsTransferToExec, tx *types.
transfer
.
Amount
,
"to"
,
tx
.
To
)
from
:=
tx
.
From
()
acc
,
err
:=
account
.
NewAccountDB
(
pt
.
ParaX
,
transfer
.
Cointoken
,
a
.
db
)
cfg
:=
a
.
api
.
GetConfig
()
acc
,
err
:=
account
.
NewAccountDB
(
cfg
,
pt
.
ParaX
,
transfer
.
Cointoken
,
a
.
db
)
if
err
!=
nil
{
clog
.
Error
(
"TransferToExec failed"
,
"err"
,
err
)
return
nil
,
err
...
...
plugin/dapp/paracross/executor/asset.go
View file @
61485a4a
...
...
@@ -41,9 +41,9 @@ func (a *action) assetTransfer(transfer *types.AssetsTransfer) (*types.Receipt,
}
var
paraAcc
*
account
.
DB
if
transfer
.
Cointoken
==
""
{
paraAcc
,
err
=
NewParaAccount
(
string
(
paraTitle
),
"coins"
,
"bty"
,
a
.
db
)
paraAcc
,
err
=
NewParaAccount
(
cfg
,
string
(
paraTitle
),
"coins"
,
"bty"
,
a
.
db
)
}
else
{
paraAcc
,
err
=
NewParaAccount
(
string
(
paraTitle
),
"token"
,
transfer
.
Cointoken
,
a
.
db
)
paraAcc
,
err
=
NewParaAccount
(
cfg
,
string
(
paraTitle
),
"token"
,
transfer
.
Cointoken
,
a
.
db
)
}
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"assetTransferCoins call NewParaAccount failed"
)
...
...
@@ -75,9 +75,9 @@ func (a *action) assetWithdraw(withdraw *types.AssetsWithdraw, withdrawTx *types
}
var
paraAcc
*
account
.
DB
if
withdraw
.
Cointoken
==
""
{
paraAcc
,
err
=
NewParaAccount
(
string
(
paraTitle
),
"coins"
,
"bty"
,
a
.
db
)
paraAcc
,
err
=
NewParaAccount
(
cfg
,
string
(
paraTitle
),
"coins"
,
"bty"
,
a
.
db
)
}
else
{
paraAcc
,
err
=
NewParaAccount
(
string
(
paraTitle
),
"token"
,
withdraw
.
Cointoken
,
a
.
db
)
paraAcc
,
err
=
NewParaAccount
(
cfg
,
string
(
paraTitle
),
"token"
,
withdraw
.
Cointoken
,
a
.
db
)
}
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"assetWithdrawCoins call NewParaAccount failed"
)
...
...
@@ -94,7 +94,7 @@ func createAccount(cfg *types.Chain33Config, db db.KV, symbol string) (*account.
accDB
=
account
.
NewCoinsAccount
(
cfg
)
accDB
.
SetDB
(
db
)
}
else
{
accDB
,
err
=
account
.
NewAccountDB
(
"token"
,
symbol
,
db
)
accDB
,
err
=
account
.
NewAccountDB
(
cfg
,
"token"
,
symbol
,
db
)
}
return
accDB
,
err
}
plugin/dapp/paracross/executor/assettransfer_test.go
View file @
61485a4a
...
...
@@ -197,7 +197,7 @@ func (suite *AssetTransferTestSuite) TestExecTransferInPara() {
suite
.
T
()
.
Log
(
string
(
kv
.
Key
),
v
)
}
acc
,
_
:=
NewParaAccount
(
Title
,
"coins"
,
"bty"
,
suite
.
stateDB
)
acc
,
_
:=
NewParaAccount
(
chain33TestCfg
,
Title
,
"coins"
,
"bty"
,
suite
.
stateDB
)
resultB
:=
acc
.
LoadAccount
(
string
(
toB
))
assert
.
Equal
(
suite
.
T
(),
Amount
,
resultB
.
Balance
)
}
...
...
@@ -244,7 +244,7 @@ func (suite *AssetTransferTestSuite) TestExecTransferToken() {
Frozen
:
0
,
Addr
:
string
(
Nodes
[
0
]),
}
acc
,
_
:=
account
.
NewAccountDB
(
"token"
,
TestSymbol
,
suite
.
stateDB
)
acc
,
_
:=
account
.
NewAccountDB
(
chain33TestMainCfg
,
"token"
,
TestSymbol
,
suite
.
stateDB
)
addrMain
:=
address
.
ExecAddress
(
pt
.
ParaX
)
addrPara
:=
address
.
ExecAddress
(
Title
+
pt
.
ParaX
)
...
...
@@ -306,7 +306,7 @@ func (suite *AssetTransferTestSuite) TestExecTransferTokenInPara() {
suite
.
T
()
.
Log
(
string
(
kv
.
Key
),
v
)
}
acc
,
_
:=
NewParaAccount
(
Title
,
"token"
,
TestSymbol
,
suite
.
stateDB
)
acc
,
_
:=
NewParaAccount
(
chain33TestCfg
,
Title
,
"token"
,
TestSymbol
,
suite
.
stateDB
)
resultB
:=
acc
.
LoadAccount
(
string
(
toB
))
assert
.
Equal
(
suite
.
T
(),
Amount
,
resultB
.
Balance
)
}
...
...
plugin/dapp/paracross/executor/assetwithdraw_test.go
View file @
61485a4a
...
...
@@ -120,7 +120,7 @@ func (suite *AssetWithdrawTestSuite) TestExecAssetWithdrawOnParaChain() {
Frozen
:
0
,
Addr
:
string
(
Nodes
[
0
]),
}
paraAcc
,
_
:=
NewParaAccount
(
Title
,
"coins"
,
"bty"
,
suite
.
stateDB
)
paraAcc
,
_
:=
NewParaAccount
(
chain33TestCfg
,
Title
,
"coins"
,
"bty"
,
suite
.
stateDB
)
paraAcc
.
SaveAccount
(
&
accountA
)
tx
,
err
:=
createAssetWithdrawTx
(
suite
.
Suite
,
PrivKeyA
,
Nodes
[
1
])
...
...
plugin/dapp/privacy/executor/exec.go
View file @
61485a4a
...
...
@@ -152,6 +152,6 @@ func (p *privacy) createAccountDB(exec, symbol string) (*account.DB, error) {
if
exec
==
""
||
exec
==
"coins"
{
return
p
.
GetCoinsAccount
(),
nil
}
return
account
.
NewAccountDB
(
exec
,
symbol
,
p
.
GetStateDB
())
cfg
:=
p
.
GetAPI
()
.
GetConfig
()
return
account
.
NewAccountDB
(
cfg
,
exec
,
symbol
,
p
.
GetStateDB
())
}
plugin/dapp/retrieve/executor/retrievedb.go
View file @
61485a4a
...
...
@@ -219,7 +219,7 @@ func (action *Action) RetrievePerformAssets(perfRet *rt.PerformRetrieve, default
}
for
_
,
asset
:=
range
perfRet
.
Assets
{
accdb
,
err
:=
account
.
NewAccountDB
(
asset
.
Exec
,
asset
.
Symbol
,
action
.
db
)
accdb
,
err
:=
account
.
NewAccountDB
(
cfg
,
asset
.
Exec
,
asset
.
Symbol
,
action
.
db
)
if
err
!=
nil
{
rlog
.
Error
(
"RetrievePerform"
,
"NewAccountDB"
,
err
)
return
nil
,
err
...
...
plugin/dapp/ticket/executor/ticketdb.go
View file @
61485a4a
...
...
@@ -339,7 +339,7 @@ func (action *Action) TicketMiner(miner *ty.TicketMiner, index int) (*types.Rece
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
//user
receipt1
,
err
:=
action
.
coinsAccount
.
ExecDepositFrozen
(
chain33Cfg
,
t
.
ReturnAddress
,
action
.
execaddr
,
ticket
.
MinerValue
)
receipt1
,
err
:=
action
.
coinsAccount
.
ExecDepositFrozen
(
t
.
ReturnAddress
,
action
.
execaddr
,
ticket
.
MinerValue
)
if
err
!=
nil
{
tlog
.
Error
(
"TicketMiner.ExecDepositFrozen user"
,
"addr"
,
t
.
ReturnAddress
,
"execaddr"
,
action
.
execaddr
)
return
nil
,
err
...
...
@@ -349,13 +349,13 @@ func (action *Action) TicketMiner(miner *ty.TicketMiner, index int) (*types.Rece
if
chain33Cfg
.
IsFork
(
action
.
height
,
"ForkTicketFundAddrV1"
)
{
// issue coins to exec addr
addr
:=
chain33Cfg
.
MGStr
(
"mver.consensus.fundKeyAddr"
,
action
.
height
)
receipt2
,
err
=
action
.
coinsAccount
.
ExecIssueCoins
(
chain33Cfg
,
addr
,
cfg
.
CoinDevFund
)
receipt2
,
err
=
action
.
coinsAccount
.
ExecIssueCoins
(
addr
,
cfg
.
CoinDevFund
)
if
err
!=
nil
{
tlog
.
Error
(
"TicketMiner.ExecDepositFrozen fund to autonomy fund"
,
"addr"
,
addr
,
"error"
,
err
)
return
nil
,
err
}
}
else
{
receipt2
,
err
=
action
.
coinsAccount
.
ExecDepositFrozen
(
chain33Cfg
,
chain33Cfg
.
GetFundAddr
(),
action
.
execaddr
,
cfg
.
CoinDevFund
)
receipt2
,
err
=
action
.
coinsAccount
.
ExecDepositFrozen
(
chain33Cfg
.
GetFundAddr
(),
action
.
execaddr
,
cfg
.
CoinDevFund
)
if
err
!=
nil
{
tlog
.
Error
(
"TicketMiner.ExecDepositFrozen fund"
,
"addr"
,
chain33Cfg
.
GetFundAddr
(),
"execaddr"
,
action
.
execaddr
,
"error"
,
err
)
return
nil
,
err
...
...
plugin/dapp/token/executor/exec.go
View file @
61485a4a
...
...
@@ -12,7 +12,8 @@ import (
func
(
t
*
token
)
Exec_Transfer
(
payload
*
types
.
AssetsTransfer
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
token
:=
payload
.
GetCointoken
()
db
,
err
:=
account
.
NewAccountDB
(
t
.
GetName
(),
token
,
t
.
GetStateDB
())
cfg
:=
t
.
GetAPI
()
.
GetConfig
()
db
,
err
:=
account
.
NewAccountDB
(
cfg
,
t
.
GetName
(),
token
,
t
.
GetStateDB
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -27,7 +28,8 @@ func (t *token) Exec_Transfer(payload *types.AssetsTransfer, tx *types.Transacti
func
(
t
*
token
)
Exec_Withdraw
(
payload
*
types
.
AssetsWithdraw
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
token
:=
payload
.
GetCointoken
()
db
,
err
:=
account
.
NewAccountDB
(
t
.
GetName
(),
token
,
t
.
GetStateDB
())
cfg
:=
t
.
GetAPI
()
.
GetConfig
()
db
,
err
:=
account
.
NewAccountDB
(
cfg
,
t
.
GetName
(),
token
,
t
.
GetStateDB
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -58,7 +60,8 @@ func (t *token) Exec_TokenRevokeCreate(payload *tokenty.TokenRevokeCreate, tx *t
func
(
t
*
token
)
Exec_TransferToExec
(
payload
*
types
.
AssetsTransferToExec
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
token
:=
payload
.
GetCointoken
()
db
,
err
:=
account
.
NewAccountDB
(
t
.
GetName
(),
token
,
t
.
GetStateDB
())
cfg
:=
t
.
GetAPI
()
.
GetConfig
()
db
,
err
:=
account
.
NewAccountDB
(
cfg
,
t
.
GetName
(),
token
,
t
.
GetStateDB
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
plugin/dapp/token/executor/exec_del_local.go
View file @
61485a4a
...
...
@@ -32,7 +32,7 @@ func (t *token) ExecDelLocal_Transfer(payload *types.AssetsTransfer, tx *types.T
if
err
!=
nil
{
return
nil
,
err
}
if
c
fg
.
SaveTokenTxList
{
if
subC
fg
.
SaveTokenTxList
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionTransfer
,
Value
:
&
tokenty
.
TokenAction_Transfer
{
...
...
@@ -53,7 +53,7 @@ func (t *token) ExecDelLocal_Withdraw(payload *types.AssetsWithdraw, tx *types.T
if
err
!=
nil
{
return
nil
,
err
}
if
c
fg
.
SaveTokenTxList
{
if
subC
fg
.
SaveTokenTxList
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionWithdraw
,
Value
:
&
tokenty
.
TokenAction_Withdraw
{
...
...
@@ -74,7 +74,7 @@ func (t *token) ExecDelLocal_TransferToExec(payload *types.AssetsTransferToExec,
if
err
!=
nil
{
return
nil
,
err
}
if
c
fg
.
SaveTokenTxList
{
if
subC
fg
.
SaveTokenTxList
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionTransferToExec
,
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
...
...
plugin/dapp/token/executor/exec_local.go
View file @
61485a4a
...
...
@@ -24,7 +24,7 @@ func (t *token) ExecLocal_Transfer(payload *types.AssetsTransfer, tx *types.Tran
if
kv
!=
nil
{
set
.
KV
=
append
(
set
.
KV
,
kv
...
)
}
if
c
fg
.
SaveTokenTxList
{
if
subC
fg
.
SaveTokenTxList
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionTransfer
,
Value
:
&
tokenty
.
TokenAction_Transfer
{
...
...
@@ -50,7 +50,7 @@ func (t *token) ExecLocal_Withdraw(payload *types.AssetsWithdraw, tx *types.Tran
if
kv
!=
nil
{
set
.
KV
=
append
(
set
.
KV
,
kv
...
)
}
if
c
fg
.
SaveTokenTxList
{
if
subC
fg
.
SaveTokenTxList
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionWithdraw
,
Value
:
&
tokenty
.
TokenAction_Withdraw
{
...
...
@@ -71,7 +71,7 @@ func (t *token) ExecLocal_TransferToExec(payload *types.AssetsTransferToExec, tx
if
err
!=
nil
{
return
nil
,
err
}
if
c
fg
.
SaveTokenTxList
{
if
subC
fg
.
SaveTokenTxList
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionTransferToExec
,
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
...
...
plugin/dapp/token/executor/query.go
View file @
61485a4a
...
...
@@ -64,7 +64,7 @@ func (t *token) Query_GetTxByToken(in *tokenty.ReqTokenTx) (types.Message, error
if
in
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
if
!
c
fg
.
SaveTokenTxList
{
if
!
subC
fg
.
SaveTokenTxList
{
return
nil
,
types
.
ErrActionNotSupport
}
return
t
.
getTxByToken
(
in
)
...
...
plugin/dapp/token/executor/token.go
View file @
61485a4a
...
...
@@ -38,12 +38,12 @@ type subConfig struct {
SaveTokenTxList
bool
`json:"saveTokenTxList"`
}
var
c
fg
subConfig
var
subC
fg
subConfig
// Init 重命名执行器名称
func
Init
(
name
string
,
cfg
*
types
.
Chain33Config
,
sub
[]
byte
)
{
if
sub
!=
nil
{
types
.
MustDecode
(
sub
,
&
c
fg
)
types
.
MustDecode
(
sub
,
&
subC
fg
)
}
drivers
.
Register
(
cfg
,
GetName
(),
newToken
,
cfg
.
GetDappFork
(
driverName
,
"Enable"
))
InitExecType
()
...
...
@@ -102,8 +102,9 @@ func (t *token) getAccountTokenAssets(req *tokenty.ReqAccountTokenAssets) (types
if
err
!=
nil
{
return
nil
,
err
}
cfg
:=
t
.
GetAPI
()
.
GetConfig
()
for
_
,
asset
:=
range
assets
.
Datas
{
acc
,
err
:=
account
.
NewAccountDB
(
t
.
GetName
(),
asset
,
t
.
GetStateDB
())
acc
,
err
:=
account
.
NewAccountDB
(
cfg
,
t
.
GetName
(),
asset
,
t
.
GetStateDB
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
plugin/dapp/token/executor/token_test.go
View file @
61485a4a
...
...
@@ -66,10 +66,10 @@ func TestToken(t *testing.T) {
stateDB
,
_
:=
dbm
.
NewGoMemDB
(
"1"
,
"2"
,
100
)
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
accA
,
_
:=
account
.
NewAccountDB
(
AssetExecPara
,
Symbol
,
stateDB
)
accA
,
_
:=
account
.
NewAccountDB
(
cfg
,
AssetExecPara
,
Symbol
,
stateDB
)
accA
.
SaveExecAccount
(
execAddr
,
&
accountA
)
accB
,
_
:=
account
.
NewAccountDB
(
AssetExecPara
,
Symbol
,
stateDB
)
accB
,
_
:=
account
.
NewAccountDB
(
cfg
,
AssetExecPara
,
Symbol
,
stateDB
)
accB
.
SaveExecAccount
(
execAddr
,
&
accountB
)
env
:=
execEnv
{
...
...
@@ -188,7 +188,7 @@ func TestToken(t *testing.T) {
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
accDB
,
_
:=
account
.
NewAccountDB
(
pty
.
TokenX
,
Symbol
,
stateDB
)
accDB
,
_
:=
account
.
NewAccountDB
(
cfg
,
pty
.
TokenX
,
Symbol
,
stateDB
)
accCheck
:=
accDB
.
LoadAccount
(
string
(
Nodes
[
0
]))
assert
.
Equal
(
t
,
tokenTotal
,
accCheck
.
Balance
)
...
...
plugin/dapp/token/executor/tokendb.go
View file @
61485a4a
...
...
@@ -276,7 +276,7 @@ func (action *tokenAction) finishCreate(tokenFinish *pty.TokenFinishCreate) (*ty
//创建token类型的账户,同时需要创建的额度存入
tokenAccount
,
err
:=
account
.
NewAccountDB
(
"token"
,
tokenFinish
.
GetSymbol
(),
action
.
db
)
tokenAccount
,
err
:=
account
.
NewAccountDB
(
cfg
,
"token"
,
tokenFinish
.
GetSymbol
(),
action
.
db
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -575,7 +575,8 @@ func (action *tokenAction) mint(mint *pty.TokenMint) (*types.Receipt, error) {
return
nil
,
err
}
tokenAccount
,
err
:=
account
.
NewAccountDB
(
"token"
,
mint
.
GetSymbol
(),
action
.
db
)
cfg
:=
action
.
api
.
GetConfig
()
tokenAccount
,
err
:=
account
.
NewAccountDB
(
cfg
,
"token"
,
mint
.
GetSymbol
(),
action
.
db
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -614,8 +615,8 @@ func (action *tokenAction) burn(burn *pty.TokenBurn) (*types.Receipt, error) {
tokenlog
.
Error
(
"token burn "
,
"symbol"
,
burn
.
GetSymbol
(),
"error"
,
err
,
"from"
,
action
.
fromaddr
,
"owner"
,
tokendb
.
token
.
Owner
)
return
nil
,
err
}
tokenAccount
,
err
:=
account
.
NewAccountDB
(
"token"
,
burn
.
GetSymbol
(),
action
.
db
)
chain33cfg
:=
action
.
api
.
GetConfig
()
tokenAccount
,
err
:=
account
.
NewAccountDB
(
chain33cfg
,
"token"
,
burn
.
GetSymbol
(),
action
.
db
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
plugin/dapp/token/rpc/rpc.go
View file @
61485a4a
...
...
@@ -17,11 +17,12 @@ import (
//TODO:和GetBalance进行泛化处理,同时LoadAccounts和LoadExecAccountQueue也需要进行泛化处理, added by hzj
func
(
c
*
channelClient
)
getTokenBalance
(
in
*
tokenty
.
ReqTokenBalance
)
([]
*
types
.
Account
,
error
)
{
accountTokendb
,
err
:=
account
.
NewAccountDB
(
tokenty
.
TokenX
,
in
.
GetTokenSymbol
(),
nil
)
cfg
:=
c
.
GetConfig
()
accountTokendb
,
err
:=
account
.
NewAccountDB
(
cfg
,
tokenty
.
TokenX
,
in
.
GetTokenSymbol
(),
nil
)
if
err
!=
nil
{
return
nil
,
err
}
cfg
:=
c
.
GetConfig
()
switch
in
.
GetExecer
()
{
case
cfg
.
ExecName
(
tokenty
.
TokenX
)
:
addrs
:=
in
.
GetAddresses
()
...
...
plugin/dapp/trade/executor/exec_test.go
View file @
61485a4a
...
...
@@ -91,7 +91,7 @@ func TestTrade_Exec_SellLimit(t *testing.T) {
accB
.
SetDB
(
kvdb
)
accB
.
SaveExecAccount
(
address
.
ExecAddress
(
"trade"
),
&
accountB
)
accA
,
_
:=
account
.
NewAccountDB
(
AssetExecToken
,
Symbol
,
kvdb
)
accA
,
_
:=
account
.
NewAccountDB
(
chain33TestCfg
,
AssetExecToken
,
Symbol
,
kvdb
)
accA
.
SaveExecAccount
(
address
.
ExecAddress
(
"trade"
),
&
accountA
)
api
:=
new
(
apimock
.
QueueProtocolAPI
)
...
...
@@ -233,11 +233,11 @@ func TestTrade_Exec_BuyLimit(t *testing.T) {
stateDB
,
_
:=
dbm
.
NewGoMemDB
(
"1"
,
"2"
,
100
)
_
,
ldb
,
kvdb
:=
util
.
CreateTestDB
()
accB
,
_
:=
account
.
NewAccountDB
(
AssetExecToken
,
SymbolA
,
stateDB
)
accB
,
_
:=
account
.
NewAccountDB
(
chain33TestCfg
,
AssetExecToken
,
SymbolA
,
stateDB
)
accB
.
SetDB
(
stateDB
)
accB
.
SaveExecAccount
(
address
.
ExecAddress
(
"trade"
),
&
accountB
)
accA
,
_
:=
account
.
NewAccountDB
(
AssetExecPara
,
Symbol
,
stateDB
)
accA
,
_
:=
account
.
NewAccountDB
(
chain33TestCfg
,
AssetExecPara
,
Symbol
,
stateDB
)
accA
.
SaveExecAccount
(
address
.
ExecAddress
(
"trade"
),
&
accountA
)
api
:=
new
(
apimock
.
QueueProtocolAPI
)
...
...
@@ -410,7 +410,7 @@ func TestTradeSellFixAssetDB(t *testing.T) {
accB
.
SetDB
(
kvdb
)
accB
.
SaveExecAccount
(
address
.
ExecAddress
(
"trade"
),
&
accountB
)
accA
,
_
:=
account
.
NewAccountDB
(
AssetExecToken
,
Symbol
,
kvdb
)
accA
,
_
:=
account
.
NewAccountDB
(
chain33TestCfg
,
AssetExecToken
,
Symbol
,
kvdb
)
accA
.
SaveExecAccount
(
address
.
ExecAddress
(
"trade"
),
&
accountA
)
api
:=
new
(
apimock
.
QueueProtocolAPI
)
...
...
plugin/dapp/trade/executor/util.go
View file @
61485a4a
...
...
@@ -74,12 +74,12 @@ func createAccountDB(cfg *types.Chain33Config, height int64, db db.KV, exec, sym
if
exec
==
""
{
exec
=
defaultAssetExec
}
return
account
.
NewAccountDB
(
exec
,
symbol
,
db
)
return
account
.
NewAccountDB
(
cfg
,
exec
,
symbol
,
db
)
}
else
if
cfg
.
IsDappFork
(
height
,
pt
.
TradeX
,
pt
.
ForkTradeAssetX
)
{
return
account
.
NewAccountDB
(
exec
,
symbol
,
db
)
return
account
.
NewAccountDB
(
cfg
,
exec
,
symbol
,
db
)
}
return
account
.
NewAccountDB
(
defaultAssetExec
,
symbol
,
db
)
return
account
.
NewAccountDB
(
cfg
,
defaultAssetExec
,
symbol
,
db
)
}
func
createPriceDB
(
cfg
*
types
.
Chain33Config
,
height
int64
,
db
db
.
KV
,
exec
,
symbol
string
)
(
*
account
.
DB
,
error
)
{
...
...
@@ -90,7 +90,7 @@ func createPriceDB(cfg *types.Chain33Config, height int64, db db.KV, exec, symbo
acc
.
SetDB
(
db
)
return
acc
,
nil
}
return
account
.
NewAccountDB
(
exec
,
symbol
,
db
)
return
account
.
NewAccountDB
(
cfg
,
exec
,
symbol
,
db
)
}
acc
:=
account
.
NewCoinsAccount
(
cfg
)
acc
.
SetDB
(
db
)
...
...
plugin/dapp/unfreeze/executor/exec.go
View file @
61485a4a
...
...
@@ -30,7 +30,8 @@ func (u *Unfreeze) Exec_Create(payload *pty.UnfreezeCreate, tx *types.Transactio
return
nil
,
err
}
acc
,
err
:=
account
.
NewAccountDB
(
payload
.
AssetExec
,
payload
.
AssetSymbol
,
u
.
GetStateDB
())
cfg
:=
u
.
GetAPI
()
.
GetConfig
()
acc
,
err
:=
account
.
NewAccountDB
(
cfg
,
payload
.
AssetExec
,
payload
.
AssetSymbol
,
u
.
GetStateDB
())
if
err
!=
nil
{
uflog
.
Error
(
"unfreeze create new account"
,
"addr"
,
tx
.
From
(),
"execAddr"
,
dapp
.
ExecAddress
(
string
(
tx
.
Execer
)),
"exec"
,
payload
.
AssetExec
,
"symbol"
,
payload
.
AssetSymbol
)
...
...
@@ -71,7 +72,7 @@ func (u *Unfreeze) Exec_Withdraw(payload *pty.UnfreezeWithdraw, tx *types.Transa
return
nil
,
err
}
acc
,
err
:=
account
.
NewAccountDB
(
unfreeze
.
AssetExec
,
unfreeze
.
AssetSymbol
,
u
.
GetStateDB
())
acc
,
err
:=
account
.
NewAccountDB
(
cfg
,
unfreeze
.
AssetExec
,
unfreeze
.
AssetSymbol
,
u
.
GetStateDB
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -108,7 +109,7 @@ func (u *Unfreeze) Exec_Terminate(payload *pty.UnfreezeTerminate, tx *types.Tran
return
nil
,
err
}
acc
,
err
:=
account
.
NewAccountDB
(
unfreeze
.
AssetExec
,
unfreeze
.
AssetSymbol
,
u
.
GetStateDB
())
acc
,
err
:=
account
.
NewAccountDB
(
cfg
,
unfreeze
.
AssetExec
,
unfreeze
.
AssetSymbol
,
u
.
GetStateDB
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
plugin/dapp/unfreeze/executor/exec_test.go
View file @
61485a4a
...
...
@@ -70,10 +70,10 @@ func TestUnfreeze(t *testing.T) {
stateDB
,
_
:=
dbm
.
NewGoMemDB
(
"1"
,
"2"
,
100
)
_
,
ldb
,
kvdb
:=
util
.
CreateTestDB
()
accA
,
_
:=
account
.
NewAccountDB
(
AssetExecPara
,
Symbol
,
stateDB
)
accA
,
_
:=
account
.
NewAccountDB
(
chain33TestCfg
,
AssetExecPara
,
Symbol
,
stateDB
)
accA
.
SaveExecAccount
(
execAddr
,
&
accountA
)
accB
,
_
:=
account
.
NewAccountDB
(
AssetExecPara
,
Symbol
,
stateDB
)
accB
,
_
:=
account
.
NewAccountDB
(
chain33TestCfg
,
AssetExecPara
,
Symbol
,
stateDB
)
accB
.
SaveExecAccount
(
execAddr
,
&
accountB
)
env
:=
execEnv
{
...
...
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