Commit 96c260d5 authored by laser's avatar laser
Browse files

feat(cachedir): sector builder instantiated with sector cache root-dir

Interactive PoRep will split the existing seal operation into a
two-step flow. In the first step, the pre-commit operation will persist
some artifacts to a per-sector directory (a subdirectory of the
sector cache root-dir) for the commit operation to load.
parent daa388b4
......@@ -248,12 +248,12 @@ func GetMaxUserBytesPerStagedSector(sectorSize uint64) uint64 {
func InitSectorBuilder(
sectorSize uint64,
poRepProofPartitions uint8,
poStProofPartitions uint8,
lastUsedSectorID uint64,
metadataDir string,
proverID [32]byte,
sealedSectorDir string,
stagedSectorDir string,
sectorCacheRootDir string,
maxNumOpenStagedSectors uint8,
) (unsafe.Pointer, error) {
defer elapsed("InitSectorBuilder")()
......@@ -270,6 +270,9 @@ func InitSectorBuilder(
cSealedSectorDir := C.CString(sealedSectorDir)
defer C.free(unsafe.Pointer(cSealedSectorDir))
cSectorCacheRootDir := C.CString(sectorCacheRootDir)
defer C.free(unsafe.Pointer(cSectorCacheRootDir))
class, err := cSectorClass(sectorSize, poRepProofPartitions)
if err != nil {
return nil, errors.Wrap(err, "failed to get sector class")
......@@ -282,6 +285,7 @@ func InitSectorBuilder(
(*[32]C.uint8_t)(proverIDCBytes),
cSealedSectorDir,
cStagedSectorDir,
cSectorCacheRootDir,
C.uint8_t(maxNumOpenStagedSectors),
)
defer C.sector_builder_ffi_destroy_init_sector_builder_response(resPtr)
......
......@@ -41,7 +41,10 @@ func TestSectorBuilderLifecycle(t *testing.T) {
stagedSectorDir := requireTempDirPath(t)
defer require.NoError(t, os.Remove(stagedSectorDir))
ptr, err := sb.InitSectorBuilder(1024, 2, 1, 0, metadataDir, proverID, sealedSectorDir, stagedSectorDir, 1)
sectorCacheRootDir := requireTempDirPath(t)
defer require.NoError(t, os.Remove(sectorCacheRootDir))
ptr, err := sb.InitSectorBuilder(1024, 2, 0, metadataDir, proverID, sealedSectorDir, stagedSectorDir, sectorCacheRootDir, 1)
require.NoError(t, err)
defer sb.DestroySectorBuilder(ptr)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment