Update sectorbuilder

This commit is contained in:
Łukasz Magiera 2020-01-31 02:18:48 +01:00
parent 591ea245bc
commit b001a73da1
2 changed files with 10 additions and 0 deletions

View File

@ -49,6 +49,9 @@ func fillersFromRem(toFill uint64) ([]uint64, error) {
func (m *Sealing) fastPledgeCommitment(size uint64, parts uint64) (commP [sectorbuilder.CommLen]byte, err 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 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) piece := sectorbuilder.UserBytesForSectorSize((size + size / 127) / parts)
out := make([]sectorbuilder.PublicPieceInfo, parts) out := make([]sectorbuilder.PublicPieceInfo, parts)

View File

@ -52,4 +52,11 @@ func TestFastPledge(t *testing.T) {
if _, err := s.fastPledgeCommitment(sectorbuilder.UserBytesForSectorSize(sz), 5); err != nil { if _, err := s.fastPledgeCommitment(sectorbuilder.UserBytesForSectorSize(sz), 5); err != nil {
t.Fatalf("%+v", err) 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)
}
} }