Commit c44d3754 authored by Litian's avatar Litian Committed by 33cn

只在自动挖矿的地方控制ticket共识挖矿

parent 277ec707
......@@ -7,7 +7,6 @@ package wallet
import (
"encoding/hex"
"fmt"
"strings"
"sync"
"sync/atomic"
"time"
......@@ -21,6 +20,7 @@ import (
"github.com/33cn/chain33/types"
wcom "github.com/33cn/chain33/wallet/common"
ty "github.com/33cn/plugin/plugin/dapp/ticket/types"
"strings"
)
var (
......@@ -29,14 +29,7 @@ var (
)
func init() {
// 只有ticket共识下ticket相关的操作才有效
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())
}
}
wcom.RegisterPolicy(ty.TicketX, New())
}
// New new instance
......@@ -777,6 +770,17 @@ func (policy *ticketPolicy) autoMining() {
defer bizlog.Info("End auto mining")
operater := policy.getWalletOperate()
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)
miningTicketTicker := policy.getMingTicketTicker()
for {
......
......@@ -7,14 +7,14 @@ package wallet_test
import (
"testing"
_ "github.com/33cn/chain33/system"
"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"
ticketwallet "github.com/33cn/plugin/plugin/dapp/ticket/wallet"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
_ "github.com/33cn/chain33/system"
_ "github.com/33cn/plugin/plugin"
)
func Test_WalletTicket(t *testing.T) {
......@@ -22,7 +22,6 @@ func Test_WalletTicket(t *testing.T) {
cfg, sub := testnode.GetDefaultConfig()
cfg.Consensus.Name = "ticket"
wcom.RegisterPolicy(ty.TicketX, ticketwallet.New())
mock33 := testnode.NewWithConfig(cfg, sub, nil)
defer mock33.Close()
err := mock33.WaitHeight(0)
......
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