From 9ee93f1e26ec9a7a610a3a10bc39d522f64aa839 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Thu, 23 Mar 2023 21:59:14 -0700 Subject: [PATCH] further progress on plugin hook --- eth/ethconfig/plugin_hooks.go | 22 +++++++++++++++------- plugins/wrappers/engine/enginewrapper.go | 2 ++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/eth/ethconfig/plugin_hooks.go b/eth/ethconfig/plugin_hooks.go index f766d5f09..c4b9c0b26 100644 --- a/eth/ethconfig/plugin_hooks.go +++ b/eth/ethconfig/plugin_hooks.go @@ -6,8 +6,8 @@ import ( "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" + "github.com/openrelayxyz/plugeth-utils/core" + "github.com/openrelayxyz/plugeth-utils/restricted" // "github.com/ethereum/go-ethereum/common" "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 +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 { - fnList := pl.Lookup("GetEngine", func(item interface{}) bool { - _, ok := item.(func(*node.Node, []string, bool, ethdb.Database) consensus.Engine) + fnList := pl.Lookup("CreateEngine", func(item interface{}) bool { + _, ok := item.(func(*core.Node, []string, bool, restricted.Database) pconsensus.Engine) return ok }) for _, fni := range fnList { - if fn, ok := fni.(func(*node.Node, []string, bool, ethdb.Database)); ok { // modify - return fn(stack, notify, noverify, db) // modify + if fn, ok := fni.(func(*core.Node, []string, bool, restircted.Database)); ok { + 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 { diff --git a/plugins/wrappers/engine/enginewrapper.go b/plugins/wrappers/engine/enginewrapper.go index 61de2c8cf..dada9112d 100644 --- a/plugins/wrappers/engine/enginewrapper.go +++ b/plugins/wrappers/engine/enginewrapper.go @@ -17,6 +17,8 @@ import ( ptypes "github.com/openrelayxyz/plugeth-utils/restricted/types" pconsensus "github.com/openrelayxyz/plugeth-utils/restricted/consensus" pparams "github.com/openrelayxyz/plugeth-utils/restricted/params" + + philip "github.com/philip-morlier/butttruck" )