From 067517db68653f73ff422d054626ed8b97406824 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Tue, 7 May 2024 11:56:27 +0100 Subject: [PATCH] fix newHeads unsubscribe --- go/common/subscription/utils.go | 3 --- go/host/rpc/clientapi/client_api_filter.go | 1 + go/node/docker_node.go | 4 +--- tools/walletextension/rpcapi/filter_api.go | 1 + 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/go/common/subscription/utils.go b/go/common/subscription/utils.go index b9d92954c7..81b02aaf20 100644 --- a/go/common/subscription/utils.go +++ b/go/common/subscription/utils.go @@ -62,8 +62,5 @@ func ForwardFromChannels[R any](inputChannels []chan R, unsubscribed *atomic.Boo // Must be called as a go routine! func HandleUnsubscribe(connectionSub *rpc.Subscription, unsubscribed *atomic.Bool, onUnsub func()) { <-connectionSub.Err() - if unsubscribed != nil { - unsubscribed.Store(true) - } onUnsub() } diff --git a/go/host/rpc/clientapi/client_api_filter.go b/go/host/rpc/clientapi/client_api_filter.go index 7af780cda1..238f5d5abf 100644 --- a/go/host/rpc/clientapi/client_api_filter.go +++ b/go/host/rpc/clientapi/client_api_filter.go @@ -62,6 +62,7 @@ func (api *FilterAPI) Logs(ctx context.Context, encryptedParams common.Encrypted }) go subscriptioncommon.HandleUnsubscribe(subscription, &unsubscribed, func() { api.host.UnsubscribeLogs(subscription.ID) + unsubscribed.Store(true) }) return subscription, nil } diff --git a/go/node/docker_node.go b/go/node/docker_node.go index eb67a175c4..f86de5d362 100644 --- a/go/node/docker_node.go +++ b/go/node/docker_node.go @@ -9,9 +9,7 @@ import ( "github.com/ten-protocol/go-ten/go/common/docker" ) -var ( - _enclaveDataDir = "/enclavedata" // this is how the directory is references within the enclave container -) +var _enclaveDataDir = "/enclavedata" // this is how the directory is references within the enclave container type DockerNode struct { cfg *Config diff --git a/tools/walletextension/rpcapi/filter_api.go b/tools/walletextension/rpcapi/filter_api.go index df056bcb56..a0664ae58e 100644 --- a/tools/walletextension/rpcapi/filter_api.go +++ b/tools/walletextension/rpcapi/filter_api.go @@ -114,6 +114,7 @@ func (api *FilterAPI) Logs(ctx context.Context, crit common.FilterCriteria) (*rp for _, connection := range backendWSConnections { _ = returnConn(api.we.rpcWSConnPool, connection.BackingClient()) } + unsubscribed.Store(true) }) return subscription, err