You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Go TFChain client isn't Thread safe (as Thabet originally mentioned).
A major issue with the current API is that The current implementation of GetClient() has a race condition because it returns references to the internal connection state (cl and meta) that other goroutines can modify after the lock is released.
Also, we need to verify if the inner client used is thread-safe and revise if we need/can go with this.
One option we have to deal with GetClient is to present new safer API that use operation-based approach
func (s *Substrate) withClient(op func(Conn, Meta) error) error {
s.mu.Lock()
defer s.mu.Unlock()
if s.closed {
return ErrClosed
}
// Execute operation while holding the lock
return op(s.cl, s.meta)
}
Currently, the Go TFChain client isn't Thread safe (as Thabet originally mentioned).
A major issue with the current API is that The current implementation of GetClient() has a race condition because it returns references to the internal connection state (cl and meta) that other goroutines can modify after the lock is released.
Also, we need to verify if the inner client used is thread-safe and revise if we need/can go with this.
One option we have to deal with GetClient is to present new safer API that use operation-based approach
The text was updated successfully, but these errors were encountered: