Updates to support blockupdates plugin

This makes several updates to support the blockupdates plugin.

I had to update several hooks that were using the wrong types, and
provide a way to get event.Feed objects into plugins without importing
event.Feed (which I did by having the plugin loader make them
available).
This commit is contained in:
Austin Roberts
2021-09-16 16:04:36 -05:00
parent 25af69b8e2
commit f7307d527d
4 changed files with 67 additions and 32 deletions
+3 -6
View File
@@ -104,7 +104,9 @@ func callbackifyChanPubSub(receiver, fn reflect.Value) *callback {
if !recvOK {
return
}
notifier.Notify(rpcSub.ID, val.Interface())
if err := notifier.Notify(rpcSub.ID, val.Interface()); err != nil {
log.Warn("Subscription notification failed", "id", rpcSub.ID, "err", err)
}
case 1:
cancel()
return
@@ -126,15 +128,10 @@ func pluginExtendedCallbacks(callbacks map[string]*callback, receiver reflect.Va
if method.PkgPath != "" {
continue // method not exported
}
if method.Name == "Timer" {
methodType := method.Func.Type()
log.Info("Timer method", "in", methodType.NumIn(), "out", methodType.NumOut(), "contextType", isContextType(methodType.In(1)), "chanType", isChanType(methodType.Out(0)), "chandir", methodType.Out(0).ChanDir() & reflect.RecvDir == reflect.RecvDir, "errorType", isErrorType(methodType.Out(1)))
}
if isChanPubsub(method.Type) {
cb := callbackifyChanPubSub(receiver, method.Func)
name := formatName(method.Name)
callbacks[name] = cb
log.Info("Added chanPubsub", "name", name, "args", cb.argTypes)
}
}
}