Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-sectorbuilder
Commits
8417fb51
Commit
8417fb51
authored
Sep 03, 2019
by
laser
Browse files
feat(plumb healthcheck bool through FFI)
parent
fa239db1
Changes
2
Show whitespace changes
Inline
Side-by-side
bindings.go
View file @
8417fb51
...
...
@@ -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,
// ascending) by replica commitment (CommR).
type
SortedSectorInfo
struct
{
...
...
@@ -71,6 +81,7 @@ type SealedSectorMetadata struct {
CommRStar
[
CommitmentBytesLen
]
byte
Proof
[]
byte
Pieces
[]
PieceMetadata
Health
SealedSectorHealth
}
// SectorSealingStatus communicates how far along in the sealing process a
...
...
@@ -372,10 +383,10 @@ func GetAllStagedSectors(sectorBuilderPtr unsafe.Pointer) ([]StagedSectorMetadat
}
// 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"
)()
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
)
if
resPtr
.
status_code
!=
0
{
...
...
transforms.go
View file @
8417fb51
...
...
@@ -85,6 +85,11 @@ func goSealedSectorMetadata(src *C.sector_builder_ffi_FFISealedSectorMetadata, s
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
{
SectorID
:
uint64
(
ptrs
[
i
]
.
sector_id
),
CommD
:
commD
,
...
...
@@ -92,6 +97,7 @@ func goSealedSectorMetadata(src *C.sector_builder_ffi_FFISealedSectorMetadata, s
CommRStar
:
commRStar
,
Proof
:
proof
,
Pieces
:
pieces
,
Health
:
health
,
}
}
...
...
@@ -120,3 +126,20 @@ func goPieceMetadata(src *C.sector_builder_ffi_FFIPieceMetadata, size C.size_t)
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
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment