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
3c6b1738
Commit
3c6b1738
authored
Nov 20, 2018
by
jiangpeng
Committed by
vipwzw
Nov 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix go vet
parent
523fd73b
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
22 additions
and
20 deletions
+22
-20
query.go
plugin/dapp/ticket/executor/query.go
+1
-1
ticket.go
plugin/dapp/ticket/executor/ticket.go
+3
-3
ticketdb.go
plugin/dapp/ticket/executor/ticketdb.go
+8
-8
types.go
plugin/dapp/ticket/rpc/types.go
+1
-0
errors.go
plugin/dapp/ticket/types/errors.go
+0
-0
ticket.go
plugin/dapp/ticket/types/ticket.go
+1
-0
exec.go
plugin/dapp/ticket/wallet/exec.go
+1
-1
ticket.go
plugin/dapp/ticket/wallet/ticket.go
+5
-5
ticket_test.go
plugin/dapp/ticket/wallet/ticket_test.go
+2
-2
No files found.
plugin/dapp/ticket/executor/query.go
View file @
3c6b1738
...
@@ -25,7 +25,7 @@ func (ticket *Ticket) Query_MinerAddress(param *types.ReqString) (types.Message,
...
@@ -25,7 +25,7 @@ func (ticket *Ticket) Query_MinerAddress(param *types.ReqString) (types.Message,
if
value
==
nil
||
err
!=
nil
{
if
value
==
nil
||
err
!=
nil
{
return
nil
,
types
.
ErrNotFound
return
nil
,
types
.
ErrNotFound
}
}
return
&
types
.
ReplyString
{
string
(
value
)},
nil
return
&
types
.
ReplyString
{
Data
:
string
(
value
)},
nil
}
}
// Query_MinerSourceList query miner src list
// Query_MinerSourceList query miner src list
...
...
plugin/dapp/ticket/executor/ticket.go
View file @
3c6b1738
...
@@ -71,7 +71,7 @@ func (t *Ticket) saveTicketBind(b *ty.ReceiptTicketBind) (kvs []*types.KeyValue)
...
@@ -71,7 +71,7 @@ func (t *Ticket) saveTicketBind(b *ty.ReceiptTicketBind) (kvs []*types.KeyValue)
kvs
=
append
(
kvs
,
kv
)
kvs
=
append
(
kvs
,
kv
)
}
}
kv
:=
&
types
.
KeyValue
{
calcBindReturnKey
(
b
.
ReturnAddress
),
[]
byte
(
b
.
NewMinerAddress
)}
kv
:=
&
types
.
KeyValue
{
Key
:
calcBindReturnKey
(
b
.
ReturnAddress
),
Value
:
[]
byte
(
b
.
NewMinerAddress
)}
//tlog.Warn("tb:add", "key", string(kv.Key), "value", string(kv.Value))
//tlog.Warn("tb:add", "key", string(kv.Key), "value", string(kv.Value))
kvs
=
append
(
kvs
,
kv
)
kvs
=
append
(
kvs
,
kv
)
kv
=
&
types
.
KeyValue
{
kv
=
&
types
.
KeyValue
{
...
@@ -92,7 +92,7 @@ func (t *Ticket) delTicketBind(b *ty.ReceiptTicketBind) (kvs []*types.KeyValue)
...
@@ -92,7 +92,7 @@ func (t *Ticket) delTicketBind(b *ty.ReceiptTicketBind) (kvs []*types.KeyValue)
kvs
=
append
(
kvs
,
kv
)
kvs
=
append
(
kvs
,
kv
)
if
len
(
b
.
OldMinerAddress
)
>
0
{
if
len
(
b
.
OldMinerAddress
)
>
0
{
//恢复旧的绑定
//恢复旧的绑定
kv
:=
&
types
.
KeyValue
{
calcBindReturnKey
(
b
.
ReturnAddress
),
[]
byte
(
b
.
OldMinerAddress
)}
kv
:=
&
types
.
KeyValue
{
Key
:
calcBindReturnKey
(
b
.
ReturnAddress
),
Value
:
[]
byte
(
b
.
OldMinerAddress
)}
kvs
=
append
(
kvs
,
kv
)
kvs
=
append
(
kvs
,
kv
)
kv
=
&
types
.
KeyValue
{
kv
=
&
types
.
KeyValue
{
Key
:
calcBindMinerKey
(
b
.
OldMinerAddress
,
b
.
ReturnAddress
),
Key
:
calcBindMinerKey
(
b
.
OldMinerAddress
,
b
.
ReturnAddress
),
...
@@ -101,7 +101,7 @@ func (t *Ticket) delTicketBind(b *ty.ReceiptTicketBind) (kvs []*types.KeyValue)
...
@@ -101,7 +101,7 @@ func (t *Ticket) delTicketBind(b *ty.ReceiptTicketBind) (kvs []*types.KeyValue)
kvs
=
append
(
kvs
,
kv
)
kvs
=
append
(
kvs
,
kv
)
}
else
{
}
else
{
//删除旧的数据
//删除旧的数据
kv
:=
&
types
.
KeyValue
{
calcBindReturnKey
(
b
.
ReturnAddress
),
nil
}
kv
:=
&
types
.
KeyValue
{
Key
:
calcBindReturnKey
(
b
.
ReturnAddress
),
Value
:
nil
}
kvs
=
append
(
kvs
,
kv
)
kvs
=
append
(
kvs
,
kv
)
}
}
return
kvs
return
kvs
...
...
plugin/dapp/ticket/executor/ticketdb.go
View file @
3c6b1738
...
@@ -77,7 +77,7 @@ func (t *DB) GetReceiptLog() *types.ReceiptLog {
...
@@ -77,7 +77,7 @@ func (t *DB) GetReceiptLog() *types.ReceiptLog {
// GetKVSet get kv set
// GetKVSet get kv set
func
(
t
*
DB
)
GetKVSet
()
(
kvset
[]
*
types
.
KeyValue
)
{
func
(
t
*
DB
)
GetKVSet
()
(
kvset
[]
*
types
.
KeyValue
)
{
value
:=
types
.
Encode
(
&
t
.
Ticket
)
value
:=
types
.
Encode
(
&
t
.
Ticket
)
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
(
t
.
TicketId
),
value
})
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
Key
(
t
.
TicketId
),
Value
:
value
})
return
kvset
return
kvset
}
}
...
@@ -144,7 +144,7 @@ func (action *Action) GenesisInit(genesis *ty.TicketGenesis) (*types.Receipt, er
...
@@ -144,7 +144,7 @@ func (action *Action) GenesisInit(genesis *ty.TicketGenesis) (*types.Receipt, er
logs
=
append
(
logs
,
receipt
.
Logs
...
)
logs
=
append
(
logs
,
receipt
.
Logs
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
}
}
receipt
:=
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -157,7 +157,7 @@ func saveBind(db dbm.KV, tbind *ty.TicketBind) {
...
@@ -157,7 +157,7 @@ func saveBind(db dbm.KV, tbind *ty.TicketBind) {
func
getBindKV
(
tbind
*
ty
.
TicketBind
)
(
kvset
[]
*
types
.
KeyValue
)
{
func
getBindKV
(
tbind
*
ty
.
TicketBind
)
(
kvset
[]
*
types
.
KeyValue
)
{
value
:=
types
.
Encode
(
tbind
)
value
:=
types
.
Encode
(
tbind
)
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
BindKey
(
tbind
.
ReturnAddress
),
value
})
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
BindKey
(
tbind
.
ReturnAddress
),
Value
:
value
})
return
kvset
return
kvset
}
}
...
@@ -205,7 +205,7 @@ func (action *Action) TicketBind(tbind *ty.TicketBind) (*types.Receipt, error) {
...
@@ -205,7 +205,7 @@ func (action *Action) TicketBind(tbind *ty.TicketBind) (*types.Receipt, error) {
saveBind
(
action
.
db
,
tbind
)
saveBind
(
action
.
db
,
tbind
)
kv
:=
getBindKV
(
tbind
)
kv
:=
getBindKV
(
tbind
)
kvs
=
append
(
kvs
,
kv
...
)
kvs
=
append
(
kvs
,
kv
...
)
receipt
:=
&
types
.
Receipt
{
types
.
ExecOk
,
kvs
,
logs
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kvs
,
Logs
:
logs
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -251,7 +251,7 @@ func (action *Action) TicketOpen(topen *ty.TicketOpen) (*types.Receipt, error) {
...
@@ -251,7 +251,7 @@ func (action *Action) TicketOpen(topen *ty.TicketOpen) (*types.Receipt, error) {
logs
=
append
(
logs
,
receipt
.
Logs
...
)
logs
=
append
(
logs
,
receipt
.
Logs
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
}
}
receipt
:=
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -339,7 +339,7 @@ func (action *Action) TicketMiner(miner *ty.TicketMiner, index int) (*types.Rece
...
@@ -339,7 +339,7 @@ func (action *Action) TicketMiner(miner *ty.TicketMiner, index int) (*types.Rece
kv
=
append
(
kv
,
receipt1
.
KV
...
)
kv
=
append
(
kv
,
receipt1
.
KV
...
)
logs
=
append
(
logs
,
receipt2
.
Logs
...
)
logs
=
append
(
logs
,
receipt2
.
Logs
...
)
kv
=
append
(
kv
,
receipt2
.
KV
...
)
kv
=
append
(
kv
,
receipt2
.
KV
...
)
return
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
// TicketClose close tick
// TicketClose close tick
...
@@ -406,7 +406,7 @@ func (action *Action) TicketClose(tclose *ty.TicketClose) (*types.Receipt, error
...
@@ -406,7 +406,7 @@ func (action *Action) TicketClose(tclose *ty.TicketClose) (*types.Receipt, error
}
}
t
.
Save
(
action
.
db
)
t
.
Save
(
action
.
db
)
}
}
receipt
:=
&
types
.
Receipt
{
types
.
ExecOk
,
kv
,
logs
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -438,5 +438,5 @@ func Infos(db dbm.KV, tinfos *ty.TicketInfos) (types.Message, error) {
...
@@ -438,5 +438,5 @@ func Infos(db dbm.KV, tinfos *ty.TicketInfos) (types.Message, error) {
}
}
tickets
=
append
(
tickets
,
ticket
)
tickets
=
append
(
tickets
,
ticket
)
}
}
return
&
ty
.
ReplyTicketList
{
tickets
},
nil
return
&
ty
.
ReplyTicketList
{
Tickets
:
tickets
},
nil
}
}
plugin/dapp/ticket/rpc/types.go
View file @
3c6b1738
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
type
Jrpc
struct
{
type
Jrpc
struct
{
cli
*
channelClient
cli
*
channelClient
}
}
// Grpc grpc type
// Grpc grpc type
type
Grpc
struct
{
type
Grpc
struct
{
*
channelClient
*
channelClient
...
...
plugin/dapp/ticket/types/errors.go
View file @
3c6b1738
plugin/dapp/ticket/types/ticket.go
View file @
3c6b1738
...
@@ -46,6 +46,7 @@ const (
...
@@ -46,6 +46,7 @@ const (
// TicketOldParts old tick type
// TicketOldParts old tick type
const
TicketOldParts
=
3
const
TicketOldParts
=
3
// TicketCountOpenOnce count open once
// TicketCountOpenOnce count open once
const
TicketCountOpenOnce
=
1000
const
TicketCountOpenOnce
=
1000
...
...
plugin/dapp/ticket/wallet/exec.go
View file @
3c6b1738
...
@@ -29,7 +29,7 @@ func (policy *ticketPolicy) On_CloseTickets(req *types.ReqNil) (types.Message, e
...
@@ -29,7 +29,7 @@ func (policy *ticketPolicy) On_CloseTickets(req *types.ReqNil) (types.Message, e
// On_WalletGetTickets get ticket
// On_WalletGetTickets get ticket
func
(
policy
*
ticketPolicy
)
On_WalletGetTickets
(
req
*
types
.
ReqNil
)
(
types
.
Message
,
error
)
{
func
(
policy
*
ticketPolicy
)
On_WalletGetTickets
(
req
*
types
.
ReqNil
)
(
types
.
Message
,
error
)
{
tickets
,
privs
,
err
:=
policy
.
getTicketsByStatus
(
1
)
tickets
,
privs
,
err
:=
policy
.
getTicketsByStatus
(
1
)
tks
:=
&
ty
.
ReplyWalletTickets
{
tickets
,
privs
}
tks
:=
&
ty
.
ReplyWalletTickets
{
Tickets
:
tickets
,
Privkeys
:
privs
}
return
tks
,
err
return
tks
,
err
}
}
...
...
plugin/dapp/ticket/wallet/ticket.go
View file @
3c6b1738
...
@@ -312,7 +312,7 @@ func (policy *ticketPolicy) forceCloseAllTicket(height int64) (*types.ReplyHashe
...
@@ -312,7 +312,7 @@ func (policy *ticketPolicy) forceCloseAllTicket(height int64) (*types.ReplyHashe
}
}
func
(
policy
*
ticketPolicy
)
getTickets
(
addr
string
,
status
int32
)
([]
*
ty
.
Ticket
,
error
)
{
func
(
policy
*
ticketPolicy
)
getTickets
(
addr
string
,
status
int32
)
([]
*
ty
.
Ticket
,
error
)
{
reqaddr
:=
&
ty
.
TicketList
{
addr
,
status
}
reqaddr
:=
&
ty
.
TicketList
{
Addr
:
addr
,
Status
:
status
}
api
:=
policy
.
getAPI
()
api
:=
policy
.
getAPI
()
msg
,
err
:=
api
.
Query
(
ty
.
TicketX
,
"TicketList"
,
reqaddr
)
msg
,
err
:=
api
.
Query
(
ty
.
TicketX
,
"TicketList"
,
reqaddr
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -369,8 +369,8 @@ func (policy *ticketPolicy) closeTickets(priv crypto.PrivKey, ids []string) ([]b
...
@@ -369,8 +369,8 @@ func (policy *ticketPolicy) closeTickets(priv crypto.PrivKey, ids []string) ([]b
}
}
bizlog
.
Info
(
"closeTickets"
,
"ids"
,
ids
[
0
:
end
])
bizlog
.
Info
(
"closeTickets"
,
"ids"
,
ids
[
0
:
end
])
ta
:=
&
ty
.
TicketAction
{}
ta
:=
&
ty
.
TicketAction
{}
tclose
:=
&
ty
.
TicketClose
{
ids
[
0
:
end
]}
tclose
:=
&
ty
.
TicketClose
{
TicketId
:
ids
[
0
:
end
]}
ta
.
Value
=
&
ty
.
TicketAction_Tclose
{
tclose
}
ta
.
Value
=
&
ty
.
TicketAction_Tclose
{
Tclose
:
tclose
}
ta
.
Ty
=
ty
.
TicketActionClose
ta
.
Ty
=
ty
.
TicketActionClose
return
policy
.
getWalletOperate
()
.
SendTransaction
(
ta
,
[]
byte
(
ty
.
TicketX
),
priv
,
""
)
return
policy
.
getWalletOperate
()
.
SendTransaction
(
ta
,
[]
byte
(
ty
.
TicketX
),
priv
,
""
)
}
}
...
@@ -551,7 +551,7 @@ func (policy *ticketPolicy) openticket(mineraddr, returnaddr string, priv crypto
...
@@ -551,7 +551,7 @@ func (policy *ticketPolicy) openticket(mineraddr, returnaddr string, priv crypto
hashList
[
i
]
=
pubHash
hashList
[
i
]
=
pubHash
}
}
topen
.
PubHashes
=
hashList
topen
.
PubHashes
=
hashList
ta
.
Value
=
&
ty
.
TicketAction_Topen
{
topen
}
ta
.
Value
=
&
ty
.
TicketAction_Topen
{
Topen
:
topen
}
ta
.
Ty
=
ty
.
TicketActionOpen
ta
.
Ty
=
ty
.
TicketActionOpen
return
policy
.
walletOperate
.
SendTransaction
(
ta
,
[]
byte
(
ty
.
TicketX
),
priv
,
""
)
return
policy
.
walletOperate
.
SendTransaction
(
ta
,
[]
byte
(
ty
.
TicketX
),
priv
,
""
)
}
}
...
@@ -626,7 +626,7 @@ func (policy *ticketPolicy) buyTicket(height int64) ([][]byte, int, error) {
...
@@ -626,7 +626,7 @@ func (policy *ticketPolicy) buyTicket(height int64) ([][]byte, int, error) {
}
}
func
(
policy
*
ticketPolicy
)
getMinerColdAddr
(
addr
string
)
([]
string
,
error
)
{
func
(
policy
*
ticketPolicy
)
getMinerColdAddr
(
addr
string
)
([]
string
,
error
)
{
reqaddr
:=
&
types
.
ReqString
{
addr
}
reqaddr
:=
&
types
.
ReqString
{
Data
:
addr
}
api
:=
policy
.
walletOperate
.
GetAPI
()
api
:=
policy
.
walletOperate
.
GetAPI
()
msg
,
err
:=
api
.
Query
(
ty
.
TicketX
,
"MinerSourceList"
,
reqaddr
)
msg
,
err
:=
api
.
Query
(
ty
.
TicketX
,
"MinerSourceList"
,
reqaddr
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/ticket/wallet/ticket_test.go
View file @
3c6b1738
...
@@ -26,11 +26,11 @@ func Test_WalletTicket(t *testing.T) {
...
@@ -26,11 +26,11 @@ func Test_WalletTicket(t *testing.T) {
defer
mock33
.
Close
()
defer
mock33
.
Close
()
err
:=
mock33
.
WaitHeight
(
0
)
err
:=
mock33
.
WaitHeight
(
0
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
msg
,
err
:=
mock33
.
GetAPI
()
.
Query
(
ty
.
TicketX
,
"TicketList"
,
&
ty
.
TicketList
{
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
,
1
})
msg
,
err
:=
mock33
.
GetAPI
()
.
Query
(
ty
.
TicketX
,
"TicketList"
,
&
ty
.
TicketList
{
Addr
:
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
,
Status
:
1
})
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
ticketList
:=
msg
.
(
*
ty
.
ReplyTicketList
)
ticketList
:=
msg
.
(
*
ty
.
ReplyTicketList
)
assert
.
NotNil
(
t
,
ticketList
)
assert
.
NotNil
(
t
,
ticketList
)
return
//
return
ticketwallet
.
FlushTicket
(
mock33
.
GetAPI
())
ticketwallet
.
FlushTicket
(
mock33
.
GetAPI
())
err
=
mock33
.
WaitHeight
(
2
)
err
=
mock33
.
WaitHeight
(
2
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
...
...
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