Commit 8417fb51 authored by laser's avatar laser
Browse files

feat(plumb healthcheck bool through FFI)

parent fa239db1
...@@ -24,6 +24,16 @@ func elapsed(what string) func() { ...@@ -24,6 +24,16 @@ func elapsed(what string) func() {
} }
} }
type SealedSectorHealth int
const (
Unknown SealedSectorHealth = iota
Ok
ErrorInvalidChecksum
ErrorInvalidLength
ErrorMissing
)
// SortedSectorInfo is a slice of SectorInfo sorted (lexicographically, // SortedSectorInfo is a slice of SectorInfo sorted (lexicographically,
// ascending) by replica commitment (CommR). // ascending) by replica commitment (CommR).
type SortedSectorInfo struct { type SortedSectorInfo struct {
...@@ -50,7 +60,7 @@ func (s *SortedSectorInfo) Values() []SectorInfo { ...@@ -50,7 +60,7 @@ func (s *SortedSectorInfo) Values() []SectorInfo {
type SectorInfo struct { type SectorInfo struct {
SectorID uint64 SectorID uint64
CommR [CommitmentBytesLen]byte CommR [CommitmentBytesLen]byte
} }
// CommitmentBytesLen is the number of bytes in a CommR, CommD, CommP, and CommRStar. // CommitmentBytesLen is the number of bytes in a CommR, CommD, CommP, and CommRStar.
...@@ -71,6 +81,7 @@ type SealedSectorMetadata struct { ...@@ -71,6 +81,7 @@ type SealedSectorMetadata struct {
CommRStar [CommitmentBytesLen]byte CommRStar [CommitmentBytesLen]byte
Proof []byte Proof []byte
Pieces []PieceMetadata Pieces []PieceMetadata
Health SealedSectorHealth
} }
// SectorSealingStatus communicates how far along in the sealing process a // SectorSealingStatus communicates how far along in the sealing process a
...@@ -372,10 +383,10 @@ func GetAllStagedSectors(sectorBuilderPtr unsafe.Pointer) ([]StagedSectorMetadat ...@@ -372,10 +383,10 @@ func GetAllStagedSectors(sectorBuilderPtr unsafe.Pointer) ([]StagedSectorMetadat
} }
// GetAllSealedSectors returns a slice of all sealed sector metadata for the sector builder. // GetAllSealedSectors returns a slice of all sealed sector metadata for the sector builder.
func GetAllSealedSectors(sectorBuilderPtr unsafe.Pointer) ([]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)) resPtr := C.sector_builder_ffi_get_sealed_sectors((*C.sector_builder_ffi_SectorBuilder)(sectorBuilderPtr), 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 {
......
...@@ -85,6 +85,11 @@ func goSealedSectorMetadata(src *C.sector_builder_ffi_FFISealedSectorMetadata, s ...@@ -85,6 +85,11 @@ func goSealedSectorMetadata(src *C.sector_builder_ffi_FFISealedSectorMetadata, s
return []SealedSectorMetadata{}, errors.Wrap(err, "failed to marshal piece metadata") return []SealedSectorMetadata{}, errors.Wrap(err, "failed to marshal piece metadata")
} }
health, err := goSealedSectorHealth(ptrs[i].health)
if err != nil {
return []SealedSectorMetadata{}, errors.Wrap(err, "failed to marshal sealed sector health")
}
sectors[i] = SealedSectorMetadata{ sectors[i] = SealedSectorMetadata{
SectorID: uint64(ptrs[i].sector_id), SectorID: uint64(ptrs[i].sector_id),
CommD: commD, CommD: commD,
...@@ -92,6 +97,7 @@ func goSealedSectorMetadata(src *C.sector_builder_ffi_FFISealedSectorMetadata, s ...@@ -92,6 +97,7 @@ func goSealedSectorMetadata(src *C.sector_builder_ffi_FFISealedSectorMetadata, s
CommRStar: commRStar, CommRStar: commRStar,
Proof: proof, Proof: proof,
Pieces: pieces, Pieces: pieces,
Health: health,
} }
} }
...@@ -120,3 +126,20 @@ func goPieceMetadata(src *C.sector_builder_ffi_FFIPieceMetadata, size C.size_t) ...@@ -120,3 +126,20 @@ func goPieceMetadata(src *C.sector_builder_ffi_FFIPieceMetadata, size C.size_t)
return ps, nil return ps, nil
} }
func goSealedSectorHealth(health C.sector_builder_ffi_FFISealedSectorHealth) (SealedSectorHealth, error) {
switch health {
case C.sector_builder_ffi_FFISealedSectorHealth_Unknown:
return Unknown, nil
case C.sector_builder_ffi_FFISealedSectorHealth_Ok:
return Ok, nil
case C.sector_builder_ffi_FFISealedSectorHealth_ErrorInvalidChecksum:
return ErrorInvalidChecksum, nil
case C.sector_builder_ffi_FFISealedSectorHealth_ErrorInvalidLength:
return ErrorInvalidLength, nil
case C.sector_builder_ffi_FFISealedSectorHealth_ErrorMissing:
return ErrorMissing, nil
default:
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