@@ -3,6 +3,7 @@ package signing
33import (
44 "errors"
55 "fmt"
6+ "sync"
67
78 cosmos_proto "github.com/cosmos/cosmos-proto"
89 gogoproto "github.com/cosmos/gogoproto/proto"
@@ -29,9 +30,11 @@ type Context struct {
2930 typeResolver protoregistry.MessageTypeResolver
3031 addressCodec address.Codec
3132 validatorAddressCodec address.Codec
32- getSignersFuncs map [protoreflect.FullName ]GetSignersFunc
3333 customGetSignerFuncs map [protoreflect.FullName ]GetSignersFunc
3434 maxRecursionDepth int
35+
36+ mtx sync.Mutex
37+ getSignersFuncs map [protoreflect.FullName ]GetSignersFunc
3538}
3639
3740// Options are options for creating Context which will be used for signing operations.
@@ -110,6 +113,7 @@ func NewContext(options Options) (*Context, error) {
110113 typeResolver : protoTypes ,
111114 addressCodec : options .AddressCodec ,
112115 validatorAddressCodec : options .ValidatorAddressCodec ,
116+ mtx : sync.Mutex {},
113117 getSignersFuncs : map [protoreflect.FullName ]GetSignersFunc {},
114118 customGetSignerFuncs : customGetSignerFuncs ,
115119 maxRecursionDepth : options .MaxRecursionDepth ,
@@ -336,6 +340,8 @@ func (c *Context) getGetSignersFn(messageDescriptor protoreflect.MessageDescript
336340 }
337341 f , ok = c .getSignersFuncs [messageDescriptor .FullName ()]
338342 if ! ok {
343+ c .mtx .Lock ()
344+ defer c .mtx .Unlock ()
339345 var err error
340346 f , err = c .makeGetSignersFunc (messageDescriptor )
341347 if err != nil {
0 commit comments