2023-06-12 16:52:46 +00:00
|
|
|
package ethconfig
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
|
|
|
"github.com/ethereum/go-ethereum/plugins"
|
2023-07-13 01:15:05 +00:00
|
|
|
// "github.com/ethereum/go-ethereum/plugins/wrappers"
|
2023-06-12 16:52:46 +00:00
|
|
|
wengine "github.com/ethereum/go-ethereum/plugins/wrappers/engine"
|
2023-07-13 01:15:05 +00:00
|
|
|
// "github.com/ethereum/go-ethereum/plugins/wrappers/backendwrapper"
|
|
|
|
// "github.com/openrelayxyz/plugeth-utils/core"
|
|
|
|
// "github.com/openrelayxyz/plugeth-utils/restricted"
|
2023-06-12 16:52:46 +00:00
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/consensus"
|
2023-07-13 01:15:05 +00:00
|
|
|
// "github.com/ethereum/go-ethereum/ethdb"
|
|
|
|
// "github.com/ethereum/go-ethereum/node"
|
2023-06-12 16:52:46 +00:00
|
|
|
|
|
|
|
pconsensus "github.com/openrelayxyz/plugeth-utils/restricted/consensus"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-13 01:15:05 +00:00
|
|
|
func PluginGetEngine(pl *plugins.PluginLoader) consensus.Engine {
|
2023-06-12 16:52:46 +00:00
|
|
|
fnList := pl.Lookup("CreateEngine", func(item interface{}) bool {
|
2023-07-13 01:15:05 +00:00
|
|
|
_, ok := item.(func() pconsensus.Engine)
|
2023-06-12 16:52:46 +00:00
|
|
|
return ok
|
|
|
|
})
|
|
|
|
for _, fni := range fnList {
|
2023-07-13 01:15:05 +00:00
|
|
|
if fn, ok := fni.(func() pconsensus.Engine); ok {
|
|
|
|
if engine := fn(); engine != nil {
|
2023-06-12 16:52:46 +00:00
|
|
|
wrappedEngine := wengine.NewWrappedEngine(engine)
|
|
|
|
return wrappedEngine
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-13 01:15:05 +00:00
|
|
|
func pluginGetEngine() consensus.Engine {
|
2023-06-12 16:52:46 +00:00
|
|
|
if plugins.DefaultPluginLoader == nil {
|
|
|
|
log.Warn("Attempting GetEngine, but default PluginLoader has not been initialized")
|
|
|
|
return nil
|
|
|
|
}
|
2023-07-13 01:15:05 +00:00
|
|
|
return PluginGetEngine(plugins.DefaultPluginLoader)
|
2023-06-12 16:52:46 +00:00
|
|
|
}
|