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
1128378d
Commit
1128378d
authored
Nov 21, 2018
by
pengjun
Committed by
vipwzw
Nov 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix go vet warning
parent
5f1f7406
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
23 deletions
+40
-23
authority_test.go
plugin/dapp/cert/authority/authority_test.go
+1
-1
cert.go
plugin/dapp/cert/authority/core/cert.go
+3
-3
cert.go
plugin/dapp/cert/executor/cert.go
+7
-2
exec_local.go
plugin/dapp/cert/executor/exec_local.go
+16
-4
game.go
plugin/dapp/pokerbull/commands/game.go
+1
-1
pokerbulldb.go
plugin/dapp/pokerbull/executor/pokerbulldb.go
+7
-7
query.go
plugin/dapp/pokerbull/executor/query.go
+1
-1
rpc.go
plugin/dapp/pokerbull/rpc/rpc.go
+4
-4
No files found.
plugin/dapp/cert/authority/authority_test.go
View file @
1128378d
...
...
@@ -42,7 +42,7 @@ var (
txs
=
[]
*
types
.
Transaction
{
tx1
,
tx2
,
tx3
,
tx4
,
tx5
,
tx6
,
tx7
,
tx8
,
tx9
,
tx10
,
tx11
,
tx12
}
privRaw
,
_
=
common
.
FromHex
(
"CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
)
tr
=
&
cty
.
CoinsAction_Transfer
{
&
types
.
AssetsTransfer
{
Amount
:
int64
(
1e8
)}}
tr
=
&
cty
.
CoinsAction_Transfer
{
Transfer
:
&
types
.
AssetsTransfer
{
Amount
:
int64
(
1e8
)}}
secpp256
,
_
=
crypto
.
New
(
types
.
GetSignName
(
""
,
types
.
SECP256K1
))
privKey
,
_
=
secpp256
.
PrivKeyFromBytes
(
privRaw
)
tx14
=
&
types
.
Transaction
{
...
...
plugin/dapp/cert/authority/core/cert.go
View file @
1128378d
...
...
@@ -112,9 +112,9 @@ func certFromX509Cert(cert *x509.Certificate) (certificate, error) {
// ParseECDSAPubKey2SM2PubKey 将ECDSA的公钥转成SM2公钥
func
ParseECDSAPubKey2SM2PubKey
(
key
*
ecdsa
.
PublicKey
)
*
sm2
.
PublicKey
{
sm2Key
:=
&
sm2
.
PublicKey
{
key
.
Curve
,
key
.
X
,
key
.
Y
,
Curve
:
key
.
Curve
,
X
:
key
.
X
,
Y
:
key
.
Y
,
}
return
sm2Key
...
...
plugin/dapp/cert/executor/cert.go
View file @
1128378d
...
...
@@ -91,7 +91,12 @@ func (c *Cert) CheckTx(tx *types.Transaction, index int) error {
根据前缀查找证书变更记录,cert回滚、重启、同步用到
*/
func
(
c
*
Cert
)
loadHistoryByPrefix
()
error
{
parm
:=
&
types
.
LocalDBList
{[]
byte
(
"LODB-cert-"
),
nil
,
0
,
0
}
parm
:=
&
types
.
LocalDBList
{
Prefix
:
[]
byte
(
"LODB-cert-"
),
Key
:
nil
,
Direction
:
0
,
Count
:
0
,
}
result
,
err
:=
c
.
DriverBase
.
GetApi
()
.
LocalList
(
parm
)
if
err
!=
nil
{
return
err
...
...
@@ -120,7 +125,7 @@ func (c *Cert) loadHistoryByPrefix() error {
*/
func
(
c
*
Cert
)
loadHistoryByHeight
()
error
{
key
:=
calcCertHeightKey
(
c
.
GetHeight
())
parm
:=
&
types
.
LocalDBGet
{[][]
byte
{
key
}}
parm
:=
&
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
result
,
err
:=
c
.
DriverBase
.
GetApi
()
.
LocalGet
(
parm
)
if
err
!=
nil
{
return
err
...
...
plugin/dapp/cert/executor/exec_local.go
View file @
1128378d
...
...
@@ -28,13 +28,19 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt
authority
.
Author
.
HistoryCertCache
.
CurHeight
=
c
.
GetHeight
()
authority
.
Author
.
HistoryCertCache
.
ToHistoryCertStore
(
historityCertdata
)
key
:=
calcCertHeightKey
(
c
.
GetHeight
())
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
key
,
types
.
Encode
(
historityCertdata
)})
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
historityCertdata
),
})
// 构造非证书历史数据
noneCertdata
:=
&
types
.
HistoryCertStore
{}
noneCertdata
.
NxtHeight
=
historityCertdata
.
CurHeigth
noneCertdata
.
CurHeigth
=
0
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
calcCertHeightKey
(
0
),
types
.
Encode
(
noneCertdata
)})
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcCertHeightKey
(
0
),
Value
:
types
.
Encode
(
noneCertdata
),
})
return
&
set
,
nil
}
...
...
@@ -52,14 +58,20 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r
historityCertdata
:=
&
types
.
HistoryCertStore
{}
authority
.
Author
.
HistoryCertCache
.
NxtHeight
=
c
.
GetHeight
()
authority
.
Author
.
HistoryCertCache
.
ToHistoryCertStore
(
historityCertdata
)
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
key
,
types
.
Encode
(
historityCertdata
)})
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
historityCertdata
),
})
// 证书更新
historityCertdata
=
&
types
.
HistoryCertStore
{}
authority
.
Author
.
ReloadCertByHeght
(
c
.
GetHeight
())
authority
.
Author
.
HistoryCertCache
.
ToHistoryCertStore
(
historityCertdata
)
setKey
:=
calcCertHeightKey
(
c
.
GetHeight
())
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
setKey
,
types
.
Encode
(
historityCertdata
)})
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
setKey
,
Value
:
types
.
Encode
(
historityCertdata
),
})
return
&
set
,
nil
}
...
...
plugin/dapp/pokerbull/commands/game.go
View file @
1128378d
...
...
@@ -195,7 +195,7 @@ func pokerbullQuery(cmd *cobra.Command, args []string) {
var
gameIDsS
[]
string
gameIDsS
=
append
(
gameIDsS
,
gameIDs
)
gameIDsS
=
append
(
gameIDsS
,
gameIDs
)
req
:=
&
pkt
.
QueryPBGameInfos
{
gameIDsS
}
req
:=
&
pkt
.
QueryPBGameInfos
{
GameIds
:
gameIDsS
}
params
.
Payload
=
req
var
res
pkt
.
ReplyPBGameList
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
...
...
plugin/dapp/pokerbull/executor/pokerbulldb.go
View file @
1128378d
...
...
@@ -27,7 +27,7 @@ const (
MaxPlayerNum
=
5
// MinPlayValue 最小赌注
MinPlayValue
=
10
*
types
.
Coin
// DefaultStyle
默认游戏类型
// DefaultStyle默认游戏类型
DefaultStyle
=
pkt
.
PlayStyleDefault
)
...
...
@@ -125,7 +125,7 @@ func getGameListByAddr(db dbm.Lister, addr string, index int64) (types.Message,
gameIds
=
append
(
gameIds
,
&
record
)
}
return
&
pkt
.
PBGameRecords
{
gameIds
},
nil
return
&
pkt
.
PBGameRecords
{
Records
:
gameIds
},
nil
}
func
getGameListByStatus
(
db
dbm
.
Lister
,
status
int32
,
index
int64
)
(
types
.
Message
,
error
)
{
...
...
@@ -150,7 +150,7 @@ func getGameListByStatus(db dbm.Lister, status int32, index int64) (types.Messag
gameIds
=
append
(
gameIds
,
&
record
)
}
return
&
pkt
.
PBGameRecords
{
gameIds
},
nil
return
&
pkt
.
PBGameRecords
{
Records
:
gameIds
},
nil
}
func
queryGameListByStatusAndPlayer
(
db
dbm
.
Lister
,
stat
int32
,
player
int32
,
value
int64
)
([]
string
,
error
)
{
...
...
@@ -175,7 +175,7 @@ func queryGameListByStatusAndPlayer(db dbm.Lister, stat int32, player int32, val
func
(
action
*
Action
)
saveGame
(
game
*
pkt
.
PokerBull
)
(
kvset
[]
*
types
.
KeyValue
)
{
value
:=
types
.
Encode
(
game
)
action
.
db
.
Set
(
Key
(
game
.
GetGameId
()),
value
)
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
(
game
.
GameId
),
value
})
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
Key
(
game
.
GameId
),
Value
:
value
})
return
kvset
}
...
...
@@ -614,7 +614,7 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error)
logs
=
append
(
logs
,
receiptLog
)
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
return
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
func
getReadyPlayerNum
(
players
[]
*
pkt
.
PBPlayer
)
int
{
...
...
@@ -712,7 +712,7 @@ func (action *Action) GameContinue(pbcontinue *pkt.PBGameContinue) (*types.Recei
logs
=
append
(
logs
,
receiptLog
)
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
return
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
// GameQuit 退出游戏
...
...
@@ -768,7 +768,7 @@ func (action *Action) GameQuit(pbend *pkt.PBGameQuit) (*types.Receipt, error) {
receiptLog
:=
action
.
GetReceiptLog
(
game
)
logs
=
append
(
logs
,
receiptLog
)
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
return
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
// HandSlice 一手牌
...
...
plugin/dapp/pokerbull/executor/query.go
View file @
1128378d
...
...
@@ -20,7 +20,7 @@ func (g *PokerBull) Query_QueryGameByID(in *pkt.QueryPBGameInfo) (types.Message,
if
err
!=
nil
{
return
nil
,
err
}
return
&
pkt
.
ReplyPBGame
{
game
},
nil
return
&
pkt
.
ReplyPBGame
{
Game
:
game
},
nil
}
// Query_QueryGameByAddr 根据地址查询游戏
...
...
plugin/dapp/pokerbull/rpc/rpc.go
View file @
1128378d
...
...
@@ -20,7 +20,7 @@ func (c *channelClient) Start(ctx context.Context, head *pb.PBGameStart) (*types
val
:=
&
pb
.
PBGameAction
{
Ty
:
pb
.
PBGameActionStart
,
Value
:
&
pb
.
PBGameAction_Start
{
head
},
Value
:
&
pb
.
PBGameAction_Start
{
Start
:
head
},
}
tx
,
err
:=
types
.
CreateFormatTx
(
pb
.
PokerBullX
,
types
.
Encode
(
val
))
if
err
!=
nil
{
...
...
@@ -33,7 +33,7 @@ func (c *channelClient) Start(ctx context.Context, head *pb.PBGameStart) (*types
func
(
c
*
channelClient
)
Continue
(
ctx
context
.
Context
,
head
*
pb
.
PBGameContinue
)
(
*
types
.
UnsignTx
,
error
)
{
val
:=
&
pb
.
PBGameAction
{
Ty
:
pb
.
PBGameActionContinue
,
Value
:
&
pb
.
PBGameAction_Continue
{
head
},
Value
:
&
pb
.
PBGameAction_Continue
{
Continue
:
head
},
}
tx
,
err
:=
types
.
CreateFormatTx
(
pb
.
PokerBullX
,
types
.
Encode
(
val
))
if
err
!=
nil
{
...
...
@@ -46,7 +46,7 @@ func (c *channelClient) Continue(ctx context.Context, head *pb.PBGameContinue) (
func
(
c
*
channelClient
)
Quit
(
ctx
context
.
Context
,
head
*
pb
.
PBGameQuit
)
(
*
types
.
UnsignTx
,
error
)
{
val
:=
&
pb
.
PBGameAction
{
Ty
:
pb
.
PBGameActionQuit
,
Value
:
&
pb
.
PBGameAction_Quit
{
head
},
Value
:
&
pb
.
PBGameAction_Quit
{
Quit
:
head
},
}
tx
,
err
:=
types
.
CreateFormatTx
(
pb
.
PokerBullX
,
types
.
Encode
(
val
))
if
err
!=
nil
{
...
...
@@ -59,7 +59,7 @@ func (c *channelClient) Quit(ctx context.Context, head *pb.PBGameQuit) (*types.U
func
(
c
*
channelClient
)
Show
(
ctx
context
.
Context
,
head
*
pb
.
PBGameQuery
)
(
*
types
.
UnsignTx
,
error
)
{
val
:=
&
pb
.
PBGameAction
{
Ty
:
pb
.
PBGameActionQuery
,
Value
:
&
pb
.
PBGameAction_Query
{
head
},
Value
:
&
pb
.
PBGameAction_Query
{
Query
:
head
},
}
tx
,
err
:=
types
.
CreateFormatTx
(
pb
.
PokerBullX
,
types
.
Encode
(
val
))
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment