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
c44d3754
Commit
c44d3754
authored
Dec 10, 2018
by
Litian
Committed by
33cn
Dec 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
只在自动挖矿的地方控制ticket共识挖矿
parent
277ec707
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
13 deletions
+16
-13
ticket.go
plugin/dapp/ticket/wallet/ticket.go
+13
-9
ticket_test.go
plugin/dapp/ticket/wallet/ticket_test.go
+3
-4
No files found.
plugin/dapp/ticket/wallet/ticket.go
View file @
c44d3754
...
@@ -7,7 +7,6 @@ package wallet
...
@@ -7,7 +7,6 @@ package wallet
import
(
import
(
"encoding/hex"
"encoding/hex"
"fmt"
"fmt"
"strings"
"sync"
"sync"
"sync/atomic"
"sync/atomic"
"time"
"time"
...
@@ -21,6 +20,7 @@ import (
...
@@ -21,6 +20,7 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
wcom
"github.com/33cn/chain33/wallet/common"
wcom
"github.com/33cn/chain33/wallet/common"
ty
"github.com/33cn/plugin/plugin/dapp/ticket/types"
ty
"github.com/33cn/plugin/plugin/dapp/ticket/types"
"strings"
)
)
var
(
var
(
...
@@ -29,14 +29,7 @@ var (
...
@@ -29,14 +29,7 @@ var (
)
)
func
init
()
{
func
init
()
{
// 只有ticket共识下ticket相关的操作才有效
wcom
.
RegisterPolicy
(
ty
.
TicketX
,
New
())
q
:=
types
.
Conf
(
"config.consensus"
)
if
q
!=
nil
{
cons
:=
q
.
GStr
(
"name"
)
if
strings
.
Compare
(
strings
.
TrimSpace
(
cons
),
ty
.
TicketX
)
==
0
{
wcom
.
RegisterPolicy
(
ty
.
TicketX
,
New
())
}
}
}
}
// New new instance
// New new instance
...
@@ -777,6 +770,17 @@ func (policy *ticketPolicy) autoMining() {
...
@@ -777,6 +770,17 @@ func (policy *ticketPolicy) autoMining() {
defer
bizlog
.
Info
(
"End auto mining"
)
defer
bizlog
.
Info
(
"End auto mining"
)
operater
:=
policy
.
getWalletOperate
()
operater
:=
policy
.
getWalletOperate
()
defer
operater
.
GetWaitGroup
()
.
Done
()
defer
operater
.
GetWaitGroup
()
.
Done
()
// 只有ticket共识下ticket相关的操作才有效
q
:=
types
.
Conf
(
"config.consensus"
)
if
q
!=
nil
{
cons
:=
q
.
GStr
(
"name"
)
if
strings
.
Compare
(
strings
.
TrimSpace
(
cons
),
ty
.
TicketX
)
!=
0
{
bizlog
.
Info
(
"consensus is not ticket, exit mining"
)
return
}
}
lastHeight
:=
int64
(
0
)
lastHeight
:=
int64
(
0
)
miningTicketTicker
:=
policy
.
getMingTicketTicker
()
miningTicketTicker
:=
policy
.
getMingTicketTicker
()
for
{
for
{
...
...
plugin/dapp/ticket/wallet/ticket_test.go
View file @
c44d3754
...
@@ -7,14 +7,14 @@ package wallet_test
...
@@ -7,14 +7,14 @@ package wallet_test
import
(
import
(
"testing"
"testing"
_
"github.com/33cn/chain33/system"
"github.com/33cn/chain33/util/testnode"
"github.com/33cn/chain33/util/testnode"
wcom
"github.com/33cn/chain33/wallet/common"
_
"github.com/33cn/plugin/plugin"
ty
"github.com/33cn/plugin/plugin/dapp/ticket/types"
ty
"github.com/33cn/plugin/plugin/dapp/ticket/types"
ticketwallet
"github.com/33cn/plugin/plugin/dapp/ticket/wallet"
ticketwallet
"github.com/33cn/plugin/plugin/dapp/ticket/wallet"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/plugin/plugin"
)
)
func
Test_WalletTicket
(
t
*
testing
.
T
)
{
func
Test_WalletTicket
(
t
*
testing
.
T
)
{
...
@@ -22,7 +22,6 @@ func Test_WalletTicket(t *testing.T) {
...
@@ -22,7 +22,6 @@ func Test_WalletTicket(t *testing.T) {
cfg
,
sub
:=
testnode
.
GetDefaultConfig
()
cfg
,
sub
:=
testnode
.
GetDefaultConfig
()
cfg
.
Consensus
.
Name
=
"ticket"
cfg
.
Consensus
.
Name
=
"ticket"
wcom
.
RegisterPolicy
(
ty
.
TicketX
,
ticketwallet
.
New
())
mock33
:=
testnode
.
NewWithConfig
(
cfg
,
sub
,
nil
)
mock33
:=
testnode
.
NewWithConfig
(
cfg
,
sub
,
nil
)
defer
mock33
.
Close
()
defer
mock33
.
Close
()
err
:=
mock33
.
WaitHeight
(
0
)
err
:=
mock33
.
WaitHeight
(
0
)
...
...
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