Commit fa670628 authored by Eric Myhre's avatar Eric Myhre

Explicit names for several TP/TC embedded fields.

Autocomplete on TraversalProgress was suggesting *way* too many things.
It's now reigned in.

Being able to say `tp.Ctx` is gone, but that's a small price to pay.
(And perhaps we should actually move the Context up to TP?  Wouldn't
seem unreasonable.  I think the main reason it's in TC right now is
to reduce the size of memory that's shuffled when TP is passed by value
down the stack, and it's unclear how consequential that's really
going to be in the big picture.  We can review this later.)
Signed-off-by: default avatarEric Myhre <hash@exultant.us>
parent d7be1f27
......@@ -33,8 +33,8 @@ func (tc *TraversalConfig) init() {
}
func (tp *TraversalProgress) init() {
if tp.TraversalConfig == nil {
tp.TraversalConfig = &TraversalConfig{}
if tp.Cfg == nil {
tp.Cfg = &TraversalConfig{}
}
tp.TraversalConfig.init()
tp.Cfg.init()
}
......@@ -22,11 +22,11 @@ type AdvVisitFn func(TraversalProgress, ipld.Node, TraversalReason) error
type TraversalReason byte // enum = SelectionMatch | SelectionParent | SelectionCandidate // probably only pointful for block edges?
type TraversalProgress struct {
*TraversalConfig
Cfg *TraversalConfig
Path ipld.Path // Path is how we reached the current point in the traversal.
LastBlock struct { // LastBlock stores the Path and Link of the last block edge we had to load. (It will always be zero in traversals with no linkloader.)
ipld.Path
ipld.Link
Path ipld.Path
Link ipld.Link
}
}
......
......@@ -70,10 +70,10 @@ func (tp TraversalProgress) Focus(n ipld.Node, p ipld.Path, fn VisitFn) error {
}
// Load link!
next, err := lnk.Load(
tp.Ctx,
tp.Cfg.Ctx,
lnkCtx,
tp.LinkNodeBuilderChooser(lnk, lnkCtx),
tp.LinkLoader,
tp.Cfg.LinkNodeBuilderChooser(lnk, lnkCtx),
tp.Cfg.LinkLoader,
)
if err != nil {
return fmt.Errorf("error traversing node at %q: could not load link %q: %s", p.Truncate(i+1), lnk, err)
......
......@@ -142,7 +142,7 @@ func TestFocusWithLinkLoading(t *testing.T) {
})
t.Run("link traversal with loader should work", func(t *testing.T) {
err := traversal.TraversalProgress{
TraversalConfig: &traversal.TraversalConfig{
Cfg: &traversal.TraversalConfig{
LinkLoader: func(lnk ipld.Link, _ ipld.LinkContext) (io.Reader, error) {
return bytes.NewBuffer(storage[lnk]), nil
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment