don't defer in a loop

This commit is contained in:
Łukasz Magiera 2022-01-20 11:19:57 +01:00
parent fa09b9afb1
commit b115e2879a
2 changed files with 11 additions and 8 deletions

View File

@ -6,15 +6,16 @@ import (
"testing"
"time"
logging "github.com/ipfs/go-log/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/itests/kit"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCCUpgrade(t *testing.T) {
@ -124,6 +125,7 @@ func waitForSectorStartUpgrade(ctx context.Context, t *testing.T, sn abi.SectorN
func TestCCUpgradeAndPoSt(t *testing.T) {
kit.QuietMiningLogs()
_ = logging.SetLogLevel("storageminer", "INFO")
t.Run("upgrade and then post", func(t *testing.T) {
ctx := context.Background()
n := runTestCCUpgrade(t, 100)

View File

@ -561,6 +561,12 @@ func (s *WindowPoStScheduler) runPoStCycle(ctx context.Context, di dline.Info, t
return nil, err
}
defer func() {
if r := recover(); r != nil {
log.Errorf("recover: %s", r)
}
}()
// Generate proofs in batches
posts := make([]miner.SubmitWindowedPoStParams, 0, len(partitionBatches))
for batchIdx, batch := range partitionBatches {
@ -651,11 +657,6 @@ func (s *WindowPoStScheduler) runPoStCycle(ctx context.Context, di dline.Info, t
return nil, err
}
defer func() {
if r := recover(); r != nil {
log.Errorf("recover: %s", r)
}
}()
postOut, ps, err := s.prover.GenerateWindowPoSt(ctx, abi.ActorID(mid), xsinfos, append(abi.PoStRandomness{}, rand...))
elapsed := time.Since(tsStart)
log.Infow("computing window post", "batch", batchIdx, "elapsed", elapsed)