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-merkledag
Commits
f274b02d
Commit
f274b02d
authored
May 04, 2017
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: wire sessions up through into FetchGraph
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
7eaacd3a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
merkledag.go
merkledag.go
+21
-2
No files found.
merkledag.go
View file @
f274b02d
...
...
@@ -161,11 +161,30 @@ func GetLinksDirect(serv node.NodeGetter) GetLinks {
}
}
type
sesGetter
struct
{
bs
*
bserv
.
Session
}
func
(
sg
*
sesGetter
)
Get
(
ctx
context
.
Context
,
c
*
cid
.
Cid
)
(
node
.
Node
,
error
)
{
blk
,
err
:=
sg
.
bs
.
GetBlock
(
ctx
,
c
)
if
err
!=
nil
{
return
nil
,
err
}
return
decodeBlock
(
blk
)
}
// FetchGraph fetches all nodes that are children of the given node
func
FetchGraph
(
ctx
context
.
Context
,
root
*
cid
.
Cid
,
serv
DAGService
)
error
{
var
ng
node
.
NodeGetter
=
serv
ds
,
ok
:=
serv
.
(
*
dagService
)
if
ok
{
ng
=
&
sesGetter
{
ds
.
Blocks
.
NewSession
(
ctx
)}
}
v
,
_
:=
ctx
.
Value
(
"progress"
)
.
(
*
ProgressTracker
)
if
v
==
nil
{
return
EnumerateChildrenAsync
(
ctx
,
GetLinksDirect
(
serv
),
root
,
cid
.
NewSet
()
.
Visit
)
return
EnumerateChildrenAsync
(
ctx
,
GetLinksDirect
(
ng
),
root
,
cid
.
NewSet
()
.
Visit
)
}
set
:=
cid
.
NewSet
()
visit
:=
func
(
c
*
cid
.
Cid
)
bool
{
...
...
@@ -176,7 +195,7 @@ func FetchGraph(ctx context.Context, root *cid.Cid, serv DAGService) error {
return
false
}
}
return
EnumerateChildrenAsync
(
ctx
,
GetLinksDirect
(
serv
),
root
,
visit
)
return
EnumerateChildrenAsync
(
ctx
,
GetLinksDirect
(
ng
),
root
,
visit
)
}
// FindLinks searches this nodes links for the given 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