Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
859de514
Commit
859de514
authored
Jul 10, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dont use searchset for indirect pin checking
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
879cfeee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
24 deletions
+21
-24
pin/pin.go
pin/pin.go
+21
-24
No files found.
pin/pin.go
View file @
859de514
...
...
@@ -176,19 +176,16 @@ func (p *pinner) isPinned(k key.Key) (string, bool, error) {
}
for
_
,
rk
:=
range
p
.
recursePin
.
GetKeys
()
{
ss
:=
&
searchSet
{
target
:
k
}
rnd
,
err
:=
p
.
dserv
.
Get
(
context
.
Background
(),
rk
)
if
err
!=
nil
{
return
""
,
false
,
err
}
err
=
mdag
.
EnumerateChildren
(
context
.
Background
(),
p
.
dserv
,
rnd
,
ss
)
has
,
err
:
=
hasChild
(
p
.
dserv
,
rnd
,
k
)
if
err
!=
nil
{
return
""
,
false
,
err
}
if
ss
.
found
{
if
has
{
return
rk
.
B58String
(),
true
,
nil
}
}
...
...
@@ -349,26 +346,26 @@ func (p *pinner) PinWithMode(k key.Key, mode PinMode) {
}
}
// searchSet implements key.KeySet in
type
searchSet
struct
{
target
key
.
Key
found
bool
}
func
hasChild
(
ds
mdag
.
DAGService
,
root
*
mdag
.
Node
,
child
key
.
Key
)
(
bool
,
error
)
{
for
_
,
lnk
:=
range
root
.
Links
{
k
:=
key
.
Key
(
lnk
.
Hash
)
if
k
==
child
{
return
true
,
nil
}
func
(
ss
*
searchSet
)
Add
(
k
key
.
Key
)
{
if
ss
.
target
==
k
{
ss
.
found
=
true
}
}
nd
,
err
:=
ds
.
Get
(
context
.
Background
(),
k
)
if
err
!=
nil
{
return
false
,
err
}
func
(
ss
*
searchSet
)
Has
(
k
key
.
Key
)
bool
{
// returning true to all Has queries will cause EnumerateChildren to return
// almost immediately
return
ss
.
found
}
has
,
err
:=
hasChild
(
ds
,
nd
,
child
)
if
err
!=
nil
{
return
false
,
err
}
func
(
ss
*
searchSet
)
Keys
()
[]
key
.
Key
{
return
nil
if
has
{
return
has
,
nil
}
}
return
false
,
nil
}
func
(
ss
*
searchSet
)
Remove
(
key
.
Key
)
{}
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