From b001a73da10fba29c82e791a66ffec2647a7c50d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 31 Jan 2020 02:18:48 +0100 Subject: [PATCH] Update sectorbuilder --- utils.go | 3 +++ utils_test.go | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/utils.go b/utils.go index 21d6b76bf..f317301ba 100644 --- a/utils.go +++ b/utils.go @@ -49,6 +49,9 @@ func fillersFromRem(toFill uint64) ([]uint64, error) { func (m *Sealing) fastPledgeCommitment(size uint64, parts uint64) (commP [sectorbuilder.CommLen]byte, err error) { parts = 1 << bits.Len64(parts) // round down to nearest power of 2 + if size / parts < 127 { + parts = size / 127 + } piece := sectorbuilder.UserBytesForSectorSize((size + size / 127) / parts) out := make([]sectorbuilder.PublicPieceInfo, parts) diff --git a/utils_test.go b/utils_test.go index 9f9ca3880..94bf858c1 100644 --- a/utils_test.go +++ b/utils_test.go @@ -52,4 +52,11 @@ func TestFastPledge(t *testing.T) { if _, err := s.fastPledgeCommitment(sectorbuilder.UserBytesForSectorSize(sz), 5); err != nil { t.Fatalf("%+v", err) } + + sz = uint64(1024) + + s = Sealing{sb: sbmock.NewMockSectorBuilder(0, sz)} + if _, err := s.fastPledgeCommitment(sectorbuilder.UserBytesForSectorSize(sz), 64); err != nil { + t.Fatalf("%+v", err) + } }