Commit 0065e5a7 authored by caoping's avatar caoping Committed by vipwzw

raft update InitBlock

parent 8703305a
...@@ -35,7 +35,6 @@ type Client struct { ...@@ -35,7 +35,6 @@ type Client struct {
validatorC <-chan bool validatorC <-chan bool
ctx context.Context ctx context.Context
cancel context.CancelFunc cancel context.CancelFunc
once sync.Once
blockInfo *BlockInfo blockInfo *BlockInfo
mtx sync.Mutex mtx sync.Mutex
} }
...@@ -98,6 +97,7 @@ func (client *Client) recoverFromSnapshot(snapshot []byte) error { ...@@ -98,6 +97,7 @@ func (client *Client) recoverFromSnapshot(snapshot []byte) error {
func (client *Client) SetQueueClient(c queue.Client) { func (client *Client) SetQueueClient(c queue.Client) {
rlog.Info("Enter SetQueue method of raft consensus") rlog.Info("Enter SetQueue method of raft consensus")
client.InitClient(c, func() { client.InitClient(c, func() {
client.InitBlock()
}) })
go client.EventLoop() go client.EventLoop()
go client.readCommits(client.commitC, client.errorC) go client.readCommits(client.commitC, client.errorC)
...@@ -244,10 +244,6 @@ func (client *Client) pollingTask() { ...@@ -244,10 +244,6 @@ func (client *Client) pollingTask() {
case <-client.ctx.Done(): case <-client.ctx.Done():
return return
case value, ok := <-client.validatorC: case value, ok := <-client.validatorC:
//各个节点Block只初始化一次
client.once.Do(func() {
client.InitBlock()
})
if ok && !value { if ok && !value {
rlog.Debug("================I'm not the validator node=============") rlog.Debug("================I'm not the validator node=============")
leader := mux.Load().(bool) leader := mux.Load().(bool)
......
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