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
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
144 additions
and
144 deletions
+144
-144
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
+8
-8
errors.go
plugin/dapp/blackwhite/types/errors.go
+4
-4
types.go
plugin/dapp/blackwhite/types/types.go
+1
-1
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
+5
-5
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
+20
-20
errors.go
plugin/dapp/token/types/errors.go
+13
-13
node.go
plugin/store/mpt/db/node.go
+2
-2
decode.go
plugin/store/mpt/db2/rlp/decode.go
+6
-6
encode.go
plugin/store/mpt/db2/rlp/encode.go
+1
-1
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
// ParaName para name
var
ParaName
string
// RPCAddr rpc address
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) {
key
:=
calcMavlRoundKey
(
round
.
GameID
)
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
())
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
)
{
...
...
@@ -184,9 +184,9 @@ func (a *action) Play(play *gt.BlackwhitePlay) (*types.Receipt, error) {
//将当前游戏状态保存,便于同一区块中游戏参数的累加
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
)
{
...
...
@@ -268,9 +268,9 @@ func (a *action) Show(show *gt.BlackwhiteShow) (*types.Receipt, error) {
//将当前游戏状态保存,便于同一区块中游戏参数的累加
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
)
{
...
...
@@ -364,7 +364,7 @@ func (a *action) TimeoutDone(done *gt.BlackwhiteTimeoutDone) (*types.Receipt, er
//将当前游戏状态保存,便于同一区块中游戏参数的累加
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
{
...
...
@@ -376,7 +376,7 @@ func (a *action) TimeoutDone(done *gt.BlackwhiteTimeoutDone) (*types.Receipt, er
receiptLog
:=
a
.
GetReceiptLog
(
&
round
,
round
.
CreateAddr
)
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)
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 (
func
(
c
*
channelClient
)
Create
(
ctx
context
.
Context
,
head
*
bw
.
BlackwhiteCreate
)
(
*
types
.
UnsignTx
,
error
)
{
val
:=
&
bw
.
BlackwhiteAction
{
Ty
:
bw
.
BlackwhiteActionCreate
,
Value
:
&
bw
.
BlackwhiteAction_Create
{
Create
:
head
},
Value
:
&
bw
.
BlackwhiteAction_Create
{
Create
:
head
},
}
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
val
),
...
...
@@ -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
)
{
val
:=
&
bw
.
BlackwhiteAction
{
Ty
:
bw
.
BlackwhiteActionShow
,
Value
:
&
bw
.
BlackwhiteAction_Show
{
Show
:
head
},
Value
:
&
bw
.
BlackwhiteAction_Show
{
Show
:
head
},
}
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
val
),
...
...
@@ -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
)
{
val
:=
&
bw
.
BlackwhiteAction
{
Ty
:
bw
.
BlackwhiteActionPlay
,
Value
:
&
bw
.
BlackwhiteAction_Play
{
Play
:
head
},
Value
:
&
bw
.
BlackwhiteAction_Play
{
Play
:
head
},
}
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
val
),
...
...
@@ -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
)
{
val
:=
&
bw
.
BlackwhiteAction
{
Ty
:
bw
.
BlackwhiteActionTimeoutDone
,
Value
:
&
bw
.
BlackwhiteAction_TimeoutDone
{
TimeoutDone
:
head
},
Value
:
&
bw
.
BlackwhiteAction_TimeoutDone
{
TimeoutDone
:
head
},
}
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
val
),
...
...
plugin/dapp/blackwhite/types/const.go
View file @
c829ea34
...
...
@@ -22,26 +22,26 @@ const (
const
(
// TyLogBlackwhiteCreate log for blackwhite create game
TyLogBlackwhiteCreate
=
750
TyLogBlackwhiteCreate
=
750
// TyLogBlackwhitePlay log for blackwhite play game
TyLogBlackwhitePlay
=
751
TyLogBlackwhitePlay
=
751
// TyLogBlackwhiteShow log for blackwhite show game
TyLogBlackwhiteShow
=
752
TyLogBlackwhiteShow
=
752
// TyLogBlackwhiteTimeout log for blackwhite timeout game
TyLogBlackwhiteTimeout
=
753
TyLogBlackwhiteTimeout
=
753
// TyLogBlackwhiteDone log for blackwhite down game
TyLogBlackwhiteDone
=
754
TyLogBlackwhiteDone
=
754
// TyLogBlackwhiteLoopInfo log for blackwhite LoopInfo game
TyLogBlackwhiteLoopInfo
=
755
)
const
(
// GetBlackwhiteRoundInfo 用于在cmd里面的区分不同的查询
GetBlackwhiteRoundInfo
=
"GetBlackwhiteRoundInfo"
GetBlackwhiteRoundInfo
=
"GetBlackwhiteRoundInfo"
// GetBlackwhiteByStatusAndAddr 用于在cmd里面的区分不同的查询
GetBlackwhiteByStatusAndAddr
=
"GetBlackwhiteByStatusAndAddr"
// GetBlackwhiteloopResult 用于在cmd里面的区分不同的查询
GetBlackwhiteloopResult
=
"GetBlackwhiteloopResult"
GetBlackwhiteloopResult
=
"GetBlackwhiteloopResult"
)
var
(
...
...
@@ -49,7 +49,7 @@ var (
BlackwhiteX
=
"blackwhite"
glog
=
log15
.
New
(
"module"
,
BlackwhiteX
)
// JRPCName json RPC name
JRPCName
=
"Blackwhite"
JRPCName
=
"Blackwhite"
// ExecerBlackwhite 执行器名字byte形式
ExecerBlackwhite
=
[]
byte
(
BlackwhiteX
)
actionName
=
map
[
string
]
int32
{
...
...
plugin/dapp/blackwhite/types/errors.go
View file @
c829ea34
...
...
@@ -8,13 +8,13 @@ import "errors"
var
(
// ErrIncorrectStatus 所处游戏状态不正确
ErrIncorrectStatus
=
errors
.
New
(
"ErrIncorrectStatus"
)
ErrIncorrectStatus
=
errors
.
New
(
"ErrIncorrectStatus"
)
// ErrRepeatPlayerAddr 重复玩家
ErrRepeatPlayerAddr
=
errors
.
New
(
"ErrRepeatPlayerAddress"
)
// ErrNoTimeoutDone 还未超时
ErrNoTimeoutDone
=
errors
.
New
(
"ErrNoTimeoutDone"
)
ErrNoTimeoutDone
=
errors
.
New
(
"ErrNoTimeoutDone"
)
// ErrNoExistAddr 不存在地址,未参与游戏
ErrNoExistAddr
=
errors
.
New
(
"ErrNoExistAddress"
)
ErrNoExistAddr
=
errors
.
New
(
"ErrNoExistAddress"
)
// ErrNoLoopSeq 查询的轮次大于决出胜负的轮次
ErrNoLoopSeq
=
errors
.
New
(
"ErrBlackwhiteFinalloopLessThanSeq"
)
ErrNoLoopSeq
=
errors
.
New
(
"ErrBlackwhiteFinalloopLessThanSeq"
)
)
plugin/dapp/blackwhite/types/types.go
View file @
c829ea34
...
...
@@ -42,7 +42,7 @@ func NewType() *BlackwhiteType {
return
c
}
// GetPayload 获取blackwhite action
// GetPayload 获取blackwhite action
func
(
b
*
BlackwhiteType
)
GetPayload
()
types
.
Message
{
return
&
BlackwhiteAction
{}
}
...
...
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
v
:=
&
tokenty
.
TokenFinishCreate
{
Symbol
:
in
.
Symbol
,
Owner
:
in
.
OwnerAddr
}
finish
:=
&
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionFinishCreate
,
Value
:
&
tokenty
.
TokenAction_TokenFinishCreate
{
TokenFinishCreate
:
v
},
Value
:
&
tokenty
.
TokenAction_TokenFinishCreate
{
TokenFinishCreate
:
v
},
}
tx
:=
&
types
.
Transaction
{
...
...
@@ -93,7 +93,7 @@ func (signatory *Signatory) SignTransfer(in *string, out *interface{}) error {
}
transfer
:=
&
cty
.
CoinsAction
{
Ty
:
cty
.
CoinsActionTransfer
,
Value
:
&
cty
.
CoinsAction_Transfer
{
Transfer
:
v
},
Value
:
&
cty
.
CoinsAction_Transfer
{
Transfer
:
v
},
}
tx
:=
&
types
.
Transaction
{
...
...
plugin/dapp/token/doc.go
View file @
c829ea34
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//Package 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
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionTransfer
,
Value
:
&
tokenty
.
TokenAction_Transfer
{
Transfer
:
payload
,
Transfer
:
payload
,
},
}
return
t
.
ExecTransWithdraw
(
db
,
tx
,
&
tokenAction
,
index
)
...
...
@@ -34,7 +34,7 @@ func (t *token) Exec_Withdraw(payload *types.AssetsWithdraw, tx *types.Transacti
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionWithdraw
,
Value
:
&
tokenty
.
TokenAction_Withdraw
{
Withdraw
:
payload
,
Withdraw
:
payload
,
},
}
return
t
.
ExecTransWithdraw
(
db
,
tx
,
&
tokenAction
,
index
)
...
...
@@ -64,7 +64,7 @@ func (t *token) Exec_TransferToExec(payload *types.AssetsTransferToExec, tx *typ
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionTransferToExec
,
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
TransferToExec
:
payload
,
TransferToExec
:
payload
,
},
}
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
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionTransfer
,
Value
:
&
tokenty
.
TokenAction_Transfer
{
Transfer
:
payload
,
Transfer
:
payload
,
},
}
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
true
)
...
...
@@ -56,7 +56,7 @@ func (t *token) ExecDelLocal_Withdraw(payload *types.AssetsWithdraw, tx *types.T
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionWithdraw
,
Value
:
&
tokenty
.
TokenAction_Withdraw
{
Withdraw
:
payload
,
Withdraw
:
payload
,
},
}
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
true
)
...
...
@@ -77,7 +77,7 @@ func (t *token) ExecDelLocal_TransferToExec(payload *types.AssetsTransferToExec,
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionTransferToExec
,
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
TransferToExec
:
payload
,
TransferToExec
:
payload
,
},
}
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
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionTransfer
,
Value
:
&
tokenty
.
TokenAction_Transfer
{
Transfer
:
payload
,
Transfer
:
payload
,
},
}
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
false
)
...
...
@@ -51,7 +51,7 @@ func (t *token) ExecLocal_Withdraw(payload *types.AssetsWithdraw, tx *types.Tran
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
ActionWithdraw
,
Value
:
&
tokenty
.
TokenAction_Withdraw
{
Withdraw
:
payload
,
Withdraw
:
payload
,
},
}
kvs
,
err
:=
t
.
makeTokenTxKvs
(
tx
,
&
tokenAction
,
receiptData
,
index
,
false
)
...
...
@@ -72,7 +72,7 @@ func (t *token) ExecLocal_TransferToExec(payload *types.AssetsTransferToExec, tx
tokenAction
:=
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionTransferToExec
,
Value
:
&
tokenty
.
TokenAction_TransferToExec
{
TransferToExec
:
payload
,
TransferToExec
:
payload
,
},
}
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
if
acc1
==
nil
{
continue
}
tokenAsset
:=
&
tokenty
.
TokenAsset
{
Symbol
:
asset
,
Account
:
acc1
}
tokenAsset
:=
&
tokenty
.
TokenAsset
{
Symbol
:
asset
,
Account
:
acc1
}
reply
.
TokenAssets
=
append
(
reply
.
TokenAssets
,
tokenAsset
)
}
return
reply
,
nil
...
...
@@ -137,7 +137,7 @@ func (t *token) getAddrReceiverforTokens(addrTokens *tokenty.ReqAddrTokens) (typ
continue
}
recv
:=
&
tokenty
.
TokenRecv
{
Token
:
token
,
Recv
:
reciver
.
Data
}
recv
:=
&
tokenty
.
TokenRecv
{
Token
:
token
,
Recv
:
reciver
.
Data
}
reply
.
TokenRecvs
=
append
(
reply
.
TokenRecvs
,
recv
)
}
...
...
@@ -244,11 +244,11 @@ func (t *token) saveLogs(receipt *tokenty.ReceiptToken) []*types.KeyValue {
}
else
{
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需要被删除
if
receipt
.
Status
!=
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
}
...
...
@@ -257,7 +257,7 @@ func (t *token) deleteLogs(receipt *tokenty.ReceiptToken) []*types.KeyValue {
var
kv
[]
*
types
.
KeyValue
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需要被恢复
if
receipt
.
Status
!=
tokenty
.
TokenStatusPreCreated
{
key
=
calcTokenStatusKeyLocal
(
receipt
.
Symbol
,
receipt
.
Owner
,
tokenty
.
TokenStatusPreCreated
)
...
...
@@ -267,7 +267,7 @@ func (t *token) deleteLogs(receipt *tokenty.ReceiptToken) []*types.KeyValue {
}
else
{
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
}
...
...
plugin/dapp/token/executor/token_new_test.go
View file @
c829ea34
...
...
@@ -55,9 +55,9 @@ const (
//for token
var
(
tokenName
=
"NEW"
tokenSym
=
"NEW"
tokenIntro
=
"newtoken"
tokenName
=
"NEW"
tokenSym
=
"NEW"
tokenIntro
=
"newtoken"
tokenPrice
int64
tokenAmount
int64
=
1000
*
1e4
*
1e4
execName
=
"user.p.guodun.token"
...
...
@@ -164,7 +164,7 @@ func TestPrecreate(t *testing.T) {
}
precreate
:=
&
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionPreCreate
,
Value
:
&
tokenty
.
TokenAction_TokenPreCreate
{
TokenPreCreate
:
v
},
Value
:
&
tokenty
.
TokenAction_TokenPreCreate
{
TokenPreCreate
:
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
execName
),
...
...
@@ -205,7 +205,7 @@ func TestFinish(t *testing.T) {
v
:=
&
tokenty
.
TokenFinishCreate
{
Symbol
:
tokenSym
,
Owner
:
addr
}
finish
:=
&
tokenty
.
TokenAction
{
Ty
:
tokenty
.
TokenActionFinishCreate
,
Value
:
&
tokenty
.
TokenAction_TokenFinishCreate
{
TokenFinishCreate
:
v
},
Value
:
&
tokenty
.
TokenAction_TokenFinishCreate
{
TokenFinishCreate
:
v
},
}
tx
:=
&
types
.
Transaction
{
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) {
func
(
t
*
tokenDB
)
getLogs
(
ty
int32
,
status
int32
)
[]
*
types
.
ReceiptLog
{
var
log
[]
*
types
.
ReceiptLog
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
})
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
})
return
log
}
...
...
@@ -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
func
(
t
*
tokenDB
)
getKVSet
(
key
[]
byte
)
(
kvset
[]
*
types
.
KeyValue
)
{
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
}
...
...
@@ -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,
// "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
}
...
...
@@ -242,7 +242,7 @@ func (action *tokenAction) finishCreate(tokenFinish *pty.TokenFinishCreate) (*ty
//因为该token已经被创建,需要保存一个全局的token,防止其他用户再次创建
tokendb
.
save
(
action
.
db
,
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
}
...
...
@@ -297,7 +297,7 @@ func (action *tokenAction) revokeCreate(tokenRevoke *pty.TokenRevokeCreate) (*ty
logs
=
append
(
logs
,
tokendb
.
getLogs
(
pty
.
TyLogRevokeCreateToken
,
pty
.
TokenStatusCreateRevoked
)
...
)
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
}
...
...
@@ -410,7 +410,7 @@ func AddTokenToAssets(addr string, db dbm.KVDB, symbol string) []*types.KeyValue
tokenAssets
.
Datas
=
append
(
tokenAssets
.
Datas
,
symbol
)
}
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
}
...
...
plugin/dapp/token/executor/tokentxlist.go
View file @
c829ea34
...
...
@@ -31,7 +31,7 @@ func tokenTxKvs(tx *types.Transaction, symbol string, height, index int64, isDel
txInfo
=
makeReplyTxInfo
(
tx
,
height
,
index
,
symbol
)
}
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
}
...
...
plugin/dapp/token/executor/transwithdraw.go
View file @
c829ea34
...
...
@@ -135,9 +135,9 @@ func (t *token) ExecDelLocalLocalTransWithdraw(tx *types.Transaction, receipt *t
}
func
getAddrReciverKV
(
token
string
,
addr
string
,
reciverAmount
int64
)
*
types
.
KeyValue
{
reciver
:=
&
types
.
Int64
{
Data
:
reciverAmount
}
reciver
:=
&
types
.
Int64
{
Data
:
reciverAmount
}
amountbytes
:=
types
.
Encode
(
reciver
)
kv
:=
&
types
.
KeyValue
{
Key
:
calcAddrKey
(
token
,
addr
),
Value
:
amountbytes
}
kv
:=
&
types
.
KeyValue
{
Key
:
calcAddrKey
(
token
,
addr
),
Value
:
amountbytes
}
return
kv
}
...
...
plugin/dapp/token/types/const.go
View file @
c829ea34
...
...
@@ -6,17 +6,17 @@ package types
const
(
// ActionTransfer for transfer
ActionTransfer
=
4
ActionTransfer
=
4
// ActionGenesis for genesis
ActionGenesis
=
5
ActionGenesis
=
5
// ActionWithdraw for Withdraw
ActionWithdraw
=
6
ActionWithdraw
=
6
// TokenActionPreCreate for token pre create
TokenActionPreCreate
=
7
TokenActionPreCreate
=
7
// TokenActionFinishCreate for token finish create
TokenActionFinishCreate
=
8
TokenActionFinishCreate
=
8
// TokenActionRevokeCreate for token revoke create
TokenActionRevokeCreate
=
9
TokenActionRevokeCreate
=
9
// TokenActionTransferToExec for token transfer to exec
TokenActionTransferToExec
=
11
)
...
...
@@ -38,38 +38,38 @@ var (
const
(
// TyLogPreCreateToken log for pre create token
TyLogPreCreateToken
=
211
TyLogPreCreateToken
=
211
// TyLogFinishCreateToken log for finish create token
TyLogFinishCreateToken
=
212
TyLogFinishCreateToken
=
212
// TyLogRevokeCreateToken log for revoke create token
TyLogRevokeCreateToken
=
213
TyLogRevokeCreateToken
=
213
// TyLogTokenTransfer log for token tranfer
TyLogTokenTransfer
=
313
TyLogTokenTransfer
=
313
// TyLogTokenGenesis log for token genesis
TyLogTokenGenesis
=
314
TyLogTokenGenesis
=
314
// TyLogTokenDeposit log for token deposit
TyLogTokenDeposit
=
315
TyLogTokenDeposit
=
315
// TyLogTokenExecTransfer log for token exec transfer
TyLogTokenExecTransfer
=
316
TyLogTokenExecTransfer
=
316
// TyLogTokenExecWithdraw log for token exec withdraw
TyLogTokenExecWithdraw
=
317
TyLogTokenExecWithdraw
=
317
// TyLogTokenExecDeposit log for token exec deposit
TyLogTokenExecDeposit
=
318
TyLogTokenExecDeposit
=
318
// TyLogTokenExecFrozen log for token exec frozen
TyLogTokenExecFrozen
=
319
TyLogTokenExecFrozen
=
319
// TyLogTokenExecActive log for token exec active
TyLogTokenExecActive
=
320
TyLogTokenExecActive
=
320
// TyLogTokenGenesisTransfer log for token genesis rransfer
TyLogTokenGenesisTransfer
=
321
// TyLogTokenGenesisDeposit log for token genesis deposit
TyLogTokenGenesisDeposit
=
322
TyLogTokenGenesisDeposit
=
322
)
const
(
// TokenNameLenLimit token name length limit
TokenNameLenLimit
=
128
TokenNameLenLimit
=
128
// TokenSymbolLenLimit token symbol length limit
TokenSymbolLenLimit
=
16
// TokenIntroLenLimit token introduction length limit
TokenIntroLenLimit
=
1024
TokenIntroLenLimit
=
1024
)
plugin/dapp/token/types/errors.go
View file @
c829ea34
...
...
@@ -8,31 +8,31 @@ import "errors"
var
(
// ErrTokenNameLen error token name length
ErrTokenNameLen
=
errors
.
New
(
"ErrTokenNameLength"
)
ErrTokenNameLen
=
errors
.
New
(
"ErrTokenNameLength"
)
// ErrTokenSymbolLen error token symbol length
ErrTokenSymbolLen
=
errors
.
New
(
"ErrTokenSymbolLength"
)
ErrTokenSymbolLen
=
errors
.
New
(
"ErrTokenSymbolLength"
)
// ErrTokenTotalOverflow error token total Overflow
ErrTokenTotalOverflow
=
errors
.
New
(
"ErrTokenTotalOverflow"
)
ErrTokenTotalOverflow
=
errors
.
New
(
"ErrTokenTotalOverflow"
)
// ErrTokenSymbolUpper error token total Overflow
ErrTokenSymbolUpper
=
errors
.
New
(
"ErrTokenSymbolUpper"
)
ErrTokenSymbolUpper
=
errors
.
New
(
"ErrTokenSymbolUpper"
)
// ErrTokenIntroLen error token introduction length
ErrTokenIntroLen
=
errors
.
New
(
"ErrTokenIntroductionLen"
)
ErrTokenIntroLen
=
errors
.
New
(
"ErrTokenIntroductionLen"
)
// ErrTokenExist error token symbol exist already
ErrTokenExist
=
errors
.
New
(
"ErrTokenSymbolExistAlready"
)
ErrTokenExist
=
errors
.
New
(
"ErrTokenSymbolExistAlready"
)
// ErrTokenNotPrecreated error token not pre created
ErrTokenNotPrecreated
=
errors
.
New
(
"ErrTokenNotPrecreated"
)
ErrTokenNotPrecreated
=
errors
.
New
(
"ErrTokenNotPrecreated"
)
// ErrTokenCreatedApprover error token created approver
ErrTokenCreatedApprover
=
errors
.
New
(
"ErrTokenCreatedApprover"
)
// ErrTokenRevoker error token revoker
ErrTokenRevoker
=
errors
.
New
(
"ErrTokenRevoker"
)
ErrTokenRevoker
=
errors
.
New
(
"ErrTokenRevoker"
)
// ErrTokenCanotRevoked error token canot revoked with wrong status
ErrTokenCanotRevoked
=
errors
.
New
(
"ErrTokenCanotRevokedWithWrongStatus"
)
ErrTokenCanotRevoked
=
errors
.
New
(
"ErrTokenCanotRevokedWithWrongStatus"
)
// ErrTokenOwner error token symbol owner not match
ErrTokenOwner
=
errors
.
New
(
"ErrTokenSymbolOwnerNotMatch"
)
ErrTokenOwner
=
errors
.
New
(
"ErrTokenSymbolOwnerNotMatch"
)
// ErrTokenHavePrecreated error owner have token pre create yet
ErrTokenHavePrecreated
=
errors
.
New
(
"ErrOwnerHaveTokenPrecreateYet"
)
ErrTokenHavePrecreated
=
errors
.
New
(
"ErrOwnerHaveTokenPrecreateYet"
)
// ErrTokenBlacklist error token blacklist
ErrTokenBlacklist
=
errors
.
New
(
"ErrTokenBlacklist"
)
ErrTokenBlacklist
=
errors
.
New
(
"ErrTokenBlacklist"
)
// ErrTokenNotExist error token symbol not exist
ErrTokenNotExist
=
errors
.
New
(
"ErrTokenSymbolNotExist"
)
ErrTokenNotExist
=
errors
.
New
(
"ErrTokenSymbolNotExist"
)
)
plugin/store/mpt/db/node.go
View file @
c829ea34
...
...
@@ -40,11 +40,11 @@ type node interface {
const
(
// TyFullNode 全节点类型
TyFullNode
=
1
TyFullNode
=
1
// TyShortNode 扩展节点类型
TyShortNode
=
2
// TyHashNode hash节点类型
TyHashNode
=
3
TyHashNode
=
3
// TyValueNode value节点类型
TyValueNode
=
4
)
...
...
plugin/store/mpt/db2/rlp/decode.go
View file @
c829ea34
...
...
@@ -38,17 +38,17 @@ var (
ErrFoo
=
errors
.
New
(
"rlp: end of list"
)
// ErrExpectedString expected String or Byte
ErrExpectedString
=
errors
.
New
(
"rlp: expected String or Byte"
)
ErrExpectedString
=
errors
.
New
(
"rlp: expected String or Byte"
)
// ErrExpectedList expected List
ErrExpectedList
=
errors
.
New
(
"rlp: expected List"
)
ErrExpectedList
=
errors
.
New
(
"rlp: expected List"
)
// ErrCanonInt non-canonical integer format
ErrCanonInt
=
errors
.
New
(
"rlp: non-canonical integer format"
)
ErrCanonInt
=
errors
.
New
(
"rlp: non-canonical integer format"
)
// ErrCanonSize non-canonical size information
ErrCanonSize
=
errors
.
New
(
"rlp: non-canonical size information"
)
ErrCanonSize
=
errors
.
New
(
"rlp: non-canonical size information"
)
// ErrElemTooLarge element is larger than containing list
ErrElemTooLarge
=
errors
.
New
(
"rlp: element is larger than containing list"
)
ErrElemTooLarge
=
errors
.
New
(
"rlp: element is larger than containing list"
)
// ErrValueTooLarge value size exceeds available input length
ErrValueTooLarge
=
errors
.
New
(
"rlp: value size exceeds available input length"
)
ErrValueTooLarge
=
errors
.
New
(
"rlp: value size exceeds available input length"
)
// ErrMoreThanOneValue input contains more than one value
ErrMoreThanOneValue
=
errors
.
New
(
"rlp: input contains more than one value"
)
...
...
plugin/store/mpt/db2/rlp/encode.go
View file @
c829ea34
...
...
@@ -34,7 +34,7 @@ var (
// These are useful when implementing EncodeRLP.
EmptyString
=
[]
byte
{
0x80
}
// EmptyList rlp definition
EmptyList
=
[]
byte
{
0xC0
}
EmptyList
=
[]
byte
{
0xC0
}
)
// Encoder is implemented by types that require custom
...
...
plugin/store/mpt/mpt_test.go
View file @
c829ea34
...
...
@@ -46,7 +46,7 @@ func TestKvddbSetGet(t *testing.T) {
assert
.
NotNil
(
t
,
store
)
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
)
mlog
.
Info
(
"info"
,
"info"
,
values0
)
// Get exist key, result nil
...
...
@@ -55,16 +55,16 @@ func TestKvddbSetGet(t *testing.T) {
assert
.
Equal
(
t
,
[]
byte
(
nil
),
values0
[
1
])
var
kv
[]
*
types
.
KeyValue
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
(
"k1"
),
Value
:
[]
byte
(
"v1"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"k2"
),
Value
:
[]
byte
(
"v2"
)})
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
hash
,
err
:=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
keys
:=
[][]
byte
{[]
byte
(
"k1"
),
[]
byte
(
"k2"
)}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
values
:=
store
.
Get
(
get1
)
assert
.
Len
(
t
,
values
,
2
)
...
...
@@ -72,12 +72,12 @@ func TestKvddbSetGet(t *testing.T) {
assert
.
Equal
(
t
,
[]
byte
(
"v2"
),
values
[
1
])
keys
=
[][]
byte
{[]
byte
(
"k1"
)}
get2
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
get2
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
values2
:=
store
.
Get
(
get2
)
assert
.
Len
(
t
,
values2
,
1
)
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
)
assert
.
Len
(
t
,
values3
,
1
)
assert
.
Equal
(
t
,
[]
byte
(
nil
),
values3
[
0
])
...
...
@@ -93,24 +93,24 @@ func TestKvdbMemSet(t *testing.T) {
assert
.
NotNil
(
t
,
store
)
var
kv
[]
*
types
.
KeyValue
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
(
"mk1"
),
Value
:
[]
byte
(
"v1"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk2"
),
Value
:
[]
byte
(
"v2"
)})
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
keys
:=
[][]
byte
{[]
byte
(
"mk1"
),
[]
byte
(
"mk2"
)}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
values
:=
store
.
Get
(
get1
)
assert
.
Len
(
t
,
values
,
2
)
actHash
,
_
:=
store
.
Commit
(
&
types
.
ReqHash
{
Hash
:
hash
})
actHash
,
_
:=
store
.
Commit
(
&
types
.
ReqHash
{
Hash
:
hash
})
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
)
}
...
...
@@ -124,23 +124,23 @@ func TestKvdbRollback(t *testing.T) {
assert
.
NotNil
(
t
,
store
)
var
kv
[]
*
types
.
KeyValue
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
(
"mk1"
),
Value
:
[]
byte
(
"v1"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk2"
),
Value
:
[]
byte
(
"v2"
)})
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
keys
:=
[][]
byte
{[]
byte
(
"mk1"
),
[]
byte
(
"mk2"
)}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
values
:=
store
.
Get
(
get1
)
assert
.
Len
(
t
,
values
,
2
)
actHash
,
_
:=
store
.
Rollback
(
&
types
.
ReqHash
{
Hash
:
hash
})
actHash
,
_
:=
store
.
Rollback
(
&
types
.
ReqHash
{
Hash
:
hash
})
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
)
}
...
...
@@ -148,7 +148,7 @@ var checkKVResult []*types.KeyValue
func
checkKV
(
k
,
v
[]
byte
)
bool
{
checkKVResult
=
append
(
checkKVResult
,
&
types
.
KeyValue
{
Key
:
k
,
Value
:
v
})
&
types
.
KeyValue
{
Key
:
k
,
Value
:
v
})
//mlog.Debug("checkKV", "key", string(k), "value", string(v))
return
false
}
...
...
@@ -174,16 +174,16 @@ func BenchmarkGet(b *testing.B) {
key
:=
GetRandomString
(
MaxKeylenth
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
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
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
b
,
err
)
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
)
assert
.
Nil
(
b
,
err
)
}
...
...
@@ -191,8 +191,8 @@ func BenchmarkGet(b *testing.B) {
b
.
ResetTimer
()
for
_
,
key
:=
range
keys
{
getData
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
[][]
byte
{
key
}}
StateHash
:
hash
,
Keys
:
[][]
byte
{
key
}}
store
.
Get
(
getData
)
}
end
:=
time
.
Now
()
...
...
@@ -216,16 +216,16 @@ func BenchmarkSet(b *testing.B) {
key
:=
GetRandomString
(
MaxKeylenth
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
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
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
b
,
err
)
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
)
assert
.
Nil
(
b
,
err
)
}
...
...
@@ -251,12 +251,12 @@ func BenchmarkMemSet(b *testing.B) {
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
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
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
start
:=
time
.
Now
()
b
.
ResetTimer
()
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
...
...
@@ -284,12 +284,12 @@ func BenchmarkCommit(b *testing.B) {
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
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
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
assert
.
Nil
(
b
,
err
)
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