Merge pull request #777 from filecoin-project/feat/better-sync-manager-relating

Better track related incoming sync targets
This commit is contained in:
Whyrusleeping 2019-12-07 23:08:42 +01:00 committed by GitHub
commit 99c4691720
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,6 +108,15 @@ func newSyncTargetBucket(tipsets ...*types.TipSet) *syncTargetBucket {
return &stb
}
func (sbs *syncBucketSet) RelatedToAny(ts *types.TipSet) bool {
for _, b := range sbs.buckets {
if b.sameChainAs(ts) {
return true
}
}
return false
}
func (sbs *syncBucketSet) Insert(ts *types.TipSet) {
for _, b := range sbs.buckets {
if b.sameChainAs(ts) {
@ -182,6 +191,9 @@ func (stb *syncTargetBucket) sameChainAs(ts *types.TipSet) bool {
if types.CidArrsEqual(ts.Parents(), t.Cids()) {
return true
}
if types.CidArrsEqual(ts.Parents(), t.Parents()) {
return true
}
}
return false
}
@ -265,12 +277,16 @@ func (sm *SyncManager) scheduleIncoming(ts *types.TipSet) {
break
}
if types.CidArrsEqual(ts.Parents(), acts.Cids()) {
if types.CidArrsEqual(ts.Parents(), acts.Cids()) || types.CidArrsEqual(ts.Parents(), acts.Parents()) {
// sync this next, after that sync process finishes
relatedToActiveSync = true
}
}
if !relatedToActiveSync && sm.activeSyncTips.RelatedToAny(ts) {
relatedToActiveSync = true
}
// if this is related to an active sync process, immediately bucket it
// we don't want to start a parallel sync process that duplicates work
if relatedToActiveSync {