Unverified Commit 0aeff9f9 authored by Erin Swenson-Healey's avatar Erin Swenson-Healey Committed by GitHub
Browse files

fix(names): fix transposed Public/Sector/Private (#57)

parent e7574485
...@@ -33,13 +33,13 @@ func elapsed(what string) func() { ...@@ -33,13 +33,13 @@ func elapsed(what string) func() {
// SortedPublicSectorInfo is a slice of PublicSectorInfo sorted // SortedPublicSectorInfo is a slice of PublicSectorInfo sorted
// (lexicographically, ascending) by replica commitment (CommR). // (lexicographically, ascending) by replica commitment (CommR).
type SortedPublicSectorInfo struct { type SortedPublicSectorInfo struct {
f []SectorPublicInfo f []PublicSectorInfo
} }
// SortedPrivateSectorInfo is a slice of PrivateSectorInfo sorted // SortedPrivateSectorInfo is a slice of PrivateSectorInfo sorted
// (lexicographically, ascending) by replica commitment (CommR). // (lexicographically, ascending) by replica commitment (CommR).
type SortedPrivateSectorInfo struct { type SortedPrivateSectorInfo struct {
f []SectorPrivateInfo f []PrivateSectorInfo
} }
// SealTicket is required for the first step of Interactive PoRep. // SealTicket is required for the first step of Interactive PoRep.
...@@ -61,8 +61,8 @@ type Candidate struct { ...@@ -61,8 +61,8 @@ type Candidate struct {
SectorChallengeIndex uint64 SectorChallengeIndex uint64
} }
// NewSortedSectorPublicInfo returns a SortedPublicSectorInfo // NewSortedPublicSectorInfo returns a SortedPublicSectorInfo
func NewSortedSectorPublicInfo(sectorInfo ...SectorPublicInfo) SortedPublicSectorInfo { func NewSortedPublicSectorInfo(sectorInfo ...PublicSectorInfo) SortedPublicSectorInfo {
fn := func(i, j int) bool { fn := func(i, j int) bool {
return bytes.Compare(sectorInfo[i].CommR[:], sectorInfo[j].CommR[:]) == -1 return bytes.Compare(sectorInfo[i].CommR[:], sectorInfo[j].CommR[:]) == -1
} }
...@@ -74,8 +74,8 @@ func NewSortedSectorPublicInfo(sectorInfo ...SectorPublicInfo) SortedPublicSecto ...@@ -74,8 +74,8 @@ func NewSortedSectorPublicInfo(sectorInfo ...SectorPublicInfo) SortedPublicSecto
} }
} }
// Values returns the sorted SectorPublicInfo as a slice // Values returns the sorted PublicSectorInfo as a slice
func (s *SortedPublicSectorInfo) Values() []SectorPublicInfo { func (s *SortedPublicSectorInfo) Values() []PublicSectorInfo {
return s.f return s.f
} }
...@@ -86,20 +86,20 @@ func (s SortedPublicSectorInfo) MarshalJSON() ([]byte, error) { ...@@ -86,20 +86,20 @@ func (s SortedPublicSectorInfo) MarshalJSON() ([]byte, error) {
// UnmarshalJSON parses the JSON-encoded byte slice and stores the result in the // UnmarshalJSON parses the JSON-encoded byte slice and stores the result in the
// value pointed to by s.f. Note that this method allows for construction of a // value pointed to by s.f. Note that this method allows for construction of a
// SortedPublicSectorInfo which violates its invariant (that its SectorPublicInfo are sorted // SortedPublicSectorInfo which violates its invariant (that its PublicSectorInfo are sorted
// in some defined way). Callers should take care to never provide a byte slice // in some defined way). Callers should take care to never provide a byte slice
// which would violate this invariant. // which would violate this invariant.
func (s *SortedPublicSectorInfo) UnmarshalJSON(b []byte) error { func (s *SortedPublicSectorInfo) UnmarshalJSON(b []byte) error {
return json.Unmarshal(b, &s.f) return json.Unmarshal(b, &s.f)
} }
type SectorPublicInfo struct { type PublicSectorInfo struct {
SectorID uint64 SectorID uint64
CommR [CommitmentBytesLen]byte CommR [CommitmentBytesLen]byte
} }
// NewSortedSectorPrivateInfo returns a SortedPrivateSectorInfo // NewSortedPrivateSectorInfo returns a SortedPrivateSectorInfo
func NewSortedSectorPrivateInfo(sectorInfo ...SectorPrivateInfo) SortedPrivateSectorInfo { func NewSortedPrivateSectorInfo(sectorInfo ...PrivateSectorInfo) SortedPrivateSectorInfo {
fn := func(i, j int) bool { fn := func(i, j int) bool {
return bytes.Compare(sectorInfo[i].CommR[:], sectorInfo[j].CommR[:]) == -1 return bytes.Compare(sectorInfo[i].CommR[:], sectorInfo[j].CommR[:]) == -1
} }
...@@ -111,8 +111,8 @@ func NewSortedSectorPrivateInfo(sectorInfo ...SectorPrivateInfo) SortedPrivateSe ...@@ -111,8 +111,8 @@ func NewSortedSectorPrivateInfo(sectorInfo ...SectorPrivateInfo) SortedPrivateSe
} }
} }
// Values returns the sorted SectorPrivateInfo as a slice // Values returns the sorted PrivateSectorInfo as a slice
func (s *SortedPrivateSectorInfo) Values() []SectorPrivateInfo { func (s *SortedPrivateSectorInfo) Values() []PrivateSectorInfo {
return s.f return s.f
} }
...@@ -125,7 +125,7 @@ func (s *SortedPrivateSectorInfo) UnmarshalJSON(b []byte) error { ...@@ -125,7 +125,7 @@ func (s *SortedPrivateSectorInfo) UnmarshalJSON(b []byte) error {
return json.Unmarshal(b, &s.f) return json.Unmarshal(b, &s.f)
} }
type SectorPrivateInfo struct { type PrivateSectorInfo struct {
SectorID uint64 SectorID uint64
CommR [CommitmentBytesLen]byte CommR [CommitmentBytesLen]byte
CacheDirPath string CacheDirPath string
......
...@@ -172,8 +172,8 @@ func TestSectorBuilderLifecycle(t *testing.T) { ...@@ -172,8 +172,8 @@ func TestSectorBuilderLifecycle(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.True(t, isValid) require.True(t, isValid)
// enforces sort ordering of SectorPublicInfo tuples // enforces sort ordering of PublicSectorInfo tuples
sectorInfo := sb.NewSortedSectorPublicInfo(sb.SectorPublicInfo{ sectorInfo := sb.NewSortedPublicSectorInfo(sb.PublicSectorInfo{
SectorID: statusA.SectorID, SectorID: statusA.SectorID,
CommR: statusA.CommR, CommR: statusA.CommR,
}) })
...@@ -351,14 +351,14 @@ func TestImportSector(t *testing.T) { ...@@ -351,14 +351,14 @@ func TestImportSector(t *testing.T) {
// generate a PoSt over the proving set before importing, just to exercise // generate a PoSt over the proving set before importing, just to exercise
// the new API // the new API
privateInfo := sb.NewSortedSectorPrivateInfo(sb.SectorPrivateInfo{ privateInfo := sb.NewSortedPrivateSectorInfo(sb.PrivateSectorInfo{
SectorID: sectorID, SectorID: sectorID,
CommR: output.CommR, CommR: output.CommR,
CacheDirPath: sectorCacheDirPath, CacheDirPath: sectorCacheDirPath,
SealedSectorPath: sealedSectorFile.Name(), SealedSectorPath: sealedSectorFile.Name(),
}) })
publicInfo := sb.NewSortedSectorPublicInfo(sb.SectorPublicInfo{ publicInfo := sb.NewSortedPublicSectorInfo(sb.PublicSectorInfo{
SectorID: sectorID, SectorID: sectorID,
CommR: output.CommR, CommR: output.CommR,
}) })
...@@ -413,9 +413,9 @@ func TestImportSector(t *testing.T) { ...@@ -413,9 +413,9 @@ func TestImportSector(t *testing.T) {
func TestJsonMarshalSymmetry(t *testing.T) { func TestJsonMarshalSymmetry(t *testing.T) {
for i := 0; i < 100; i++ { for i := 0; i < 100; i++ {
xs := make([]sb.SectorPublicInfo, 10) xs := make([]sb.PublicSectorInfo, 10)
for j := 0; j < 10; j++ { for j := 0; j < 10; j++ {
var x sb.SectorPublicInfo var x sb.PublicSectorInfo
_, err := io.ReadFull(rand.Reader, x.CommR[:]) _, err := io.ReadFull(rand.Reader, x.CommR[:])
require.NoError(t, err) require.NoError(t, err)
...@@ -424,7 +424,7 @@ func TestJsonMarshalSymmetry(t *testing.T) { ...@@ -424,7 +424,7 @@ func TestJsonMarshalSymmetry(t *testing.T) {
x.SectorID = n.Uint64() x.SectorID = n.Uint64()
xs[j] = x xs[j] = x
} }
toSerialize := sb.NewSortedSectorPublicInfo(xs...) toSerialize := sb.NewSortedPublicSectorInfo(xs...)
serialized, err := toSerialize.MarshalJSON() serialized, err := toSerialize.MarshalJSON()
require.NoError(t, err) require.NoError(t, err)
......
...@@ -106,7 +106,7 @@ func cCandidates(src []Candidate) (*C.sector_builder_ffi_FFICandidate, C.size_t) ...@@ -106,7 +106,7 @@ func cCandidates(src []Candidate) (*C.sector_builder_ffi_FFICandidate, C.size_t)
return (*C.sector_builder_ffi_FFICandidate)(cCandidates), srcCSizeT return (*C.sector_builder_ffi_FFICandidate)(cCandidates), srcCSizeT
} }
func cPrivateReplicaInfos(src []SectorPrivateInfo) (*C.sector_builder_ffi_FFIPrivateReplicaInfo, C.size_t) { func cPrivateReplicaInfos(src []PrivateSectorInfo) (*C.sector_builder_ffi_FFIPrivateReplicaInfo, C.size_t) {
srcCSizeT := C.size_t(len(src)) srcCSizeT := C.size_t(len(src))
cPrivateReplicas := C.malloc(srcCSizeT * C.sizeof_sector_builder_ffi_FFIPrivateReplicaInfo) cPrivateReplicas := C.malloc(srcCSizeT * C.sizeof_sector_builder_ffi_FFIPrivateReplicaInfo)
......
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