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
0aeff9f9
Unverified
Commit
0aeff9f9
authored
Nov 25, 2019
by
Erin Swenson-Healey
Committed by
GitHub
Nov 25, 2019
Browse files
fix(names): fix transposed Public/Sector/Private (#57)
parent
e7574485
Changes
3
Show whitespace changes
Inline
Side-by-side
bindings.go
View file @
0aeff9f9
...
...
@@ -33,13 +33,13 @@ func elapsed(what string) func() {
// SortedPublicSectorInfo is a slice of PublicSectorInfo sorted
// (lexicographically, ascending) by replica commitment (CommR).
type
SortedPublicSectorInfo
struct
{
f
[]
Sector
PublicInfo
f
[]
Public
Sector
Info
}
// SortedPrivateSectorInfo is a slice of PrivateSectorInfo sorted
// (lexicographically, ascending) by replica commitment (CommR).
type
SortedPrivateSectorInfo
struct
{
f
[]
Sector
PrivateInfo
f
[]
Private
Sector
Info
}
// SealTicket is required for the first step of Interactive PoRep.
...
...
@@ -61,8 +61,8 @@ type Candidate struct {
SectorChallengeIndex
uint64
}
// NewSorted
Sector
PublicInfo returns a SortedPublicSectorInfo
func
NewSorted
Sector
PublicInfo
(
sectorInfo
...
Sector
PublicInfo
)
SortedPublicSectorInfo
{
// NewSortedPublic
Sector
Info returns a SortedPublicSectorInfo
func
NewSortedPublic
Sector
Info
(
sectorInfo
...
Public
Sector
Info
)
SortedPublicSectorInfo
{
fn
:=
func
(
i
,
j
int
)
bool
{
return
bytes
.
Compare
(
sectorInfo
[
i
]
.
CommR
[
:
],
sectorInfo
[
j
]
.
CommR
[
:
])
==
-
1
}
...
...
@@ -74,8 +74,8 @@ func NewSortedSectorPublicInfo(sectorInfo ...SectorPublicInfo) SortedPublicSecto
}
}
// Values returns the sorted
Sector
PublicInfo as a slice
func
(
s
*
SortedPublicSectorInfo
)
Values
()
[]
Sector
PublicInfo
{
// Values returns the sorted Public
Sector
Info as a slice
func
(
s
*
SortedPublicSectorInfo
)
Values
()
[]
Public
Sector
Info
{
return
s
.
f
}
...
...
@@ -86,20 +86,20 @@ func (s SortedPublicSectorInfo) MarshalJSON() ([]byte, error) {
// 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
// SortedPublicSectorInfo which violates its invariant (that its
Sector
PublicInfo are sorted
// SortedPublicSectorInfo which violates its invariant (that its Public
Sector
Info are sorted
// in some defined way). Callers should take care to never provide a byte slice
// which would violate this invariant.
func
(
s
*
SortedPublicSectorInfo
)
UnmarshalJSON
(
b
[]
byte
)
error
{
return
json
.
Unmarshal
(
b
,
&
s
.
f
)
}
type
Sector
PublicInfo
struct
{
type
Public
Sector
Info
struct
{
SectorID
uint64
CommR
[
CommitmentBytesLen
]
byte
}
// NewSorted
Sector
PrivateInfo returns a SortedPrivateSectorInfo
func
NewSorted
Sector
PrivateInfo
(
sectorInfo
...
Sector
PrivateInfo
)
SortedPrivateSectorInfo
{
// NewSortedPrivate
Sector
Info returns a SortedPrivateSectorInfo
func
NewSortedPrivate
Sector
Info
(
sectorInfo
...
Private
Sector
Info
)
SortedPrivateSectorInfo
{
fn
:=
func
(
i
,
j
int
)
bool
{
return
bytes
.
Compare
(
sectorInfo
[
i
]
.
CommR
[
:
],
sectorInfo
[
j
]
.
CommR
[
:
])
==
-
1
}
...
...
@@ -111,8 +111,8 @@ func NewSortedSectorPrivateInfo(sectorInfo ...SectorPrivateInfo) SortedPrivateSe
}
}
// Values returns the sorted
Sector
PrivateInfo as a slice
func
(
s
*
SortedPrivateSectorInfo
)
Values
()
[]
Sector
PrivateInfo
{
// Values returns the sorted Private
Sector
Info as a slice
func
(
s
*
SortedPrivateSectorInfo
)
Values
()
[]
Private
Sector
Info
{
return
s
.
f
}
...
...
@@ -125,7 +125,7 @@ func (s *SortedPrivateSectorInfo) UnmarshalJSON(b []byte) error {
return
json
.
Unmarshal
(
b
,
&
s
.
f
)
}
type
Sector
PrivateInfo
struct
{
type
Private
Sector
Info
struct
{
SectorID
uint64
CommR
[
CommitmentBytesLen
]
byte
CacheDirPath
string
...
...
bindings_test.go
View file @
0aeff9f9
...
...
@@ -172,8 +172,8 @@ func TestSectorBuilderLifecycle(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
isValid
)
// enforces sort ordering of
Sector
PublicInfo tuples
sectorInfo
:=
sb
.
NewSorted
SectorPublicInfo
(
sb
.
SectorPublic
Info
{
// enforces sort ordering of Public
Sector
Info tuples
sectorInfo
:=
sb
.
NewSorted
PublicSectorInfo
(
sb
.
PublicSector
Info
{
SectorID
:
statusA
.
SectorID
,
CommR
:
statusA
.
CommR
,
})
...
...
@@ -351,14 +351,14 @@ func TestImportSector(t *testing.T) {
// generate a PoSt over the proving set before importing, just to exercise
// the new API
privateInfo
:=
sb
.
NewSorted
Sector
PrivateInfo
(
sb
.
Sector
PrivateInfo
{
privateInfo
:=
sb
.
NewSortedPrivate
Sector
Info
(
sb
.
Private
Sector
Info
{
SectorID
:
sectorID
,
CommR
:
output
.
CommR
,
CacheDirPath
:
sectorCacheDirPath
,
SealedSectorPath
:
sealedSectorFile
.
Name
(),
})
publicInfo
:=
sb
.
NewSorted
SectorPublicInfo
(
sb
.
SectorPublic
Info
{
publicInfo
:=
sb
.
NewSorted
PublicSectorInfo
(
sb
.
PublicSector
Info
{
SectorID
:
sectorID
,
CommR
:
output
.
CommR
,
})
...
...
@@ -413,9 +413,9 @@ func TestImportSector(t *testing.T) {
func
TestJsonMarshalSymmetry
(
t
*
testing
.
T
)
{
for
i
:=
0
;
i
<
100
;
i
++
{
xs
:=
make
([]
sb
.
Sector
PublicInfo
,
10
)
xs
:=
make
([]
sb
.
Public
Sector
Info
,
10
)
for
j
:=
0
;
j
<
10
;
j
++
{
var
x
sb
.
Sector
PublicInfo
var
x
sb
.
Public
Sector
Info
_
,
err
:=
io
.
ReadFull
(
rand
.
Reader
,
x
.
CommR
[
:
])
require
.
NoError
(
t
,
err
)
...
...
@@ -424,7 +424,7 @@ func TestJsonMarshalSymmetry(t *testing.T) {
x
.
SectorID
=
n
.
Uint64
()
xs
[
j
]
=
x
}
toSerialize
:=
sb
.
NewSorted
Sector
PublicInfo
(
xs
...
)
toSerialize
:=
sb
.
NewSortedPublic
Sector
Info
(
xs
...
)
serialized
,
err
:=
toSerialize
.
MarshalJSON
()
require
.
NoError
(
t
,
err
)
...
...
transforms.go
View file @
0aeff9f9
...
...
@@ -106,7 +106,7 @@ func cCandidates(src []Candidate) (*C.sector_builder_ffi_FFICandidate, C.size_t)
return
(
*
C
.
sector_builder_ffi_FFICandidate
)(
cCandidates
),
srcCSizeT
}
func
cPrivateReplicaInfos
(
src
[]
Sector
PrivateInfo
)
(
*
C
.
sector_builder_ffi_FFIPrivateReplicaInfo
,
C
.
size_t
)
{
func
cPrivateReplicaInfos
(
src
[]
Private
Sector
Info
)
(
*
C
.
sector_builder_ffi_FFIPrivateReplicaInfo
,
C
.
size_t
)
{
srcCSizeT
:=
C
.
size_t
(
len
(
src
))
cPrivateReplicas
:=
C
.
malloc
(
srcCSizeT
*
C
.
sizeof_sector_builder_ffi_FFIPrivateReplicaInfo
)
...
...
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