Call GetHeaviestTipSet() only once when syncing
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
a5c05f87f1
commit
e68f69b63b
@ -563,15 +563,16 @@ func (syncer *Syncer) Sync(ctx context.Context, maybeHead *types.TipSet) error {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if syncer.store.GetHeaviestTipSet().ParentWeight().GreaterThan(maybeHead.ParentWeight()) {
|
hts := syncer.store.GetHeaviestTipSet()
|
||||||
|
|
||||||
|
if hts.ParentWeight().GreaterThan(maybeHead.ParentWeight()) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if syncer.Genesis.Equals(maybeHead) || hts.Equals(maybeHead) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if syncer.Genesis.Equals(maybeHead) || syncer.store.GetHeaviestTipSet().Equals(maybeHead) {
|
if err := syncer.collectChain(ctx, maybeHead, hts); err != nil {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := syncer.collectChain(ctx, maybeHead); err != nil {
|
|
||||||
span.AddAttributes(trace.StringAttribute("col_error", err.Error()))
|
span.AddAttributes(trace.StringAttribute("col_error", err.Error()))
|
||||||
span.SetStatus(trace.Status{
|
span.SetStatus(trace.Status{
|
||||||
Code: 13,
|
Code: 13,
|
||||||
@ -1684,14 +1685,14 @@ func persistMessages(ctx context.Context, bs bstore.Blockstore, bst *exchange.Co
|
|||||||
//
|
//
|
||||||
// 3. StageMessages: having acquired the headers and found a common tipset,
|
// 3. StageMessages: having acquired the headers and found a common tipset,
|
||||||
// we then move forward, requesting the full blocks, including the messages.
|
// we then move forward, requesting the full blocks, including the messages.
|
||||||
func (syncer *Syncer) collectChain(ctx context.Context, ts *types.TipSet) error {
|
func (syncer *Syncer) collectChain(ctx context.Context, ts *types.TipSet, hts *types.TipSet) error {
|
||||||
ctx, span := trace.StartSpan(ctx, "collectChain")
|
ctx, span := trace.StartSpan(ctx, "collectChain")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
ss := extractSyncState(ctx)
|
ss := extractSyncState(ctx)
|
||||||
|
|
||||||
ss.Init(syncer.store.GetHeaviestTipSet(), ts)
|
ss.Init(hts, ts)
|
||||||
|
|
||||||
headers, err := syncer.collectHeaders(ctx, ts, syncer.store.GetHeaviestTipSet())
|
headers, err := syncer.collectHeaders(ctx, ts, hts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ss.Error(err)
|
ss.Error(err)
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user