Commit 5f158371 authored by caopingcp's avatar caopingcp Committed by 33cn

raft support sync mode

parent 32c53c39
......@@ -95,13 +95,19 @@ func (client *Client) SetQueueClient(c queue.Client) {
client.InitBlock()
})
go client.EventLoop()
if !client.IsMining() {
rlog.Info("enter sync mode")
return
}
go client.readCommits(client.commitC, client.errorC)
go client.pollingTask()
}
// Close method
func (client *Client) Close() {
client.cancel()
if client.cancel != nil {
client.cancel()
}
rlog.Info("consensus raft closed")
}
......
......@@ -71,8 +71,9 @@ poolCacheSize=10240
[consensus]
# 共识驱动名,支持solo/raft/ticket/tendermint/pbft
name="raft"
minerstart=false
minerstart=true
genesis="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
genesisBlockTime=1514533394
[mver.consensus]
fundKeyAddr = "1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
......
......@@ -11,6 +11,7 @@ import (
log "github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/queue"
drivers "github.com/33cn/chain33/system/consensus"
"github.com/33cn/chain33/types"
"github.com/coreos/etcd/raft/raftpb"
)
......@@ -50,6 +51,15 @@ func init() {
// NewRaftCluster create raft cluster
func NewRaftCluster(cfg *types.Consensus, sub []byte) queue.Module {
genesis = cfg.Genesis
genesisBlockTime = cfg.GenesisBlockTime
if !cfg.Minerstart {
rlog.Info("node only sync block")
c := drivers.NewBaseClient(cfg)
client := &Client{BaseClient: c}
c.SetChild(client)
return client
}
rlog.Info("Start to create raft cluster")
var subcfg subConfig
if sub != nil {
......
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