Updated FindChild to use UseMoreStates and expect to get passed currently held states

graph-rework-2
noah metz 2023-07-02 09:05:34 -06:00
parent 97c1405e3c
commit 638148afab
2 changed files with 4 additions and 4 deletions

@ -796,7 +796,7 @@ func GQLMutationSendUpdate() *graphql.Field {
var node GraphNode = nil var node GraphNode = nil
err := UseStates(ctx, []GraphNode{server}, func(states NodeStateMap) (error){ err := UseStates(ctx, []GraphNode{server}, func(states NodeStateMap) (error){
server_state := states[server.ID()].(*GQLThreadState) server_state := states[server.ID()].(*GQLThreadState)
node = FindChild(ctx, server, server_state, NodeID(id)) node = FindChild(ctx, server, server_state, NodeID(id), states)
if node == nil { if node == nil {
return fmt.Errorf("Failed to find ID: %s as child of server thread", id) return fmt.Errorf("Failed to find ID: %s as child of server thread", id)
} }

@ -321,7 +321,7 @@ type Thread interface {
ChildWaits() *sync.WaitGroup ChildWaits() *sync.WaitGroup
} }
func FindChild(ctx * GraphContext, thread Thread, thread_state ThreadState, id NodeID) Thread { func FindChild(ctx * GraphContext, thread Thread, thread_state ThreadState, id NodeID, states NodeStateMap) Thread {
if thread == nil { if thread == nil {
panic("cannot recurse through nil") panic("cannot recurse through nil")
} }
@ -332,9 +332,9 @@ func FindChild(ctx * GraphContext, thread Thread, thread_state ThreadState, id N
for _, child := range thread_state.Children() { for _, child := range thread_state.Children() {
var result Thread = nil var result Thread = nil
UseStates(ctx, []GraphNode{child}, func(states NodeStateMap) (error) { UseMoreStates(ctx, []GraphNode{child}, states, func(states NodeStateMap) (error) {
child_state := states[child.ID()].(ThreadState) child_state := states[child.ID()].(ThreadState)
result = FindChild(ctx, child, child_state, id) result = FindChild(ctx, child, child_state, id, states)
return nil return nil
}) })
if result != nil { if result != nil {