Commit a19fbdb0 authored by madengji's avatar madengji Committed by 33cn

genesisBlockTime

parent 6e938434
......@@ -109,6 +109,12 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
subcfg.WriteBlockSeconds = poolMainBlockSec
}
//最初平行链toml GenesisBlockTime=1514533394,但是未被使用,一直使用的内置的1514533390,最新版本开始适配cfg.GenesisBlockTime,并且
//时间也缺省改为1514533390,支持修改时间, 如果有以前的旧的配置未修改,panic强制修改
if cfg.GenesisBlockTime == 1514533394 {
panic("para chain GenesisBlockTime need be modified to 1514533390 or other")
}
emptyInterval, err := parseEmptyBlockInterval(subcfg.EmptyBlockInterval)
if err != nil {
panic("para EmptyBlockInterval config not correct")
......@@ -240,6 +246,7 @@ func (client *client) InitBlock() {
if client.cfg.GenesisBlockTime > 0 {
newblock.BlockTime = client.cfg.GenesisBlockTime
}
newblock.ParentHash = zeroHash[:]
newblock.MainHash = mainHash
......
......@@ -6,7 +6,6 @@ package para
import (
"bytes"
"fmt"
"sort"
"strings"
"sync"
......@@ -146,10 +145,13 @@ func (b *blsClient) rcvLeaderSyncTx(sync *pt.LeaderSyncInfo) error {
}
//如果leader节点冲突,取大者
if isLeader && off > sync.Offset {
return errors.Wrapf(types.ErrNotSync, "self leader off=%d bigger than sync=%d", off, sync.Offset)
return errors.Wrapf(types.ErrNotSync, "self is leader, off=%d bigger than peer sync=%d", off, sync.Offset)
}
//更新同步过来的最新offset 高度
atomic.StoreInt32(&b.leaderOffset, sync.Offset)
if off != sync.Offset {
atomic.StoreInt32(&b.leaderOffset, sync.Offset)
plog.Error("rcvLeaderSyncTx sync to peer", "offset", sync.Offset)
}
//两节点不同步则不喂狗,以防止非同步或作恶节点喂狗
atomic.StoreUint32(&b.feedDog, 1)
......@@ -548,14 +550,15 @@ func (b *blsClient) showTxBuffInfo() *pt.ParaBlsSignSumInfo {
b.mutex.Lock()
defer b.mutex.Unlock()
var ret pt.ParaBlsSignSumInfo
reply, err := b.paraClient.SendFetchP2PTopic()
if err != nil {
plog.Error("fetch p2p topic", "err", err)
}
plog.Info("fetch p2p topics", "list", fmt.Sprint(reply.Topics))
ret.Topics = append(ret.Topics, reply.Topics...)
var seq []int64
var ret pt.ParaBlsSignSumInfo
for k := range b.commitsPool {
seq = append(seq, k)
}
......
......@@ -149,6 +149,10 @@ func (client *commitMsgClient) updateChainHeightNotify(height int64, isDel bool)
client.createCommitTx()
}
func (client *commitMsgClient) setInitChainHeight(height int64) {
atomic.StoreInt64(&client.chainHeight, height)
}
// reset notify 提供重设发送参数,发送tx的入口
func (client *commitMsgClient) resetNotify() {
client.resetCh <- 1
......
......@@ -573,4 +573,14 @@ func (client *blockSyncClient) syncInit() {
if err != nil {
client.printError(err)
}
//设置初始chainHeight,及时发送共识,不然需要等到再产生一个新块才发送
lastBlock, err := client.paraClient.getLastBlockInfo()
if err != nil {
//取已执行最新区块发生错误,不做任何操作
plog.Info("Para sync init", "err", err)
} else {
client.paraClient.commitMsgClient.setInitChainHeight(lastBlock.Height)
}
}
......@@ -431,6 +431,7 @@ message ParaBlsSignSumDetailsShow {
}
message ParaBlsSignSumInfo {
repeated ParaBlsSignSumDetailsShow info = 1;
repeated string topics = 2;
}
message LeaderSyncInfo {
......
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