plugeth/core/forkid/plugin_hooks.go

38 lines
1.1 KiB
Go
Raw Normal View History

2023-10-10 22:26:47 +00:00
package forkid
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/plugins"
)
2023-10-24 00:25:52 +00:00
func PluginForkIDs(pl *plugins.PluginLoader, byBlock, byTime []uint64) ([]uint64, []uint64, bool) {
f, ok := plugins.LookupOne[func([]uint64, []uint64) ([]uint64, []uint64)](pl, "ForkIDs")
2023-10-10 22:26:47 +00:00
if !ok {
return nil, nil, false
}
2023-10-24 00:25:52 +00:00
pluginByBlock, pluginByTime := f(byBlock, byTime)
return pluginByBlock, pluginByTime, ok
// fnList := pl.Lookup("ForkIDs", func(item interface{}) bool {
// _, ok := item.(func([]uint64, []uint64) ([]uint64, []uint64))
// return ok
// })
// for _, fni := range fnList {
// if fn, ok := fni.(func([]uint64, []uint64) ([]uint64, []uint64)); ok {
// pluginByBlock, pluginByTime := fn(byBlock, byTime)
// return pluginByBlock, pluginByTime, true
// }
// }
2023-10-10 22:26:47 +00:00
2023-10-24 00:25:52 +00:00
// return nil, nil, false
2023-10-10 22:26:47 +00:00
}
2023-10-24 00:25:52 +00:00
func pluginForkIDs(byBlock, byTime []uint64) ([]uint64, []uint64, bool) {
2023-10-10 22:26:47 +00:00
if plugins.DefaultPluginLoader == nil {
log.Warn("Attempting PluginForkIDs, but default PluginLoader has not been initialized")
return nil, nil, false
}
2023-10-24 00:25:52 +00:00
return PluginForkIDs(plugins.DefaultPluginLoader, byBlock, byTime)
2023-10-10 22:26:47 +00:00
}