From 262d7b2372c57f0915ab3ad302b9afa6cfcd7e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 22 Apr 2020 21:16:19 +0200 Subject: [PATCH] post: Don't send empty posts --- storage/wdpost_run.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/storage/wdpost_run.go b/storage/wdpost_run.go index 151eb4155..1aa9977d6 100644 --- a/storage/wdpost_run.go +++ b/storage/wdpost_run.go @@ -3,6 +3,7 @@ package storage import ( "bytes" "context" + "errors" "time" "github.com/filecoin-project/go-address" @@ -17,6 +18,8 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) +var errNoPartitions = errors.New("no partitions") + func (s *WindowPoStScheduler) failPost(deadline *miner.DeadlineInfo) { log.Errorf("TODO") /*s.failLk.Lock() @@ -39,18 +42,20 @@ func (s *WindowPoStScheduler) doPost(ctx context.Context, deadline *miner.Deadli defer span.End() proof, err := s.runPost(ctx, *deadline, ts) - if err != nil { + switch err { + case errNoPartitions: + return + case nil: + if err := s.submitPost(ctx, proof); err != nil { + log.Errorf("submitPost failed: %+v", err) + s.failPost(deadline) + return + } + default: log.Errorf("runPost failed: %+v", err) s.failPost(deadline) return } - - if err := s.submitPost(ctx, proof); err != nil { - log.Errorf("submitPost failed: %+v", err) - s.failPost(deadline) - return - } - }() } @@ -114,7 +119,7 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di miner.DeadlineInfo log.Infof("ts: %+v (%d)", ts.Key(), ts.Height()) if partitionCount == 0 { - return nil, nil + return nil, errNoPartitions } partitions := make([]uint64, partitionCount)