forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: merge conflict resolution errors, config
- Loading branch information
1 parent
920c0c4
commit 227e3a6
Showing
2 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package registry | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/cosmos/gogoproto/proto" | ||
"google.golang.org/protobuf/reflect/protoreflect" | ||
"google.golang.org/protobuf/reflect/protoregistry" | ||
|
||
"cosmossdk.io/x/tx/signing" | ||
) | ||
|
||
var ( | ||
mergedRegistryOnce sync.Once | ||
mergedRegistry *protoregistry.Files | ||
_ signing.ProtoFileResolver = lazyProtoRegistry{} | ||
) | ||
|
||
// lazyProtoRegistry is a lazy loading wrapper around the global protobuf registry. | ||
type lazyProtoRegistry struct{} | ||
|
||
func getRegistry() *protoregistry.Files { | ||
var err error | ||
mergedRegistryOnce.Do(func() { | ||
mergedRegistry, err = proto.MergedRegistry() | ||
if err != nil { | ||
panic(err) | ||
} | ||
}) | ||
return mergedRegistry | ||
} | ||
|
||
func (l lazyProtoRegistry) FindFileByPath(s string) (protoreflect.FileDescriptor, error) { | ||
reg := getRegistry() | ||
return reg.FindFileByPath(s) | ||
} | ||
|
||
func (l lazyProtoRegistry) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error) { | ||
reg := getRegistry() | ||
return reg.FindDescriptorByName(name) | ||
} | ||
|
||
func (l lazyProtoRegistry) RangeFiles(f func(protoreflect.FileDescriptor) bool) { | ||
reg := getRegistry() | ||
reg.RangeFiles(f) | ||
} | ||
|
||
// MergedProtoRegistry returns a lazy loading wrapper around the global protobuf registry, a merged registry | ||
// containing both gogo proto and pulsar types. | ||
func MergedProtoRegistry() signing.ProtoFileResolver { | ||
return lazyProtoRegistry{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters