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
79a4a1d8
Commit
79a4a1d8
authored
Sep 04, 2019
by
laser
Browse files
feat(plumb sector health parameter to FFI call)
parent
5a6af1f9
Changes
3
Show whitespace changes
Inline
Side-by-side
bindings.go
View file @
79a4a1d8
...
...
@@ -386,7 +386,7 @@ func GetAllStagedSectors(sectorBuilderPtr unsafe.Pointer) ([]StagedSectorMetadat
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
),
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
)
if
resPtr
.
status_code
!=
0
{
...
...
bindings_test.go
View file @
79a4a1d8
...
...
@@ -87,12 +87,13 @@ func TestSectorBuilderLifecycle(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
isValid
)
sealedSectors
,
err
:=
sb
.
GetAllSealedSectors
(
ptr
)
sealedSectors
,
err
:=
sb
.
GetAllSealedSectors
(
ptr
,
true
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
1
,
len
(
sealedSectors
),
"expected to see one sealed sector"
)
sealedSector
:=
sealedSectors
[
0
]
require
.
Equal
(
t
,
uint64
(
1
),
sealedSector
.
SectorID
)
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
// data commitment
require
.
Equal
(
t
,
commP
,
sealedSector
.
CommD
)
...
...
transforms.go
View file @
79a4a1d8
...
...
@@ -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
)
{
switch
health
{
case
C
.
sector_builder_ffi_FFISealedSectorHealth_
Unknown
:
case
C
.
Unknown
:
return
Unknown
,
nil
case
C
.
sector_builder_ffi_FFISealedSectorHealth_
Ok
:
case
C
.
Ok
:
return
Ok
,
nil
case
C
.
sector_builder_ffi_FFISealedSectorHealth_
ErrorInvalidChecksum
:
case
C
.
ErrorInvalidChecksum
:
return
ErrorInvalidChecksum
,
nil
case
C
.
sector_builder_ffi_FFISealedSectorHealth_
ErrorInvalidLength
:
case
C
.
ErrorInvalidLength
:
return
ErrorInvalidLength
,
nil
case
C
.
sector_builder_ffi_FFISealedSectorHealth_
ErrorMissing
:
case
C
.
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