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