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
3ed773dd
Commit
3ed773dd
authored
Jan 30, 2020
by
Łukasz Magiera
Browse files
fs: better findBestPath errors
parent
6c13c17b
Changes
1
Show whitespace changes
Inline
Side-by-side
fs/fs.go
View file @
3ed773dd
...
...
@@ -145,8 +145,6 @@ func (f *FS) Init() error {
return
nil
}
// TODO: fix the locking situation
func
(
f
*
FS
)
FindSector
(
typ
DataType
,
miner
address
.
Address
,
id
uint64
)
(
out
SectorPath
,
err
error
)
{
// TODO: consider keeping some sort of index at some point
...
...
@@ -177,7 +175,7 @@ func (f *FS) FindSector(typ DataType, miner address.Address, id uint64) (out Sec
return
out
,
nil
}
func
(
f
*
FS
)
findBestPath
(
size
uint64
,
cache
bool
,
strict
bool
)
StoragePath
{
func
(
f
*
FS
)
findBestPath
(
size
uint64
,
cache
bool
,
strict
bool
)
(
StoragePath
,
error
)
{
var
best
StoragePath
bestw
:=
big
.
NewInt
(
0
)
...
...
@@ -211,7 +209,15 @@ func (f *FS) findBestPath(size uint64, cache bool, strict bool) StoragePath {
}
}
return
best
if
best
==
""
{
if
cache
{
return
best
,
xerrors
.
Errorf
(
"no available cache: %w"
,
ErrNoSuitablePath
)
}
return
best
,
xerrors
.
Errorf
(
"no available storage: %w"
,
ErrNoSuitablePath
)
}
return
best
,
nil
}
func
(
f
*
FS
)
ForceAllocSector
(
typ
DataType
,
miner
address
.
Address
,
ssize
uint64
,
cache
bool
,
id
uint64
)
(
SectorPath
,
error
)
{
...
...
@@ -247,9 +253,9 @@ func (f *FS) AllocSector(typ DataType, miner address.Address, ssize uint64, cach
need
:=
overheadMul
[
typ
]
*
ssize
p
:=
f
.
findBestPath
(
need
,
cache
,
false
)
if
p
==
""
{
return
""
,
E
rr
NoSuitablePath
p
,
err
:=
f
.
findBestPath
(
need
,
cache
,
false
)
if
err
!=
nil
{
return
""
,
e
rr
}
sp
:=
p
.
Sector
(
typ
,
miner
,
id
)
...
...
@@ -258,10 +264,11 @@ func (f *FS) AllocSector(typ DataType, miner address.Address, ssize uint64, cach
}
func
(
f
*
FS
)
PrepareCacheMove
(
sector
SectorPath
,
ssize
uint64
,
tocache
bool
)
(
SectorPath
,
error
)
{
p
:=
f
.
findBestPath
(
ssize
,
tocache
,
true
)
if
p
==
""
{
return
""
,
E
rr
NoSuitablePath
p
,
err
:=
f
.
findBestPath
(
ssize
,
tocache
,
true
)
if
err
!=
nil
{
return
""
,
e
rr
}
m
,
err
:=
sector
.
miner
()
if
err
!=
nil
{
return
""
,
err
...
...
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