Commit c829ea34 authored by gitlab's avatar gitlab

auto ci

parent 2d62cb6b
...@@ -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
...@@ -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
} }
......
...@@ -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),
......
...@@ -22,26 +22,26 @@ const ( ...@@ -22,26 +22,26 @@ const (
const ( const (
// TyLogBlackwhiteCreate log for blackwhite create game // TyLogBlackwhiteCreate log for blackwhite create game
TyLogBlackwhiteCreate = 750 TyLogBlackwhiteCreate = 750
// TyLogBlackwhitePlay log for blackwhite play game // TyLogBlackwhitePlay log for blackwhite play game
TyLogBlackwhitePlay = 751 TyLogBlackwhitePlay = 751
// TyLogBlackwhiteShow log for blackwhite show game // TyLogBlackwhiteShow log for blackwhite show game
TyLogBlackwhiteShow = 752 TyLogBlackwhiteShow = 752
// TyLogBlackwhiteTimeout log for blackwhite timeout game // TyLogBlackwhiteTimeout log for blackwhite timeout game
TyLogBlackwhiteTimeout = 753 TyLogBlackwhiteTimeout = 753
// TyLogBlackwhiteDone log for blackwhite down game // TyLogBlackwhiteDone log for blackwhite down game
TyLogBlackwhiteDone = 754 TyLogBlackwhiteDone = 754
// TyLogBlackwhiteLoopInfo log for blackwhite LoopInfo game // TyLogBlackwhiteLoopInfo log for blackwhite LoopInfo game
TyLogBlackwhiteLoopInfo = 755 TyLogBlackwhiteLoopInfo = 755
) )
const ( const (
// GetBlackwhiteRoundInfo 用于在cmd里面的区分不同的查询 // GetBlackwhiteRoundInfo 用于在cmd里面的区分不同的查询
GetBlackwhiteRoundInfo = "GetBlackwhiteRoundInfo" GetBlackwhiteRoundInfo = "GetBlackwhiteRoundInfo"
// GetBlackwhiteByStatusAndAddr 用于在cmd里面的区分不同的查询 // GetBlackwhiteByStatusAndAddr 用于在cmd里面的区分不同的查询
GetBlackwhiteByStatusAndAddr = "GetBlackwhiteByStatusAndAddr" GetBlackwhiteByStatusAndAddr = "GetBlackwhiteByStatusAndAddr"
// GetBlackwhiteloopResult 用于在cmd里面的区分不同的查询 // GetBlackwhiteloopResult 用于在cmd里面的区分不同的查询
GetBlackwhiteloopResult = "GetBlackwhiteloopResult" GetBlackwhiteloopResult = "GetBlackwhiteloopResult"
) )
var ( var (
...@@ -49,7 +49,7 @@ var ( ...@@ -49,7 +49,7 @@ var (
BlackwhiteX = "blackwhite" BlackwhiteX = "blackwhite"
glog = log15.New("module", BlackwhiteX) glog = log15.New("module", BlackwhiteX)
// JRPCName json RPC name // JRPCName json RPC name
JRPCName = "Blackwhite" JRPCName = "Blackwhite"
// ExecerBlackwhite 执行器名字byte形式 // ExecerBlackwhite 执行器名字byte形式
ExecerBlackwhite = []byte(BlackwhiteX) ExecerBlackwhite = []byte(BlackwhiteX)
actionName = map[string]int32{ actionName = map[string]int32{
......
...@@ -8,13 +8,13 @@ import "errors" ...@@ -8,13 +8,13 @@ import "errors"
var ( var (
// ErrIncorrectStatus 所处游戏状态不正确 // ErrIncorrectStatus 所处游戏状态不正确
ErrIncorrectStatus = errors.New("ErrIncorrectStatus") ErrIncorrectStatus = errors.New("ErrIncorrectStatus")
// ErrRepeatPlayerAddr 重复玩家 // ErrRepeatPlayerAddr 重复玩家
ErrRepeatPlayerAddr = errors.New("ErrRepeatPlayerAddress") ErrRepeatPlayerAddr = errors.New("ErrRepeatPlayerAddress")
// ErrNoTimeoutDone 还未超时 // ErrNoTimeoutDone 还未超时
ErrNoTimeoutDone = errors.New("ErrNoTimeoutDone") ErrNoTimeoutDone = errors.New("ErrNoTimeoutDone")
// ErrNoExistAddr 不存在地址,未参与游戏 // ErrNoExistAddr 不存在地址,未参与游戏
ErrNoExistAddr = errors.New("ErrNoExistAddress") ErrNoExistAddr = errors.New("ErrNoExistAddress")
// ErrNoLoopSeq 查询的轮次大于决出胜负的轮次 // ErrNoLoopSeq 查询的轮次大于决出胜负的轮次
ErrNoLoopSeq = errors.New("ErrBlackwhiteFinalloopLessThanSeq") ErrNoLoopSeq = errors.New("ErrBlackwhiteFinalloopLessThanSeq")
) )
...@@ -42,7 +42,7 @@ func NewType() *BlackwhiteType { ...@@ -42,7 +42,7 @@ func NewType() *BlackwhiteType {
return c return c
} }
// GetPayload 获取blackwhite action // GetPayload 获取blackwhite action
func (b *BlackwhiteType) GetPayload() types.Message { func (b *BlackwhiteType) GetPayload() types.Message {
return &BlackwhiteAction{} return &BlackwhiteAction{}
} }
......
...@@ -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{
......
...@@ -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 的创建
......
...@@ -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)
......
...@@ -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)
......
...@@ -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)
......
...@@ -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
} }
......
...@@ -55,9 +55,9 @@ const ( ...@@ -55,9 +55,9 @@ const (
//for token //for token
var ( var (
tokenName = "NEW" tokenName = "NEW"
tokenSym = "NEW" tokenSym = "NEW"
tokenIntro = "newtoken" tokenIntro = "newtoken"
tokenPrice int64 tokenPrice int64
tokenAmount int64 = 1000 * 1e4 * 1e4 tokenAmount int64 = 1000 * 1e4 * 1e4
execName = "user.p.guodun.token" execName = "user.p.guodun.token"
...@@ -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),
......
...@@ -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
} }
......
...@@ -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
} }
......
...@@ -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
} }
......
...@@ -6,17 +6,17 @@ package types ...@@ -6,17 +6,17 @@ package types
const ( const (
// ActionTransfer for transfer // ActionTransfer for transfer
ActionTransfer = 4 ActionTransfer = 4
// ActionGenesis for genesis // ActionGenesis for genesis
ActionGenesis = 5 ActionGenesis = 5
// ActionWithdraw for Withdraw // ActionWithdraw for Withdraw
ActionWithdraw = 6 ActionWithdraw = 6
// TokenActionPreCreate for token pre create // TokenActionPreCreate for token pre create
TokenActionPreCreate = 7 TokenActionPreCreate = 7
// TokenActionFinishCreate for token finish create // TokenActionFinishCreate for token finish create
TokenActionFinishCreate = 8 TokenActionFinishCreate = 8
// TokenActionRevokeCreate for token revoke create // TokenActionRevokeCreate for token revoke create
TokenActionRevokeCreate = 9 TokenActionRevokeCreate = 9
// TokenActionTransferToExec for token transfer to exec // TokenActionTransferToExec for token transfer to exec
TokenActionTransferToExec = 11 TokenActionTransferToExec = 11
) )
...@@ -38,38 +38,38 @@ var ( ...@@ -38,38 +38,38 @@ var (
const ( const (
// TyLogPreCreateToken log for pre create token // TyLogPreCreateToken log for pre create token
TyLogPreCreateToken = 211 TyLogPreCreateToken = 211
// TyLogFinishCreateToken log for finish create token // TyLogFinishCreateToken log for finish create token
TyLogFinishCreateToken = 212 TyLogFinishCreateToken = 212
// TyLogRevokeCreateToken log for revoke create token // TyLogRevokeCreateToken log for revoke create token
TyLogRevokeCreateToken = 213 TyLogRevokeCreateToken = 213
// TyLogTokenTransfer log for token tranfer // TyLogTokenTransfer log for token tranfer
TyLogTokenTransfer = 313 TyLogTokenTransfer = 313
// TyLogTokenGenesis log for token genesis // TyLogTokenGenesis log for token genesis
TyLogTokenGenesis = 314 TyLogTokenGenesis = 314
// TyLogTokenDeposit log for token deposit // TyLogTokenDeposit log for token deposit
TyLogTokenDeposit = 315 TyLogTokenDeposit = 315
// TyLogTokenExecTransfer log for token exec transfer // TyLogTokenExecTransfer log for token exec transfer
TyLogTokenExecTransfer = 316 TyLogTokenExecTransfer = 316
// TyLogTokenExecWithdraw log for token exec withdraw // TyLogTokenExecWithdraw log for token exec withdraw
TyLogTokenExecWithdraw = 317 TyLogTokenExecWithdraw = 317
// TyLogTokenExecDeposit log for token exec deposit // TyLogTokenExecDeposit log for token exec deposit
TyLogTokenExecDeposit = 318 TyLogTokenExecDeposit = 318
// TyLogTokenExecFrozen log for token exec frozen // TyLogTokenExecFrozen log for token exec frozen
TyLogTokenExecFrozen = 319 TyLogTokenExecFrozen = 319
// TyLogTokenExecActive log for token exec active // TyLogTokenExecActive log for token exec active
TyLogTokenExecActive = 320 TyLogTokenExecActive = 320
// TyLogTokenGenesisTransfer log for token genesis rransfer // TyLogTokenGenesisTransfer log for token genesis rransfer
TyLogTokenGenesisTransfer = 321 TyLogTokenGenesisTransfer = 321
// TyLogTokenGenesisDeposit log for token genesis deposit // TyLogTokenGenesisDeposit log for token genesis deposit
TyLogTokenGenesisDeposit = 322 TyLogTokenGenesisDeposit = 322
) )
const ( const (
// TokenNameLenLimit token name length limit // TokenNameLenLimit token name length limit
TokenNameLenLimit = 128 TokenNameLenLimit = 128
// TokenSymbolLenLimit token symbol length limit // TokenSymbolLenLimit token symbol length limit
TokenSymbolLenLimit = 16 TokenSymbolLenLimit = 16
// TokenIntroLenLimit token introduction length limit // TokenIntroLenLimit token introduction length limit
TokenIntroLenLimit = 1024 TokenIntroLenLimit = 1024
) )
...@@ -8,31 +8,31 @@ import "errors" ...@@ -8,31 +8,31 @@ import "errors"
var ( var (
// ErrTokenNameLen error token name length // ErrTokenNameLen error token name length
ErrTokenNameLen = errors.New("ErrTokenNameLength") ErrTokenNameLen = errors.New("ErrTokenNameLength")
// ErrTokenSymbolLen error token symbol length // ErrTokenSymbolLen error token symbol length
ErrTokenSymbolLen = errors.New("ErrTokenSymbolLength") ErrTokenSymbolLen = errors.New("ErrTokenSymbolLength")
// ErrTokenTotalOverflow error token total Overflow // ErrTokenTotalOverflow error token total Overflow
ErrTokenTotalOverflow = errors.New("ErrTokenTotalOverflow") ErrTokenTotalOverflow = errors.New("ErrTokenTotalOverflow")
// ErrTokenSymbolUpper error token total Overflow // ErrTokenSymbolUpper error token total Overflow
ErrTokenSymbolUpper = errors.New("ErrTokenSymbolUpper") ErrTokenSymbolUpper = errors.New("ErrTokenSymbolUpper")
// ErrTokenIntroLen error token introduction length // ErrTokenIntroLen error token introduction length
ErrTokenIntroLen = errors.New("ErrTokenIntroductionLen") ErrTokenIntroLen = errors.New("ErrTokenIntroductionLen")
// ErrTokenExist error token symbol exist already // ErrTokenExist error token symbol exist already
ErrTokenExist = errors.New("ErrTokenSymbolExistAlready") ErrTokenExist = errors.New("ErrTokenSymbolExistAlready")
// ErrTokenNotPrecreated error token not pre created // ErrTokenNotPrecreated error token not pre created
ErrTokenNotPrecreated = errors.New("ErrTokenNotPrecreated") ErrTokenNotPrecreated = errors.New("ErrTokenNotPrecreated")
// ErrTokenCreatedApprover error token created approver // ErrTokenCreatedApprover error token created approver
ErrTokenCreatedApprover = errors.New("ErrTokenCreatedApprover") ErrTokenCreatedApprover = errors.New("ErrTokenCreatedApprover")
// ErrTokenRevoker error token revoker // ErrTokenRevoker error token revoker
ErrTokenRevoker = errors.New("ErrTokenRevoker") ErrTokenRevoker = errors.New("ErrTokenRevoker")
// ErrTokenCanotRevoked error token canot revoked with wrong status // ErrTokenCanotRevoked error token canot revoked with wrong status
ErrTokenCanotRevoked = errors.New("ErrTokenCanotRevokedWithWrongStatus") ErrTokenCanotRevoked = errors.New("ErrTokenCanotRevokedWithWrongStatus")
// ErrTokenOwner error token symbol owner not match // ErrTokenOwner error token symbol owner not match
ErrTokenOwner = errors.New("ErrTokenSymbolOwnerNotMatch") ErrTokenOwner = errors.New("ErrTokenSymbolOwnerNotMatch")
// ErrTokenHavePrecreated error owner have token pre create yet // ErrTokenHavePrecreated error owner have token pre create yet
ErrTokenHavePrecreated = errors.New("ErrOwnerHaveTokenPrecreateYet") ErrTokenHavePrecreated = errors.New("ErrOwnerHaveTokenPrecreateYet")
// ErrTokenBlacklist error token blacklist // ErrTokenBlacklist error token blacklist
ErrTokenBlacklist = errors.New("ErrTokenBlacklist") ErrTokenBlacklist = errors.New("ErrTokenBlacklist")
// ErrTokenNotExist error token symbol not exist // ErrTokenNotExist error token symbol not exist
ErrTokenNotExist = errors.New("ErrTokenSymbolNotExist") ErrTokenNotExist = errors.New("ErrTokenSymbolNotExist")
) )
...@@ -40,11 +40,11 @@ type node interface { ...@@ -40,11 +40,11 @@ type node interface {
const ( const (
// TyFullNode 全节点类型 // TyFullNode 全节点类型
TyFullNode = 1 TyFullNode = 1
// TyShortNode 扩展节点类型 // TyShortNode 扩展节点类型
TyShortNode = 2 TyShortNode = 2
// TyHashNode hash节点类型 // TyHashNode hash节点类型
TyHashNode = 3 TyHashNode = 3
// TyValueNode value节点类型 // TyValueNode value节点类型
TyValueNode = 4 TyValueNode = 4
) )
......
...@@ -38,17 +38,17 @@ var ( ...@@ -38,17 +38,17 @@ var (
ErrFoo = errors.New("rlp: end of list") ErrFoo = errors.New("rlp: end of list")
// ErrExpectedString expected String or Byte // 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 expected List
ErrExpectedList = errors.New("rlp: expected List") ErrExpectedList = errors.New("rlp: expected List")
// ErrCanonInt non-canonical integer format // 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 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 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 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 input contains more than one value
ErrMoreThanOneValue = errors.New("rlp: input contains more than one value") ErrMoreThanOneValue = errors.New("rlp: input contains more than one value")
......
...@@ -34,7 +34,7 @@ var ( ...@@ -34,7 +34,7 @@ var (
// These are useful when implementing EncodeRLP. // These are useful when implementing EncodeRLP.
EmptyString = []byte{0x80} EmptyString = []byte{0x80}
// EmptyList rlp definition // EmptyList rlp definition
EmptyList = []byte{0xC0} EmptyList = []byte{0xC0}
) )
// Encoder is implemented by types that require custom // Encoder is implemented by types that require custom
......
...@@ -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{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment