forked from cerc-io/plugeth
updated cmd/geth/plugin_hooks.go and plugins/plugin_loader.go to reflect changes re core.logger, updated go.mod and go.sum to address dependency issues
This commit is contained in:
+58
-58
@@ -1,80 +1,80 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/plugins"
|
||||
"github.com/ethereum/go-ethereum/plugins/wrappers"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/openrelayxyz/plugeth-utils/core"
|
||||
"github.com/openrelayxyz/plugeth-utils/restricted"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/plugins"
|
||||
"github.com/ethereum/go-ethereum/plugins/wrappers"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/openrelayxyz/plugeth-utils/core"
|
||||
"github.com/openrelayxyz/plugeth-utils/restricted"
|
||||
)
|
||||
|
||||
func apiTranslate(apis []core.API) []rpc.API {
|
||||
result := make([]rpc.API, len(apis))
|
||||
for i, api := range apis {
|
||||
result[i] = rpc.API{
|
||||
Namespace: api.Namespace,
|
||||
Version: api.Version,
|
||||
Service: api.Service,
|
||||
Public: api.Public,
|
||||
}
|
||||
}
|
||||
return result
|
||||
result := make([]rpc.API, len(apis))
|
||||
for i, api := range apis {
|
||||
result[i] = rpc.API{
|
||||
Namespace: api.Namespace,
|
||||
Version: api.Version,
|
||||
Service: api.Service,
|
||||
Public: api.Public,
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func GetAPIsFromLoader(pl *plugins.PluginLoader, stack *node.Node, backend restricted.Backend) []rpc.API {
|
||||
result := []core.API{}
|
||||
fnList := pl.Lookup("GetAPIs", func(item interface{}) bool {
|
||||
switch item.(type) {
|
||||
case func(core.Node, restricted.Backend) []core.API:
|
||||
return true
|
||||
case func(core.Node, core.Backend) []core.API:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
})
|
||||
for _, fni := range fnList {
|
||||
switch fn := fni.(type) {
|
||||
case func(core.Node, restricted.Backend) []core.API:
|
||||
result = append(result, fn(wrappers.NewNode(stack), backend)...)
|
||||
case func(core.Node, core.Backend) []core.API:
|
||||
result = append(result, fn(wrappers.NewNode(stack), backend)...)
|
||||
default:
|
||||
}
|
||||
}
|
||||
return apiTranslate(result)
|
||||
result := []core.API{}
|
||||
fnList := pl.Lookup("GetAPIs", func(item interface{}) bool {
|
||||
switch item.(type) {
|
||||
case func(core.Node, restricted.Backend) []core.API:
|
||||
return true
|
||||
case func(core.Node, core.Backend) []core.API:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
})
|
||||
for _, fni := range fnList {
|
||||
switch fn := fni.(type) {
|
||||
case func(core.Node, restricted.Backend) []core.API:
|
||||
result = append(result, fn(wrappers.NewNode(stack), backend)...)
|
||||
case func(core.Node, core.Backend) []core.API:
|
||||
result = append(result, fn(wrappers.NewNode(stack), backend)...)
|
||||
default:
|
||||
}
|
||||
}
|
||||
return apiTranslate(result)
|
||||
}
|
||||
|
||||
func pluginGetAPIs(stack *node.Node, backend restricted.Backend) []rpc.API {
|
||||
if plugins.DefaultPluginLoader == nil {
|
||||
log.Warn("Attempting GetAPIs, but default PluginLoader has not been initialized")
|
||||
return []rpc.API{}
|
||||
}
|
||||
}
|
||||
return GetAPIsFromLoader(plugins.DefaultPluginLoader, stack, backend)
|
||||
}
|
||||
|
||||
func InitializeNode(pl *plugins.PluginLoader, stack *node.Node, backend restricted.Backend) {
|
||||
fnList := pl.Lookup("InitializeNode", func(item interface{}) bool {
|
||||
switch item.(type) {
|
||||
case func(core.Logger, core.Node, restricted.Backend):
|
||||
return true
|
||||
case func(core.Logger, core.Node, core.Backend):
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
})
|
||||
for _, fni := range fnList {
|
||||
switch fn := fni.(type) {
|
||||
case func(core.Logger, core.Node, restricted.Backend):
|
||||
fn(log.Root(), wrappers.NewNode(stack), backend)
|
||||
case func(core.Logger, core.Node, core.Backend):
|
||||
fn(log.Root(), wrappers.NewNode(stack), backend)
|
||||
default:
|
||||
}
|
||||
}
|
||||
fnList := pl.Lookup("InitializeNode", func(item interface{}) bool {
|
||||
switch item.(type) {
|
||||
case func(core.Node, restricted.Backend):
|
||||
return true
|
||||
case func(core.Node, core.Backend):
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
})
|
||||
for _, fni := range fnList {
|
||||
switch fn := fni.(type) {
|
||||
case func(core.Node, restricted.Backend):
|
||||
fn(wrappers.NewNode(stack), backend)
|
||||
case func(core.Node, core.Backend):
|
||||
fn(wrappers.NewNode(stack), backend)
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func pluginsInitializeNode(stack *node.Node, backend restricted.Backend) {
|
||||
|
||||
Reference in New Issue
Block a user