From 53b93d5e708a461a35851cc4368dfe1c55f55632 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Mon, 3 Jul 2023 18:08:32 -0600 Subject: [PATCH] Removed child_state from FindChild --- gql_graph.go | 3 +-- thread.go | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gql_graph.go b/gql_graph.go index 5d857b5..2aa310f 100644 --- a/gql_graph.go +++ b/gql_graph.go @@ -795,8 +795,7 @@ func GQLMutationSendUpdate() *graphql.Field { var node GraphNode = nil err := UseStates(ctx, []GraphNode{server}, func(states NodeStateMap) (error){ - server_state := states[server.ID()].(*GQLThreadState) - node = FindChild(ctx, server, server_state, NodeID(id), states) + node = FindChild(ctx, server, NodeID(id), states) if node == nil { return fmt.Errorf("Failed to find ID: %s as child of server thread", id) } diff --git a/thread.go b/thread.go index e364d9e..7d36797 100644 --- a/thread.go +++ b/thread.go @@ -398,7 +398,8 @@ type Thread interface { ChildWaits() *sync.WaitGroup } -func FindChild(ctx * GraphContext, thread Thread, thread_state ThreadState, id NodeID, states NodeStateMap) Thread { +// Requires that thread is already locked for read in UseStates +func FindChild(ctx * GraphContext, thread Thread, id NodeID, states NodeStateMap) Thread { if thread == nil { panic("cannot recurse through nil") } @@ -406,12 +407,11 @@ func FindChild(ctx * GraphContext, thread Thread, thread_state ThreadState, id N return thread } - + thread_state := thread.State().(ThreadState) for _, child := range thread_state.Children() { var result Thread = nil UseMoreStates(ctx, []GraphNode{child}, states, func(states NodeStateMap) (error) { - child_state := states[child.ID()].(ThreadState) - result = FindChild(ctx, child, child_state, id, states) + result = FindChild(ctx, child, id, states) return nil }) if result != nil {