Merge pull request #78 from cerc-io/fix-subscription-methods

Fix subscription method registration
This commit is contained in:
Philip Morlier 2023-06-14 09:44:27 -07:00 committed by GitHub
commit 366f480bc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -18,7 +18,7 @@ import (
type Subcommand func(core.Context, []string) error type Subcommand func(core.Context, []string) error
type pluginDetails struct { type pluginDetails struct {
p *plugin.Plugin p *plugin.Plugin
name string name string
} }
@ -72,12 +72,12 @@ func NewPluginLoader(target string) (*PluginLoader, error) {
for _, file := range files { for _, file := range files {
fpath := path.Join(target, file.Name()) fpath := path.Join(target, file.Name())
if !strings.HasSuffix(file.Name(), ".so") { if !strings.HasSuffix(file.Name(), ".so") {
log.Debug("File inplugin directory is not '.so' file. Skipping.", "file", fpath) log.Debug("File in plugin directory is not '.so' file. Skipping.", "file", fpath)
continue continue
} }
plug, err := plugin.Open(fpath) plug, err := plugin.Open(fpath)
if err != nil { if err != nil {
log.Warn("File in plugin directory could not be loaded: %v", "file", fpath, "error", err.Error()) log.Warn("File in plugin directory could not be loaded", "file", fpath, "error", err)
continue continue
} }
// Any type of plugin can potentially specify flags // Any type of plugin can potentially specify flags

View File

@ -63,6 +63,9 @@ func (r *serviceRegistry) registerName(name string, rcvr interface{}) error {
return fmt.Errorf("no service name for type %s", rcvrVal.Type().String()) return fmt.Errorf("no service name for type %s", rcvrVal.Type().String())
} }
callbacks := suitableCallbacks(rcvrVal) callbacks := suitableCallbacks(rcvrVal)
// begin PluGeth code injection
pluginExtendedCallbacks(callbacks, rcvrVal)
// end PluGeth code injection
if len(callbacks) == 0 { if len(callbacks) == 0 {
return fmt.Errorf("service %T doesn't have any suitable methods/subscriptions to expose", rcvr) return fmt.Errorf("service %T doesn't have any suitable methods/subscriptions to expose", rcvr)
} }