Commit 79a4a1d8 authored by laser's avatar laser
Browse files

feat(plumb sector health parameter to FFI call)

parent 5a6af1f9
...@@ -386,7 +386,7 @@ func GetAllStagedSectors(sectorBuilderPtr unsafe.Pointer) ([]StagedSectorMetadat ...@@ -386,7 +386,7 @@ func GetAllStagedSectors(sectorBuilderPtr unsafe.Pointer) ([]StagedSectorMetadat
func GetAllSealedSectors(sectorBuilderPtr unsafe.Pointer, performHealthchecks bool) ([]SealedSectorMetadata, error) { func GetAllSealedSectors(sectorBuilderPtr unsafe.Pointer, performHealthchecks bool) ([]SealedSectorMetadata, error) {
defer elapsed("GetAllSealedSectors")() defer elapsed("GetAllSealedSectors")()
resPtr := C.sector_builder_ffi_get_sealed_sectors((*C.sector_builder_ffi_SectorBuilder)(sectorBuilderPtr), performHealthchecks) resPtr := C.sector_builder_ffi_get_sealed_sectors((*C.sector_builder_ffi_SectorBuilder)(sectorBuilderPtr), true == performHealthchecks)
defer C.sector_builder_ffi_destroy_get_sealed_sectors_response(resPtr) defer C.sector_builder_ffi_destroy_get_sealed_sectors_response(resPtr)
if resPtr.status_code != 0 { if resPtr.status_code != 0 {
......
...@@ -87,12 +87,13 @@ func TestSectorBuilderLifecycle(t *testing.T) { ...@@ -87,12 +87,13 @@ func TestSectorBuilderLifecycle(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.True(t, isValid) require.True(t, isValid)
sealedSectors, err := sb.GetAllSealedSectors(ptr) sealedSectors, err := sb.GetAllSealedSectors(ptr, true)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, 1, len(sealedSectors), "expected to see one sealed sector") require.Equal(t, 1, len(sealedSectors), "expected to see one sealed sector")
sealedSector := sealedSectors[0] sealedSector := sealedSectors[0]
require.Equal(t, uint64(1), sealedSector.SectorID) require.Equal(t, uint64(1), sealedSector.SectorID)
require.Equal(t, 1, len(sealedSector.Pieces)) require.Equal(t, 1, len(sealedSector.Pieces))
require.Equal(t, sb.Ok, sealedSector.Health)
// the piece is the size of the sector, so its piece commitment should be the // the piece is the size of the sector, so its piece commitment should be the
// data commitment // data commitment
require.Equal(t, commP, sealedSector.CommD) require.Equal(t, commP, sealedSector.CommD)
......
...@@ -129,15 +129,15 @@ func goPieceMetadata(src *C.sector_builder_ffi_FFIPieceMetadata, size C.size_t) ...@@ -129,15 +129,15 @@ func goPieceMetadata(src *C.sector_builder_ffi_FFIPieceMetadata, size C.size_t)
func goSealedSectorHealth(health C.sector_builder_ffi_FFISealedSectorHealth) (SealedSectorHealth, error) { func goSealedSectorHealth(health C.sector_builder_ffi_FFISealedSectorHealth) (SealedSectorHealth, error) {
switch health { switch health {
case C.sector_builder_ffi_FFISealedSectorHealth_Unknown: case C.Unknown:
return Unknown, nil return Unknown, nil
case C.sector_builder_ffi_FFISealedSectorHealth_Ok: case C.Ok:
return Ok, nil return Ok, nil
case C.sector_builder_ffi_FFISealedSectorHealth_ErrorInvalidChecksum: case C.ErrorInvalidChecksum:
return ErrorInvalidChecksum, nil return ErrorInvalidChecksum, nil
case C.sector_builder_ffi_FFISealedSectorHealth_ErrorInvalidLength: case C.ErrorInvalidLength:
return ErrorInvalidLength, nil return ErrorInvalidLength, nil
case C.sector_builder_ffi_FFISealedSectorHealth_ErrorMissing: case C.ErrorMissing:
return ErrorMissing, nil return ErrorMissing, nil
default: default:
return Unknown, errors.Errorf("unhandled sealed sector health: %v", health) return Unknown, errors.Errorf("unhandled sealed sector health: %v", health)
......
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