Add flag to coalesce Tipsets in pending queue
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
2fd0d430c8
commit
16d2cb6309
@ -15,12 +15,10 @@ import (
|
|||||||
|
|
||||||
var BootstrapPeerThreshold = 1
|
var BootstrapPeerThreshold = 1
|
||||||
|
|
||||||
var coalesceForksParents = false
|
var coalesceTipsets = false
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if os.Getenv("LOTUS_SYNC_REL_PARENT") == "yes" {
|
coalesceTipsets = os.Getenv("LOTUS_SYNC_FORMTS_PEND") == "yes"
|
||||||
coalesceForksParents = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SyncFunc func(context.Context, *types.TipSet) error
|
type SyncFunc func(context.Context, *types.TipSet) error
|
||||||
@ -471,19 +469,29 @@ func (stb *syncTargetBucket) sameChainAs(ts *types.TipSet) bool {
|
|||||||
if ts.Parents() == t.Key() {
|
if ts.Parents() == t.Key() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if coalesceForksParents && ts.Parents() == t.Parents() {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stb *syncTargetBucket) add(ts *types.TipSet) {
|
func (stb *syncTargetBucket) add(ts *types.TipSet) {
|
||||||
|
for i, t := range stb.tips {
|
||||||
for _, t := range stb.tips {
|
|
||||||
if t.Equals(ts) {
|
if t.Equals(ts) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if coalesceTipsets && t.Height() == ts.Height() &&
|
||||||
|
types.CidArrsEqual(t.Blocks()[0].Parents, ts.Blocks()[0].Parents) {
|
||||||
|
|
||||||
|
newTs := append([]*types.BlockHeader{}, ts.Blocks()...)
|
||||||
|
newTs = append(newTs, t.Blocks()...)
|
||||||
|
ts2, err := types.NewTipSet(newTs)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("error while trying to recombine a tipset in a bucket: %+v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
stb.tips[i] = ts2
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stb.tips = append(stb.tips, ts)
|
stb.tips = append(stb.tips, ts)
|
||||||
|
Loading…
Reference in New Issue
Block a user