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
99304d84
Commit
99304d84
authored
Jan 23, 2020
by
Łukasz Magiera
Browse files
CanCommit Method
parent
af914f02
Changes
2
Hide whitespace changes
Inline
Side-by-side
files.go
View file @
99304d84
...
...
@@ -81,6 +81,21 @@ func (sb *SectorBuilder) TrimCache(sectorID uint64) error {
return
nil
}
func
(
sb
*
SectorBuilder
)
CanCommit
(
sectorID
uint64
)
(
bool
,
error
)
{
dir
,
err
:=
sb
.
sectorCacheDir
(
sectorID
)
if
err
!=
nil
{
return
false
,
xerrors
.
Errorf
(
"getting cache dir: %w"
,
err
)
}
ents
,
err
:=
ioutil
.
ReadDir
(
dir
)
if
err
!=
nil
{
return
false
,
err
}
// TODO: slightly more sophisticated check
return
len
(
ents
)
==
10
,
nil
}
func
toReadableFile
(
r
io
.
Reader
,
n
int64
)
(
*
os
.
File
,
func
()
error
,
error
)
{
f
,
ok
:=
r
.
(
*
os
.
File
)
if
ok
{
...
...
interface.go
View file @
99304d84
...
...
@@ -24,6 +24,7 @@ type Interface interface {
ReadPieceFromSealedSector
(
sectorID
uint64
,
offset
uint64
,
size
uint64
,
ticket
[]
byte
,
commD
[]
byte
)
(
io
.
ReadCloser
,
error
)
GetPath
(
string
,
string
)
(
string
,
error
)
CanCommit
(
sectorID
uint64
)
(
bool
,
error
)
WorkerStats
()
WorkerStats
AddWorker
(
context
.
Context
,
WorkerCfg
)
(
<-
chan
WorkerTask
,
error
)
TaskDone
(
context
.
Context
,
uint64
,
SealRes
)
error
...
...
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