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
c829ea34
Commit
c829ea34
authored
Nov 22, 2018
by
gitlab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto ci
parent
2d62cb6b
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
86 additions
and
86 deletions
+86
-86
flags.go
cli/buildflags/flags.go
+1
-0
action.go
plugin/dapp/blackwhite/executor/action.go
+10
-10
rpc.go
plugin/dapp/blackwhite/rpc/rpc.go
+4
-4
const.go
plugin/dapp/blackwhite/types/const.go
+0
-0
errors.go
plugin/dapp/blackwhite/types/errors.go
+0
-0
types.go
plugin/dapp/blackwhite/types/types.go
+0
-0
signatory.go
...in/dapp/token/cmd/signatory-server/signatory/signatory.go
+2
-2
doc.go
plugin/dapp/token/doc.go
+0
-1
exec.go
plugin/dapp/token/executor/exec.go
+3
-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
token.go
plugin/dapp/token/executor/token.go
+6
-6
token_new_test.go
plugin/dapp/token/executor/token_new_test.go
+2
-2
tokendb.go
plugin/dapp/token/executor/tokendb.go
+7
-7
tokentxlist.go
plugin/dapp/token/executor/tokentxlist.go
+1
-1
transwithdraw.go
plugin/dapp/token/executor/transwithdraw.go
+2
-2
const.go
plugin/dapp/token/types/const.go
+0
-0
errors.go
plugin/dapp/token/types/errors.go
+0
-0
node.go
plugin/store/mpt/db/node.go
+0
-0
decode.go
plugin/store/mpt/db2/rlp/decode.go
+0
-0
encode.go
plugin/store/mpt/db2/rlp/encode.go
+0
-0
mpt_test.go
plugin/store/mpt/mpt_test.go
+42
-42
No files found.
cli/buildflags/flags.go
View file @
c829ea34
...
@@ -6,5 +6,6 @@ package buildflags
...
@@ -6,5 +6,6 @@ package buildflags
// ParaName para name
// ParaName para name
var
ParaName
string
var
ParaName
string
// RPCAddr rpc address
// RPCAddr rpc address
var
RPCAddr
string
var
RPCAddr
string
plugin/dapp/blackwhite/executor/action.go
View file @
c829ea34
...
@@ -92,12 +92,12 @@ func (a *action) Create(create *gt.BlackwhiteCreate) (*types.Receipt, error) {
...
@@ -92,12 +92,12 @@ func (a *action) Create(create *gt.BlackwhiteCreate) (*types.Receipt, error) {
key
:=
calcMavlRoundKey
(
round
.
GameID
)
key
:=
calcMavlRoundKey
(
round
.
GameID
)
value
:=
types
.
Encode
(
round
)
value
:=
types
.
Encode
(
round
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
receiptLog
:=
a
.
GetReceiptLog
(
round
,
round
.
GetCreateAddr
())
receiptLog
:=
a
.
GetReceiptLog
(
round
,
round
.
GetCreateAddr
())
logs
=
append
(
logs
,
receiptLog
)
logs
=
append
(
logs
,
receiptLog
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
func
(
a
*
action
)
Play
(
play
*
gt
.
BlackwhitePlay
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
Play
(
play
*
gt
.
BlackwhitePlay
)
(
*
types
.
Receipt
,
error
)
{
...
@@ -184,9 +184,9 @@ func (a *action) Play(play *gt.BlackwhitePlay) (*types.Receipt, error) {
...
@@ -184,9 +184,9 @@ func (a *action) Play(play *gt.BlackwhitePlay) (*types.Receipt, error) {
//将当前游戏状态保存,便于同一区块中游戏参数的累加
//将当前游戏状态保存,便于同一区块中游戏参数的累加
a
.
db
.
Set
(
key1
,
value1
)
a
.
db
.
Set
(
key1
,
value1
)
}
}
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key1
,
Value
:
value1
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key1
,
Value
:
value1
})
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
func
(
a
*
action
)
Show
(
show
*
gt
.
BlackwhiteShow
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
Show
(
show
*
gt
.
BlackwhiteShow
)
(
*
types
.
Receipt
,
error
)
{
...
@@ -268,9 +268,9 @@ func (a *action) Show(show *gt.BlackwhiteShow) (*types.Receipt, error) {
...
@@ -268,9 +268,9 @@ func (a *action) Show(show *gt.BlackwhiteShow) (*types.Receipt, error) {
//将当前游戏状态保存,便于同一区块中游戏参数的累加
//将当前游戏状态保存,便于同一区块中游戏参数的累加
a
.
db
.
Set
(
key1
,
value1
)
a
.
db
.
Set
(
key1
,
value1
)
}
}
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key1
,
Value
:
value1
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key1
,
Value
:
value1
})
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
func
(
a
*
action
)
TimeoutDone
(
done
*
gt
.
BlackwhiteTimeoutDone
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
TimeoutDone
(
done
*
gt
.
BlackwhiteTimeoutDone
)
(
*
types
.
Receipt
,
error
)
{
...
@@ -364,7 +364,7 @@ func (a *action) TimeoutDone(done *gt.BlackwhiteTimeoutDone) (*types.Receipt, er
...
@@ -364,7 +364,7 @@ func (a *action) TimeoutDone(done *gt.BlackwhiteTimeoutDone) (*types.Receipt, er
//将当前游戏状态保存,便于同一区块中游戏参数的累加
//将当前游戏状态保存,便于同一区块中游戏参数的累加
a
.
db
.
Set
(
key1
,
value1
)
a
.
db
.
Set
(
key1
,
value1
)
}
}
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key1
,
Value
:
value1
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key1
,
Value
:
value1
})
// 需要更新全部地址状态
// 需要更新全部地址状态
for
_
,
addr
:=
range
round
.
AddrResult
{
for
_
,
addr
:=
range
round
.
AddrResult
{
...
@@ -376,7 +376,7 @@ func (a *action) TimeoutDone(done *gt.BlackwhiteTimeoutDone) (*types.Receipt, er
...
@@ -376,7 +376,7 @@ func (a *action) TimeoutDone(done *gt.BlackwhiteTimeoutDone) (*types.Receipt, er
receiptLog
:=
a
.
GetReceiptLog
(
&
round
,
round
.
CreateAddr
)
receiptLog
:=
a
.
GetReceiptLog
(
&
round
,
round
.
CreateAddr
)
logs
=
append
(
logs
,
receiptLog
)
logs
=
append
(
logs
,
receiptLog
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
...
@@ -514,9 +514,9 @@ func (a *action) StatTransfer(round *gt.BlackwhiteRound) (*types.Receipt, error)
...
@@ -514,9 +514,9 @@ func (a *action) StatTransfer(round *gt.BlackwhiteRound) (*types.Receipt, error)
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
// 将每一轮次的结果保存
// 将每一轮次的结果保存
logs
=
append
(
logs
,
&
types
.
ReceiptLog
{
Ty
:
gt
.
TyLogBlackwhiteLoopInfo
,
Log
:
types
.
Encode
(
loopResults
)})
logs
=
append
(
logs
,
&
types
.
ReceiptLog
{
Ty
:
gt
.
TyLogBlackwhiteLoopInfo
,
Log
:
types
.
Encode
(
loopResults
)})
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
...
...
plugin/dapp/blackwhite/rpc/rpc.go
View file @
c829ea34
...
@@ -14,7 +14,7 @@ import (
...
@@ -14,7 +14,7 @@ import (
func
(
c
*
channelClient
)
Create
(
ctx
context
.
Context
,
head
*
bw
.
BlackwhiteCreate
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
Create
(
ctx
context
.
Context
,
head
*
bw
.
BlackwhiteCreate
)
(
*
types
.
UnsignTx
,
error
)
{
val
:=
&
bw
.
BlackwhiteAction
{
val
:=
&
bw
.
BlackwhiteAction
{
Ty
:
bw
.
BlackwhiteActionCreate
,
Ty
:
bw
.
BlackwhiteActionCreate
,
Value
:
&
bw
.
BlackwhiteAction_Create
{
Create
:
head
},
Value
:
&
bw
.
BlackwhiteAction_Create
{
Create
:
head
},
}
}
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
val
),
Payload
:
types
.
Encode
(
val
),
...
@@ -29,7 +29,7 @@ func (c *channelClient) Create(ctx context.Context, head *bw.BlackwhiteCreate) (
...
@@ -29,7 +29,7 @@ func (c *channelClient) Create(ctx context.Context, head *bw.BlackwhiteCreate) (
func
(
c
*
channelClient
)
Show
(
ctx
context
.
Context
,
head
*
bw
.
BlackwhiteShow
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
Show
(
ctx
context
.
Context
,
head
*
bw
.
BlackwhiteShow
)
(
*
types
.
UnsignTx
,
error
)
{
val
:=
&
bw
.
BlackwhiteAction
{
val
:=
&
bw
.
BlackwhiteAction
{
Ty
:
bw
.
BlackwhiteActionShow
,
Ty
:
bw
.
BlackwhiteActionShow
,
Value
:
&
bw
.
BlackwhiteAction_Show
{
Show
:
head
},
Value
:
&
bw
.
BlackwhiteAction_Show
{
Show
:
head
},
}
}
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
val
),
Payload
:
types
.
Encode
(
val
),
...
@@ -44,7 +44,7 @@ func (c *channelClient) Show(ctx context.Context, head *bw.BlackwhiteShow) (*typ
...
@@ -44,7 +44,7 @@ func (c *channelClient) Show(ctx context.Context, head *bw.BlackwhiteShow) (*typ
func
(
c
*
channelClient
)
Play
(
ctx
context
.
Context
,
head
*
bw
.
BlackwhitePlay
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
Play
(
ctx
context
.
Context
,
head
*
bw
.
BlackwhitePlay
)
(
*
types
.
UnsignTx
,
error
)
{
val
:=
&
bw
.
BlackwhiteAction
{
val
:=
&
bw
.
BlackwhiteAction
{
Ty
:
bw
.
BlackwhiteActionPlay
,
Ty
:
bw
.
BlackwhiteActionPlay
,
Value
:
&
bw
.
BlackwhiteAction_Play
{
Play
:
head
},
Value
:
&
bw
.
BlackwhiteAction_Play
{
Play
:
head
},
}
}
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
val
),
Payload
:
types
.
Encode
(
val
),
...
@@ -59,7 +59,7 @@ func (c *channelClient) Play(ctx context.Context, head *bw.BlackwhitePlay) (*typ
...
@@ -59,7 +59,7 @@ func (c *channelClient) Play(ctx context.Context, head *bw.BlackwhitePlay) (*typ
func
(
c
*
channelClient
)
TimeoutDone
(
ctx
context
.
Context
,
head
*
bw
.
BlackwhiteTimeoutDone
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
TimeoutDone
(
ctx
context
.
Context
,
head
*
bw
.
BlackwhiteTimeoutDone
)
(
*
types
.
UnsignTx
,
error
)
{
val
:=
&
bw
.
BlackwhiteAction
{
val
:=
&
bw
.
BlackwhiteAction
{
Ty
:
bw
.
BlackwhiteActionTimeoutDone
,
Ty
:
bw
.
BlackwhiteActionTimeoutDone
,
Value
:
&
bw
.
BlackwhiteAction_TimeoutDone
{
TimeoutDone
:
head
},
Value
:
&
bw
.
BlackwhiteAction_TimeoutDone
{
TimeoutDone
:
head
},
}
}
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
val
),
Payload
:
types
.
Encode
(
val
),
...
...
plugin/dapp/blackwhite/types/const.go
View file @
c829ea34
plugin/dapp/blackwhite/types/errors.go
View file @
c829ea34
plugin/dapp/blackwhite/types/types.go
View file @
c829ea34
plugin/dapp/token/cmd/signatory-server/signatory/signatory.go
View file @
c829ea34
...
@@ -52,7 +52,7 @@ func (signatory *Signatory) SignApprove(in *TokenFinish, out *interface{}) error
...
@@ -52,7 +52,7 @@ func (signatory *Signatory) SignApprove(in *TokenFinish, out *interface{}) error
v
:=
&
tokenty
.
TokenFinishCreate
{
Symbol
:
in
.
Symbol
,
Owner
:
in
.
OwnerAddr
}
v
:=
&
tokenty
.
TokenFinishCreate
{
Symbol
:
in
.
Symbol
,
Owner
:
in
.
OwnerAddr
}
finish
:=
&
tokenty
.
TokenAction
{
finish
:=
&
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionFinishCreate
,
Ty
:
tokenty
.
TokenActionFinishCreate
,
Value
:
&
tokenty
.
TokenAction_TokenFinishCreate
{
TokenFinishCreate
:
v
},
Value
:
&
tokenty
.
TokenAction_TokenFinishCreate
{
TokenFinishCreate
:
v
},
}
}
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
...
@@ -93,7 +93,7 @@ func (signatory *Signatory) SignTransfer(in *string, out *interface{}) error {
...
@@ -93,7 +93,7 @@ func (signatory *Signatory) SignTransfer(in *string, out *interface{}) error {
}
}
transfer
:=
&
cty
.
CoinsAction
{
transfer
:=
&
cty
.
CoinsAction
{
Ty
:
cty
.
CoinsActionTransfer
,
Ty
:
cty
.
CoinsActionTransfer
,
Value
:
&
cty
.
CoinsAction_Transfer
{
Transfer
:
v
},
Value
:
&
cty
.
CoinsAction_Transfer
{
Transfer
:
v
},
}
}
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
...
...
plugin/dapp/token/doc.go
View file @
c829ea34
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
//Package token
//Package token
//主要包含两方面功能
//主要包含两方面功能
// 1. token 的创建
// 1. token 的创建
...
...
plugin/dapp/token/executor/exec.go
View file @
c829ea34
...
@@ -19,7 +19,7 @@ func (t *token) Exec_Transfer(payload *types.AssetsTransfer, tx *types.Transacti
...
@@ -19,7 +19,7 @@ func (t *token) Exec_Transfer(payload *types.AssetsTransfer, tx *types.Transacti
tokenAction
:=
tokenty
.
TokenAction
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionTransfer
,
Ty
:
tokenty
.
ActionTransfer
,
Value
:
&
tokenty
.
TokenAction_Transfer
{
Value
:
&
tokenty
.
TokenAction_Transfer
{
Transfer
:
payload
,
Transfer
:
payload
,
},
},
}
}
return
t
.
ExecTransWithdraw
(
db
,
tx
,
&
tokenAction
,
index
)
return
t
.
ExecTransWithdraw
(
db
,
tx
,
&
tokenAction
,
index
)
...
@@ -34,7 +34,7 @@ func (t *token) Exec_Withdraw(payload *types.AssetsWithdraw, tx *types.Transacti
...
@@ -34,7 +34,7 @@ func (t *token) Exec_Withdraw(payload *types.AssetsWithdraw, tx *types.Transacti
tokenAction
:=
tokenty
.
TokenAction
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionWithdraw
,
Ty
:
tokenty
.
ActionWithdraw
,
Value
:
&
tokenty
.
TokenAction_Withdraw
{
Value
:
&
tokenty
.
TokenAction_Withdraw
{
Withdraw
:
payload
,
Withdraw
:
payload
,
},
},
}
}
return
t
.
ExecTransWithdraw
(
db
,
tx
,
&
tokenAction
,
index
)
return
t
.
ExecTransWithdraw
(
db
,
tx
,
&
tokenAction
,
index
)
...
@@ -64,7 +64,7 @@ func (t *token) Exec_TransferToExec(payload *types.AssetsTransferToExec, tx *typ
...
@@ -64,7 +64,7 @@ func (t *token) Exec_TransferToExec(payload *types.AssetsTransferToExec, tx *typ
tokenAction
:=
tokenty
.
TokenAction
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionTransferToExec
,
Ty
:
tokenty
.
TokenActionTransferToExec
,
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
TransferToExec
:
payload
,
TransferToExec
:
payload
,
},
},
}
}
return
t
.
ExecTransWithdraw
(
db
,
tx
,
&
tokenAction
,
index
)
return
t
.
ExecTransWithdraw
(
db
,
tx
,
&
tokenAction
,
index
)
...
...
plugin/dapp/token/executor/exec_del_local.go
View file @
c829ea34
...
@@ -35,7 +35,7 @@ func (t *token) ExecDelLocal_Transfer(payload *types.AssetsTransfer, tx *types.T
...
@@ -35,7 +35,7 @@ func (t *token) ExecDelLocal_Transfer(payload *types.AssetsTransfer, tx *types.T
tokenAction
:=
tokenty
.
TokenAction
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionTransfer
,
Ty
:
tokenty
.
ActionTransfer
,
Value
:
&
tokenty
.
TokenAction_Transfer
{
Value
:
&
tokenty
.
TokenAction_Transfer
{
Transfer
:
payload
,
Transfer
:
payload
,
},
},
}
}
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
true
)
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
true
)
...
@@ -56,7 +56,7 @@ func (t *token) ExecDelLocal_Withdraw(payload *types.AssetsWithdraw, tx *types.T
...
@@ -56,7 +56,7 @@ func (t *token) ExecDelLocal_Withdraw(payload *types.AssetsWithdraw, tx *types.T
tokenAction
:=
tokenty
.
TokenAction
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionWithdraw
,
Ty
:
tokenty
.
ActionWithdraw
,
Value
:
&
tokenty
.
TokenAction_Withdraw
{
Value
:
&
tokenty
.
TokenAction_Withdraw
{
Withdraw
:
payload
,
Withdraw
:
payload
,
},
},
}
}
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
true
)
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
true
)
...
@@ -77,7 +77,7 @@ func (t *token) ExecDelLocal_TransferToExec(payload *types.AssetsTransferToExec,
...
@@ -77,7 +77,7 @@ func (t *token) ExecDelLocal_TransferToExec(payload *types.AssetsTransferToExec,
tokenAction
:=
tokenty
.
TokenAction
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionTransferToExec
,
Ty
:
tokenty
.
TokenActionTransferToExec
,
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
TransferToExec
:
payload
,
TransferToExec
:
payload
,
},
},
}
}
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
true
)
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
true
)
...
...
plugin/dapp/token/executor/exec_local.go
View file @
c829ea34
...
@@ -25,7 +25,7 @@ func (t *token) ExecLocal_Transfer(payload *types.AssetsTransfer, tx *types.Tran
...
@@ -25,7 +25,7 @@ func (t *token) ExecLocal_Transfer(payload *types.AssetsTransfer, tx *types.Tran
tokenAction
:=
tokenty
.
TokenAction
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionTransfer
,
Ty
:
tokenty
.
ActionTransfer
,
Value
:
&
tokenty
.
TokenAction_Transfer
{
Value
:
&
tokenty
.
TokenAction_Transfer
{
Transfer
:
payload
,
Transfer
:
payload
,
},
},
}
}
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
false
)
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
false
)
...
@@ -51,7 +51,7 @@ func (t *token) ExecLocal_Withdraw(payload *types.AssetsWithdraw, tx *types.Tran
...
@@ -51,7 +51,7 @@ func (t *token) ExecLocal_Withdraw(payload *types.AssetsWithdraw, tx *types.Tran
tokenAction
:=
tokenty
.
TokenAction
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionWithdraw
,
Ty
:
tokenty
.
ActionWithdraw
,
Value
:
&
tokenty
.
TokenAction_Withdraw
{
Value
:
&
tokenty
.
TokenAction_Withdraw
{
Withdraw
:
payload
,
Withdraw
:
payload
,
},
},
}
}
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
false
)
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
false
)
...
@@ -72,7 +72,7 @@ func (t *token) ExecLocal_TransferToExec(payload *types.AssetsTransferToExec, tx
...
@@ -72,7 +72,7 @@ func (t *token) ExecLocal_TransferToExec(payload *types.AssetsTransferToExec, tx
tokenAction
:=
tokenty
.
TokenAction
{
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionTransferToExec
,
Ty
:
tokenty
.
TokenActionTransferToExec
,
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
TransferToExec
:
payload
,
TransferToExec
:
payload
,
},
},
}
}
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
false
)
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
false
)
...
...
plugin/dapp/token/executor/token.go
View file @
c829ea34
...
@@ -117,7 +117,7 @@ func (t *token) getAccountTokenAssets(req *tokenty.ReqAccountTokenAssets) (types
...
@@ -117,7 +117,7 @@ func (t *token) getAccountTokenAssets(req *tokenty.ReqAccountTokenAssets) (types
if
acc1
==
nil
{
if
acc1
==
nil
{
continue
continue
}
}
tokenAsset
:=
&
tokenty
.
TokenAsset
{
Symbol
:
asset
,
Account
:
acc1
}
tokenAsset
:=
&
tokenty
.
TokenAsset
{
Symbol
:
asset
,
Account
:
acc1
}
reply
.
TokenAssets
=
append
(
reply
.
TokenAssets
,
tokenAsset
)
reply
.
TokenAssets
=
append
(
reply
.
TokenAssets
,
tokenAsset
)
}
}
return
reply
,
nil
return
reply
,
nil
...
@@ -137,7 +137,7 @@ func (t *token) getAddrReceiverforTokens(addrTokens *tokenty.ReqAddrTokens) (typ
...
@@ -137,7 +137,7 @@ func (t *token) getAddrReceiverforTokens(addrTokens *tokenty.ReqAddrTokens) (typ
continue
continue
}
}
recv
:=
&
tokenty
.
TokenRecv
{
Token
:
token
,
Recv
:
reciver
.
Data
}
recv
:=
&
tokenty
.
TokenRecv
{
Token
:
token
,
Recv
:
reciver
.
Data
}
reply
.
TokenRecvs
=
append
(
reply
.
TokenRecvs
,
recv
)
reply
.
TokenRecvs
=
append
(
reply
.
TokenRecvs
,
recv
)
}
}
...
@@ -244,11 +244,11 @@ func (t *token) saveLogs(receipt *tokenty.ReceiptToken) []*types.KeyValue {
...
@@ -244,11 +244,11 @@ func (t *token) saveLogs(receipt *tokenty.ReceiptToken) []*types.KeyValue {
}
else
{
}
else
{
value
=
calcTokenAddrKeyS
(
receipt
.
Symbol
,
receipt
.
Owner
)
value
=
calcTokenAddrKeyS
(
receipt
.
Symbol
,
receipt
.
Owner
)
}
}
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
//如果当前需要被更新的状态不是Status_PreCreated,则认为之前的状态是precreate,且其对应的key需要被删除
//如果当前需要被更新的状态不是Status_PreCreated,则认为之前的状态是precreate,且其对应的key需要被删除
if
receipt
.
Status
!=
tokenty
.
TokenStatusPreCreated
{
if
receipt
.
Status
!=
tokenty
.
TokenStatusPreCreated
{
key
=
calcTokenStatusKeyLocal
(
receipt
.
Symbol
,
receipt
.
Owner
,
tokenty
.
TokenStatusPreCreated
)
key
=
calcTokenStatusKeyLocal
(
receipt
.
Symbol
,
receipt
.
Owner
,
tokenty
.
TokenStatusPreCreated
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
})
}
}
return
kv
return
kv
}
}
...
@@ -257,7 +257,7 @@ func (t *token) deleteLogs(receipt *tokenty.ReceiptToken) []*types.KeyValue {
...
@@ -257,7 +257,7 @@ func (t *token) deleteLogs(receipt *tokenty.ReceiptToken) []*types.KeyValue {
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
key
:=
calcTokenStatusKeyLocal
(
receipt
.
Symbol
,
receipt
.
Owner
,
receipt
.
Status
)
key
:=
calcTokenStatusKeyLocal
(
receipt
.
Symbol
,
receipt
.
Owner
,
receipt
.
Status
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
})
//如果当前需要被更新的状态不是Status_PreCreated,则认为之前的状态是precreate,且其对应的key需要被恢复
//如果当前需要被更新的状态不是Status_PreCreated,则认为之前的状态是precreate,且其对应的key需要被恢复
if
receipt
.
Status
!=
tokenty
.
TokenStatusPreCreated
{
if
receipt
.
Status
!=
tokenty
.
TokenStatusPreCreated
{
key
=
calcTokenStatusKeyLocal
(
receipt
.
Symbol
,
receipt
.
Owner
,
tokenty
.
TokenStatusPreCreated
)
key
=
calcTokenStatusKeyLocal
(
receipt
.
Symbol
,
receipt
.
Owner
,
tokenty
.
TokenStatusPreCreated
)
...
@@ -267,7 +267,7 @@ func (t *token) deleteLogs(receipt *tokenty.ReceiptToken) []*types.KeyValue {
...
@@ -267,7 +267,7 @@ func (t *token) deleteLogs(receipt *tokenty.ReceiptToken) []*types.KeyValue {
}
else
{
}
else
{
value
=
calcTokenAddrKeyS
(
receipt
.
Symbol
,
receipt
.
Owner
)
value
=
calcTokenAddrKeyS
(
receipt
.
Symbol
,
receipt
.
Owner
)
}
}
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
}
}
return
kv
return
kv
}
}
...
...
plugin/dapp/token/executor/token_new_test.go
View file @
c829ea34
...
@@ -164,7 +164,7 @@ func TestPrecreate(t *testing.T) {
...
@@ -164,7 +164,7 @@ func TestPrecreate(t *testing.T) {
}
}
precreate
:=
&
tokenty
.
TokenAction
{
precreate
:=
&
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionPreCreate
,
Ty
:
tokenty
.
TokenActionPreCreate
,
Value
:
&
tokenty
.
TokenAction_TokenPreCreate
{
TokenPreCreate
:
v
},
Value
:
&
tokenty
.
TokenAction_TokenPreCreate
{
TokenPreCreate
:
v
},
}
}
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
execName
),
Execer
:
[]
byte
(
execName
),
...
@@ -205,7 +205,7 @@ func TestFinish(t *testing.T) {
...
@@ -205,7 +205,7 @@ func TestFinish(t *testing.T) {
v
:=
&
tokenty
.
TokenFinishCreate
{
Symbol
:
tokenSym
,
Owner
:
addr
}
v
:=
&
tokenty
.
TokenFinishCreate
{
Symbol
:
tokenSym
,
Owner
:
addr
}
finish
:=
&
tokenty
.
TokenAction
{
finish
:=
&
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionFinishCreate
,
Ty
:
tokenty
.
TokenActionFinishCreate
,
Value
:
&
tokenty
.
TokenAction_TokenFinishCreate
{
TokenFinishCreate
:
v
},
Value
:
&
tokenty
.
TokenAction_TokenFinishCreate
{
TokenFinishCreate
:
v
},
}
}
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
execName
),
Execer
:
[]
byte
(
execName
),
...
...
plugin/dapp/token/executor/tokendb.go
View file @
c829ea34
...
@@ -43,8 +43,8 @@ func (t *tokenDB) save(db dbm.KV, key []byte) {
...
@@ -43,8 +43,8 @@ func (t *tokenDB) save(db dbm.KV, key []byte) {
func
(
t
*
tokenDB
)
getLogs
(
ty
int32
,
status
int32
)
[]
*
types
.
ReceiptLog
{
func
(
t
*
tokenDB
)
getLogs
(
ty
int32
,
status
int32
)
[]
*
types
.
ReceiptLog
{
var
log
[]
*
types
.
ReceiptLog
var
log
[]
*
types
.
ReceiptLog
value
:=
types
.
Encode
(
&
pty
.
ReceiptToken
{
Symbol
:
t
.
token
.
Symbol
,
Owner
:
t
.
token
.
Owner
,
Status
:
t
.
token
.
Status
})
value
:=
types
.
Encode
(
&
pty
.
ReceiptToken
{
Symbol
:
t
.
token
.
Symbol
,
Owner
:
t
.
token
.
Owner
,
Status
:
t
.
token
.
Status
})
log
=
append
(
log
,
&
types
.
ReceiptLog
{
Ty
:
ty
,
Log
:
value
})
log
=
append
(
log
,
&
types
.
ReceiptLog
{
Ty
:
ty
,
Log
:
value
})
return
log
return
log
}
}
...
@@ -52,7 +52,7 @@ func (t *tokenDB) getLogs(ty int32, status int32) []*types.ReceiptLog {
...
@@ -52,7 +52,7 @@ func (t *tokenDB) getLogs(ty int32, status int32) []*types.ReceiptLog {
//key:mavl-create-token-addr-xxx or mavl-token-xxx <-----> value:token
//key:mavl-create-token-addr-xxx or mavl-token-xxx <-----> value:token
func
(
t
*
tokenDB
)
getKVSet
(
key
[]
byte
)
(
kvset
[]
*
types
.
KeyValue
)
{
func
(
t
*
tokenDB
)
getKVSet
(
key
[]
byte
)
(
kvset
[]
*
types
.
KeyValue
)
{
value
:=
types
.
Encode
(
&
t
.
token
)
value
:=
types
.
Encode
(
&
t
.
token
)
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
return
kvset
return
kvset
}
}
...
@@ -167,7 +167,7 @@ func (action *tokenAction) preCreate(token *pty.TokenPreCreate) (*types.Receipt,
...
@@ -167,7 +167,7 @@ func (action *tokenAction) preCreate(token *pty.TokenPreCreate) (*types.Receipt,
//tokenlog.Info("func token preCreate", "token:", tokendb.token.Symbol, "owner:", tokendb.token.Owner,
//tokenlog.Info("func token preCreate", "token:", tokendb.token.Symbol, "owner:", tokendb.token.Owner,
// "key:", key, "key string", string(key), "value:", tokendb.getKVSet(key)[0].Value)
// "key:", key, "key string", string(key), "value:", tokendb.getKVSet(key)[0].Value)
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -242,7 +242,7 @@ func (action *tokenAction) finishCreate(tokenFinish *pty.TokenFinishCreate) (*ty
...
@@ -242,7 +242,7 @@ func (action *tokenAction) finishCreate(tokenFinish *pty.TokenFinishCreate) (*ty
//因为该token已经被创建,需要保存一个全局的token,防止其他用户再次创建
//因为该token已经被创建,需要保存一个全局的token,防止其他用户再次创建
tokendb
.
save
(
action
.
db
,
key
)
tokendb
.
save
(
action
.
db
,
key
)
kv
=
append
(
kv
,
tokendb
.
getKVSet
(
key
)
...
)
kv
=
append
(
kv
,
tokendb
.
getKVSet
(
key
)
...
)
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -297,7 +297,7 @@ func (action *tokenAction) revokeCreate(tokenRevoke *pty.TokenRevokeCreate) (*ty
...
@@ -297,7 +297,7 @@ func (action *tokenAction) revokeCreate(tokenRevoke *pty.TokenRevokeCreate) (*ty
logs
=
append
(
logs
,
tokendb
.
getLogs
(
pty
.
TyLogRevokeCreateToken
,
pty
.
TokenStatusCreateRevoked
)
...
)
logs
=
append
(
logs
,
tokendb
.
getLogs
(
pty
.
TyLogRevokeCreateToken
,
pty
.
TokenStatusCreateRevoked
)
...
)
kv
=
append
(
kv
,
tokendb
.
getKVSet
(
key
)
...
)
kv
=
append
(
kv
,
tokendb
.
getKVSet
(
key
)
...
)
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -410,7 +410,7 @@ func AddTokenToAssets(addr string, db dbm.KVDB, symbol string) []*types.KeyValue
...
@@ -410,7 +410,7 @@ func AddTokenToAssets(addr string, db dbm.KVDB, symbol string) []*types.KeyValue
tokenAssets
.
Datas
=
append
(
tokenAssets
.
Datas
,
symbol
)
tokenAssets
.
Datas
=
append
(
tokenAssets
.
Datas
,
symbol
)
}
}
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
calcTokenAssetsKey
(
addr
),
Value
:
types
.
Encode
(
tokenAssets
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
calcTokenAssetsKey
(
addr
),
Value
:
types
.
Encode
(
tokenAssets
)})
return
kv
return
kv
}
}
...
...
plugin/dapp/token/executor/tokentxlist.go
View file @
c829ea34
...
@@ -31,7 +31,7 @@ func tokenTxKvs(tx *types.Transaction, symbol string, height, index int64, isDel
...
@@ -31,7 +31,7 @@ func tokenTxKvs(tx *types.Transaction, symbol string, height, index int64, isDel
txInfo
=
makeReplyTxInfo
(
tx
,
height
,
index
,
symbol
)
txInfo
=
makeReplyTxInfo
(
tx
,
height
,
index
,
symbol
)
}
}
for
_
,
k
:=
range
keys
{
for
_
,
k
:=
range
keys
{
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
k
,
Value
:
txInfo
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
k
,
Value
:
txInfo
})
}
}
return
kv
,
nil
return
kv
,
nil
}
}
...
...
plugin/dapp/token/executor/transwithdraw.go
View file @
c829ea34
...
@@ -135,9 +135,9 @@ func (t *token) ExecDelLocalLocalTransWithdraw(tx *types.Transaction, receipt *t
...
@@ -135,9 +135,9 @@ func (t *token) ExecDelLocalLocalTransWithdraw(tx *types.Transaction, receipt *t
}
}
func
getAddrReciverKV
(
token
string
,
addr
string
,
reciverAmount
int64
)
*
types
.
KeyValue
{
func
getAddrReciverKV
(
token
string
,
addr
string
,
reciverAmount
int64
)
*
types
.
KeyValue
{
reciver
:=
&
types
.
Int64
{
Data
:
reciverAmount
}
reciver
:=
&
types
.
Int64
{
Data
:
reciverAmount
}
amountbytes
:=
types
.
Encode
(
reciver
)
amountbytes
:=
types
.
Encode
(
reciver
)
kv
:=
&
types
.
KeyValue
{
Key
:
calcAddrKey
(
token
,
addr
),
Value
:
amountbytes
}
kv
:=
&
types
.
KeyValue
{
Key
:
calcAddrKey
(
token
,
addr
),
Value
:
amountbytes
}
return
kv
return
kv
}
}
...
...
plugin/dapp/token/types/const.go
View file @
c829ea34
plugin/dapp/token/types/errors.go
View file @
c829ea34
plugin/store/mpt/db/node.go
View file @
c829ea34
plugin/store/mpt/db2/rlp/decode.go
View file @
c829ea34
plugin/store/mpt/db2/rlp/encode.go
View file @
c829ea34
plugin/store/mpt/mpt_test.go
View file @
c829ea34
...
@@ -46,7 +46,7 @@ func TestKvddbSetGet(t *testing.T) {
...
@@ -46,7 +46,7 @@ func TestKvddbSetGet(t *testing.T) {
assert
.
NotNil
(
t
,
store
)
assert
.
NotNil
(
t
,
store
)
keys0
:=
[][]
byte
{[]
byte
(
"mk1"
),
[]
byte
(
"mk2"
)}
keys0
:=
[][]
byte
{[]
byte
(
"mk1"
),
[]
byte
(
"mk2"
)}
get0
:=
&
types
.
StoreGet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
Keys
:
keys0
}
get0
:=
&
types
.
StoreGet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
Keys
:
keys0
}
values0
:=
store
.
Get
(
get0
)
values0
:=
store
.
Get
(
get0
)
mlog
.
Info
(
"info"
,
"info"
,
values0
)
mlog
.
Info
(
"info"
,
"info"
,
values0
)
// Get exist key, result nil
// Get exist key, result nil
...
@@ -55,16 +55,16 @@ func TestKvddbSetGet(t *testing.T) {
...
@@ -55,16 +55,16 @@ func TestKvddbSetGet(t *testing.T) {
assert
.
Equal
(
t
,
[]
byte
(
nil
),
values0
[
1
])
assert
.
Equal
(
t
,
[]
byte
(
nil
),
values0
[
1
])
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"k1"
),
Value
:
[]
byte
(
"v1"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"k1"
),
Value
:
[]
byte
(
"v1"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"k2"
),
Value
:
[]
byte
(
"v2"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"k2"
),
Value
:
[]
byte
(
"v2"
)})
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
KV
:
kv
,
Height
:
0
}
Height
:
0
}
hash
,
err
:=
store
.
Set
(
datas
,
true
)
hash
,
err
:=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
keys
:=
[][]
byte
{[]
byte
(
"k1"
),
[]
byte
(
"k2"
)}
keys
:=
[][]
byte
{[]
byte
(
"k1"
),
[]
byte
(
"k2"
)}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
values
:=
store
.
Get
(
get1
)
values
:=
store
.
Get
(
get1
)
assert
.
Len
(
t
,
values
,
2
)
assert
.
Len
(
t
,
values
,
2
)
...
@@ -72,12 +72,12 @@ func TestKvddbSetGet(t *testing.T) {
...
@@ -72,12 +72,12 @@ func TestKvddbSetGet(t *testing.T) {
assert
.
Equal
(
t
,
[]
byte
(
"v2"
),
values
[
1
])
assert
.
Equal
(
t
,
[]
byte
(
"v2"
),
values
[
1
])
keys
=
[][]
byte
{[]
byte
(
"k1"
)}
keys
=
[][]
byte
{[]
byte
(
"k1"
)}
get2
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
get2
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
values2
:=
store
.
Get
(
get2
)
values2
:=
store
.
Get
(
get2
)
assert
.
Len
(
t
,
values2
,
1
)
assert
.
Len
(
t
,
values2
,
1
)
assert
.
Equal
(
t
,
[]
byte
(
"v1"
),
values2
[
0
])
assert
.
Equal
(
t
,
[]
byte
(
"v1"
),
values2
[
0
])
get3
:=
&
types
.
StoreGet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
Keys
:
keys
}
get3
:=
&
types
.
StoreGet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
Keys
:
keys
}
values3
:=
store
.
Get
(
get3
)
values3
:=
store
.
Get
(
get3
)
assert
.
Len
(
t
,
values3
,
1
)
assert
.
Len
(
t
,
values3
,
1
)
assert
.
Equal
(
t
,
[]
byte
(
nil
),
values3
[
0
])
assert
.
Equal
(
t
,
[]
byte
(
nil
),
values3
[
0
])
...
@@ -93,24 +93,24 @@ func TestKvdbMemSet(t *testing.T) {
...
@@ -93,24 +93,24 @@ func TestKvdbMemSet(t *testing.T) {
assert
.
NotNil
(
t
,
store
)
assert
.
NotNil
(
t
,
store
)
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk1"
),
Value
:
[]
byte
(
"v1"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk1"
),
Value
:
[]
byte
(
"v1"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk2"
),
Value
:
[]
byte
(
"v2"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk2"
),
Value
:
[]
byte
(
"v2"
)})
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
KV
:
kv
,
Height
:
0
}
Height
:
0
}
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
keys
:=
[][]
byte
{[]
byte
(
"mk1"
),
[]
byte
(
"mk2"
)}
keys
:=
[][]
byte
{[]
byte
(
"mk1"
),
[]
byte
(
"mk2"
)}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
values
:=
store
.
Get
(
get1
)
values
:=
store
.
Get
(
get1
)
assert
.
Len
(
t
,
values
,
2
)
assert
.
Len
(
t
,
values
,
2
)
actHash
,
_
:=
store
.
Commit
(
&
types
.
ReqHash
{
Hash
:
hash
})
actHash
,
_
:=
store
.
Commit
(
&
types
.
ReqHash
{
Hash
:
hash
})
assert
.
Equal
(
t
,
hash
,
actHash
)
assert
.
Equal
(
t
,
hash
,
actHash
)
notExistHash
,
_
:=
store
.
Commit
(
&
types
.
ReqHash
{
Hash
:
drivers
.
EmptyRoot
[
:
]})
notExistHash
,
_
:=
store
.
Commit
(
&
types
.
ReqHash
{
Hash
:
drivers
.
EmptyRoot
[
:
]})
assert
.
Nil
(
t
,
notExistHash
)
assert
.
Nil
(
t
,
notExistHash
)
}
}
...
@@ -124,23 +124,23 @@ func TestKvdbRollback(t *testing.T) {
...
@@ -124,23 +124,23 @@ func TestKvdbRollback(t *testing.T) {
assert
.
NotNil
(
t
,
store
)
assert
.
NotNil
(
t
,
store
)
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk1"
),
Value
:
[]
byte
(
"v1"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk1"
),
Value
:
[]
byte
(
"v1"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk2"
),
Value
:
[]
byte
(
"v2"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk2"
),
Value
:
[]
byte
(
"v2"
)})
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
KV
:
kv
,
Height
:
0
}
Height
:
0
}
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
keys
:=
[][]
byte
{[]
byte
(
"mk1"
),
[]
byte
(
"mk2"
)}
keys
:=
[][]
byte
{[]
byte
(
"mk1"
),
[]
byte
(
"mk2"
)}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
values
:=
store
.
Get
(
get1
)
values
:=
store
.
Get
(
get1
)
assert
.
Len
(
t
,
values
,
2
)
assert
.
Len
(
t
,
values
,
2
)
actHash
,
_
:=
store
.
Rollback
(
&
types
.
ReqHash
{
Hash
:
hash
})
actHash
,
_
:=
store
.
Rollback
(
&
types
.
ReqHash
{
Hash
:
hash
})
assert
.
Equal
(
t
,
hash
,
actHash
)
assert
.
Equal
(
t
,
hash
,
actHash
)
notExistHash
,
_
:=
store
.
Rollback
(
&
types
.
ReqHash
{
Hash
:
drivers
.
EmptyRoot
[
:
]})
notExistHash
,
_
:=
store
.
Rollback
(
&
types
.
ReqHash
{
Hash
:
drivers
.
EmptyRoot
[
:
]})
assert
.
Nil
(
t
,
notExistHash
)
assert
.
Nil
(
t
,
notExistHash
)
}
}
...
@@ -148,7 +148,7 @@ var checkKVResult []*types.KeyValue
...
@@ -148,7 +148,7 @@ var checkKVResult []*types.KeyValue
func
checkKV
(
k
,
v
[]
byte
)
bool
{
func
checkKV
(
k
,
v
[]
byte
)
bool
{
checkKVResult
=
append
(
checkKVResult
,
checkKVResult
=
append
(
checkKVResult
,
&
types
.
KeyValue
{
Key
:
k
,
Value
:
v
})
&
types
.
KeyValue
{
Key
:
k
,
Value
:
v
})
//mlog.Debug("checkKV", "key", string(k), "value", string(v))
//mlog.Debug("checkKV", "key", string(k), "value", string(v))
return
false
return
false
}
}
...
@@ -174,16 +174,16 @@ func BenchmarkGet(b *testing.B) {
...
@@ -174,16 +174,16 @@ func BenchmarkGet(b *testing.B) {
key
:=
GetRandomString
(
MaxKeylenth
)
key
:=
GetRandomString
(
MaxKeylenth
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
if
i
%
10000
==
0
{
if
i
%
10000
==
0
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
hash
,
err
=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
b
,
err
)
assert
.
Nil
(
b
,
err
)
kv
=
nil
kv
=
nil
}
}
}
}
if
kv
!=
nil
{
if
kv
!=
nil
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
hash
,
err
=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
b
,
err
)
assert
.
Nil
(
b
,
err
)
}
}
...
@@ -191,8 +191,8 @@ func BenchmarkGet(b *testing.B) {
...
@@ -191,8 +191,8 @@ func BenchmarkGet(b *testing.B) {
b
.
ResetTimer
()
b
.
ResetTimer
()
for
_
,
key
:=
range
keys
{
for
_
,
key
:=
range
keys
{
getData
:=
&
types
.
StoreGet
{
getData
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
StateHash
:
hash
,
Keys
:
[][]
byte
{
key
}}
Keys
:
[][]
byte
{
key
}}
store
.
Get
(
getData
)
store
.
Get
(
getData
)
}
}
end
:=
time
.
Now
()
end
:=
time
.
Now
()
...
@@ -216,16 +216,16 @@ func BenchmarkSet(b *testing.B) {
...
@@ -216,16 +216,16 @@ func BenchmarkSet(b *testing.B) {
key
:=
GetRandomString
(
MaxKeylenth
)
key
:=
GetRandomString
(
MaxKeylenth
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
if
i
%
10000
==
0
{
if
i
%
10000
==
0
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
hash
,
err
=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
b
,
err
)
assert
.
Nil
(
b
,
err
)
kv
=
nil
kv
=
nil
}
}
}
}
if
kv
!=
nil
{
if
kv
!=
nil
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
_
,
err
=
store
.
Set
(
datas
,
true
)
_
,
err
=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
b
,
err
)
assert
.
Nil
(
b
,
err
)
}
}
...
@@ -251,12 +251,12 @@ func BenchmarkMemSet(b *testing.B) {
...
@@ -251,12 +251,12 @@ func BenchmarkMemSet(b *testing.B) {
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
KV
:
kv
,
Height
:
0
}
Height
:
0
}
start
:=
time
.
Now
()
start
:=
time
.
Now
()
b
.
ResetTimer
()
b
.
ResetTimer
()
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
...
@@ -284,12 +284,12 @@ func BenchmarkCommit(b *testing.B) {
...
@@ -284,12 +284,12 @@ func BenchmarkCommit(b *testing.B) {
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
KV
:
kv
,
Height
:
0
}
Height
:
0
}
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
assert
.
Nil
(
b
,
err
)
assert
.
Nil
(
b
,
err
)
req
:=
&
types
.
ReqHash
{
req
:=
&
types
.
ReqHash
{
...
...
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