plugeth/core/forkid/plugin_hooks.go

26 lines
737 B
Go
Raw Permalink 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
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
}