Commit 34a9a7f9 authored by yukang's avatar yukang Committed by vipwzw

Optimize some code for review

parent 408ddd34
...@@ -187,6 +187,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module { ...@@ -187,6 +187,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
} }
para.blockSyncClient = &BlockSyncClient{ para.blockSyncClient = &BlockSyncClient{
paraClient: para,
notifyChan: make(chan bool), notifyChan: make(chan bool),
quitChan: make(chan struct{}), quitChan: make(chan struct{}),
maxCacheCount: 1000, maxCacheCount: 1000,
...@@ -228,7 +229,8 @@ func (client *client) SetQueueClient(c queue.Client) { ...@@ -228,7 +229,8 @@ func (client *client) SetQueueClient(c queue.Client) {
go client.commitMsgClient.handler() go client.commitMsgClient.handler()
client.wg.Add(1) client.wg.Add(1)
go client.CreateBlock() go client.CreateBlock()
go client.SyncBlocks() client.wg.Add(1)
go client.blockSyncClient.SyncBlocks()
} }
func (client *client) InitBlock() { func (client *client) InitBlock() {
...@@ -257,7 +259,7 @@ func (client *client) InitBlock() { ...@@ -257,7 +259,7 @@ func (client *client) InitBlock() {
tx := client.CreateGenesisTx() tx := client.CreateGenesisTx()
newblock.Txs = tx newblock.Txs = tx
newblock.TxHash = merkle.CalcMerkleRoot(newblock.Txs) newblock.TxHash = merkle.CalcMerkleRoot(newblock.Txs)
err := client.CreateGenesisBlock(newblock) err := client.blockSyncClient.CreateGenesisBlock(newblock)
if err != nil { if err != nil {
panic(fmt.Sprintf("para chain create genesis block,err=%s", err.Error())) panic(fmt.Sprintf("para chain create genesis block,err=%s", err.Error()))
} }
......
...@@ -170,8 +170,8 @@ func (client *commitMsgClient) isSync() bool { ...@@ -170,8 +170,8 @@ func (client *commitMsgClient) isSync() bool {
return false return false
} }
if !client.paraClient.SyncHasCaughtUp() { if !client.paraClient.blockSyncClient.SyncHasCaughtUp() {
plog.Info("para is not Sync", "syncCaughtUp", client.paraClient.SyncHasCaughtUp()) plog.Info("para is not Sync", "syncCaughtUp", client.paraClient.blockSyncClient.SyncHasCaughtUp())
return false return false
} }
......
This diff is collapsed.
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