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
a42ebfdc
Commit
a42ebfdc
authored
Jan 29, 2020
by
Łukasz Magiera
Browse files
Fix findBestPath for SinglePath
parent
327428a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
fs/fs.go
View file @
a42ebfdc
...
...
@@ -180,7 +180,9 @@ func (f *FS) FindSector(typ DataType, miner address.Address, id uint64) (out Sec
func
(
f
*
FS
)
findBestPath
(
size
uint64
,
cache
bool
,
strict
bool
)
StoragePath
{
var
best
StoragePath
bestw
:=
big
.
NewInt
(
0
)
bestc
:=
!
cache
// If we need cache, only return cache. If we need storage, prefer storage, fall back to cache
bestc
:=
true
for
path
,
info
:=
range
f
.
paths
{
if
info
.
cache
!=
cache
&&
(
bestc
!=
info
.
cache
||
strict
)
{
...
...
@@ -200,8 +202,11 @@ func (f *FS) findBestPath(size uint64, cache bool, strict bool) StoragePath {
w
:=
big
.
NewInt
(
avail
)
w
.
Mul
(
w
,
big
.
NewInt
(
int64
(
info
.
weight
)))
if
w
.
Cmp
(
bestw
)
>
0
{
if
info
.
cache
==
cache
{
bestw
=
w
}
best
=
path
bestw
=
w
bestc
=
info
.
cache
}
}
...
...
@@ -242,7 +247,7 @@ func (f *FS) AllocSector(typ DataType, miner address.Address, ssize uint64, cach
need
:=
overheadMul
[
typ
]
*
ssize
p
:=
f
.
findBestPath
(
need
,
cache
,
cach
e
)
p
:=
f
.
findBestPath
(
need
,
cache
,
fals
e
)
if
p
==
""
{
return
""
,
ErrNoSuitablePath
}
...
...
mock.go
View file @
a42ebfdc
...
...
@@ -30,7 +30,7 @@ func TempSectorbuilderDir(paths []fs.PathConfig, sectorSize uint64, ds datastore
func
SimplePath
(
dir
string
)
[]
fs
.
PathConfig
{
return
[]
fs
.
PathConfig
{{
Path
:
dir
,
Cache
:
fals
e
,
Cache
:
tru
e
,
Weight
:
1
,
}}
}
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