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
f39d270e
Commit
f39d270e
authored
Sep 13, 2019
by
laser
Browse files
refactor(enum): extract sealed sector health into package
parent
632a680c
Changes
4
Hide whitespace changes
Inline
Side-by-side
bindings.go
View file @
f39d270e
...
...
@@ -6,6 +6,8 @@ import (
"time"
"unsafe"
"github.com/filecoin-project/go-sectorbuilder/sealed_sector_health"
logging
"github.com/ipfs/go-log"
"github.com/pkg/errors"
)
...
...
@@ -24,18 +26,6 @@ func elapsed(what string) func() {
}
}
// SealedSectorHealth represents the healthiness of a sector managed by a
// sector builder.
type
SealedSectorHealth
int
const
(
Unknown
SealedSectorHealth
=
iota
Ok
// everything is fine
ErrorInvalidChecksum
// sector exists, but checksum is invalid
ErrorInvalidLength
// sector exists, but length is incorrect
ErrorMissing
// sector no longer exists
)
// SortedSectorInfo is a slice of SectorInfo sorted (lexicographically,
// ascending) by replica commitment (CommR).
type
SortedSectorInfo
struct
{
...
...
@@ -83,7 +73,7 @@ type SealedSectorMetadata struct {
CommRStar
[
CommitmentBytesLen
]
byte
Proof
[]
byte
Pieces
[]
PieceMetadata
Health
S
ealed
S
ectorHealth
Health
s
ealed
_s
ector
_health
.
Health
}
// SectorSealingStatus communicates how far along in the sealing process a
...
...
bindings_test.go
View file @
f39d270e
...
...
@@ -12,6 +12,7 @@ import (
"unsafe"
sb
"github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/go-sectorbuilder/sealed_sector_health"
"github.com/stretchr/testify/require"
)
...
...
@@ -98,7 +99,7 @@ func TestSectorBuilderLifecycle(t *testing.T) {
sealedSector
:=
sealedSectors
[
0
]
require
.
Equal
(
t
,
uint64
(
1
),
sealedSector
.
SectorID
)
require
.
Equal
(
t
,
1
,
len
(
sealedSector
.
Pieces
))
require
.
Equal
(
t
,
s
b
.
Ok
,
sealedSector
.
Health
)
require
.
Equal
(
t
,
s
ealed_sector_health
.
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
)
...
...
sealed_sector_health/health.go
0 → 100644
View file @
f39d270e
package
sealed_sector_health
// Health represents the healthiness of a sector managed by a
// sector builder.
type
Health
int
const
(
Unknown
Health
=
iota
Ok
// everything is fine
ErrorInvalidChecksum
// sector exists, but checksum is invalid
ErrorInvalidLength
// sector exists, but length is incorrect
ErrorMissing
// sector no longer exists
)
transforms.go
View file @
f39d270e
...
...
@@ -3,6 +3,8 @@ package go_sectorbuilder
import
(
"unsafe"
"github.com/filecoin-project/go-sectorbuilder/sealed_sector_health"
"github.com/pkg/errors"
)
...
...
@@ -127,19 +129,19 @@ func goPieceMetadata(src *C.sector_builder_ffi_FFIPieceMetadata, size C.size_t)
return
ps
,
nil
}
func
goSealedSectorHealth
(
health
C
.
sector_builder_ffi_FFISealedSectorHealth
)
(
S
ealed
S
ectorHealth
,
error
)
{
func
goSealedSectorHealth
(
health
C
.
sector_builder_ffi_FFISealedSectorHealth
)
(
s
ealed
_s
ector
_health
.
Health
,
error
)
{
switch
health
{
case
C
.
Unknown
:
return
Unknown
,
nil
return
sealed_sector_health
.
Unknown
,
nil
case
C
.
Ok
:
return
Ok
,
nil
return
sealed_sector_health
.
Ok
,
nil
case
C
.
ErrorInvalidChecksum
:
return
ErrorInvalidChecksum
,
nil
return
sealed_sector_health
.
ErrorInvalidChecksum
,
nil
case
C
.
ErrorInvalidLength
:
return
ErrorInvalidLength
,
nil
return
sealed_sector_health
.
ErrorInvalidLength
,
nil
case
C
.
ErrorMissing
:
return
ErrorMissing
,
nil
return
sealed_sector_health
.
ErrorMissing
,
nil
default
:
return
Unknown
,
errors
.
Errorf
(
"unhandled sealed sector health: %v"
,
health
)
return
sealed_sector_health
.
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