further progress on plugin hook

This commit is contained in:
philip-morlier 2023-03-23 21:59:14 -07:00
parent d2d3490abc
commit 9ee93f1e26
2 changed files with 17 additions and 7 deletions

View File

@ -6,8 +6,8 @@ import (
"github.com/ethereum/go-ethereum/plugins" "github.com/ethereum/go-ethereum/plugins"
// "github.com/ethereum/go-ethereum/plugins/wrappers" // "github.com/ethereum/go-ethereum/plugins/wrappers"
// "github.com/ethereum/go-ethereum/rpc" // "github.com/ethereum/go-ethereum/rpc"
// "github.com/openrelayxyz/plugeth-utils/core" "github.com/openrelayxyz/plugeth-utils/core"
// "github.com/openrelayxyz/plugeth-utils/restricted" "github.com/openrelayxyz/plugeth-utils/restricted"
// "github.com/ethereum/go-ethereum/common" // "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/consensus"
@ -30,17 +30,25 @@ import (
// stack *node.Node, ethashConfig *ethash.Config, cliqueConfig *params.CliqueConfig, notify []string, noverify bool, db ethdb.Database) consensus.Engine // stack *node.Node, ethashConfig *ethash.Config, cliqueConfig *params.CliqueConfig, notify []string, noverify bool, db ethdb.Database) consensus.Engine
func engineTranslate(engine pconsensus.Engine) consensus.Engine {
result consensus.Engine{
}
return result
}
func PluginGetEngine(pl *plugins.PluginLoader, stack *node.Node, notify []string, noverify bool, db ethdb.Database) consensus.Engine { func PluginGetEngine(pl *plugins.PluginLoader, stack *node.Node, notify []string, noverify bool, db ethdb.Database) consensus.Engine {
fnList := pl.Lookup("GetEngine", func(item interface{}) bool { fnList := pl.Lookup("CreateEngine", func(item interface{}) bool {
_, ok := item.(func(*node.Node, []string, bool, ethdb.Database) consensus.Engine) _, ok := item.(func(*core.Node, []string, bool, restricted.Database) pconsensus.Engine)
return ok return ok
}) })
for _, fni := range fnList { for _, fni := range fnList {
if fn, ok := fni.(func(*node.Node, []string, bool, ethdb.Database)); ok { // modify if fn, ok := fni.(func(*core.Node, []string, bool, restircted.Database)); ok {
return fn(stack, notify, noverify, db) // modify engine := fn(wrappers.NewNode(stack), notify, noverify, db) // modify
} }
} }
return nil return engineTranslate(engine)
} }
func pluginGetEngine(stack *node.Node, notify []string, noverify bool, db ethdb.Database) consensus.Engine { func pluginGetEngine(stack *node.Node, notify []string, noverify bool, db ethdb.Database) consensus.Engine {

View File

@ -17,6 +17,8 @@ import (
ptypes "github.com/openrelayxyz/plugeth-utils/restricted/types" ptypes "github.com/openrelayxyz/plugeth-utils/restricted/types"
pconsensus "github.com/openrelayxyz/plugeth-utils/restricted/consensus" pconsensus "github.com/openrelayxyz/plugeth-utils/restricted/consensus"
pparams "github.com/openrelayxyz/plugeth-utils/restricted/params" pparams "github.com/openrelayxyz/plugeth-utils/restricted/params"
philip "github.com/philip-morlier/butttruck"
) )