type correction in trei hoppks, adjusting length condition in core hooks

This commit is contained in:
philip-morlier 2023-03-08 11:37:28 -08:00
parent e2c33f60c4
commit 3527a74333
2 changed files with 31 additions and 10 deletions

View File

@ -306,7 +306,7 @@ func PluginSetTrieFlushIntervalClone(pl *plugins.PluginLoader, flushInterval tim
return ok return ok
}) })
var snc sync.Once var snc sync.Once
if len(fnList) > 0 { if len(fnList) > 1 {
snc.Do(func() {log.Warn("The blockChain flushInterval value is being accessed by multiple plugins")}) snc.Do(func() {log.Warn("The blockChain flushInterval value is being accessed by multiple plugins")})
} }
for _, fni := range fnList { for _, fni := range fnList {

View File

@ -4,21 +4,22 @@ import (
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/plugins" "github.com/ethereum/go-ethereum/plugins"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/openrelayxyz/plugeth-utils/core"
) )
func PluginPreTrieCommit(pl *plugins.PluginLoader, node common.Hash) { func PluginPreTrieCommit(pl *plugins.PluginLoader, node common.Hash) {
fnList := pl.Lookup("PreTrieCommit", func(item interface{}) bool { fnList := pl.Lookup("PreTrieCommit", func(item interface{}) bool {
_, ok := item.(func(common.Hash)) _, ok := item.(func(core.Hash))
return ok return ok
}) })
for _, fni := range fnList { for _, fni := range fnList {
if fn, ok := fni.(func(common.Hash)); ok { if fn, ok := fni.(func(core.Hash)); ok {
fn(node) fn(core.Hash(node))
} }
} }
} }
func pluginPreTrieCommit(node common.Hash,) { func pluginPreTrieCommit(node common.Hash) {
if plugins.DefaultPluginLoader == nil { if plugins.DefaultPluginLoader == nil {
log.Warn("Attempting PreTrieCommit, but default PluginLoader has not been initialized") log.Warn("Attempting PreTrieCommit, but default PluginLoader has not been initialized")
return return
@ -28,20 +29,40 @@ func pluginPreTrieCommit(node common.Hash,) {
func PluginPostTrieCommit(pl *plugins.PluginLoader, node common.Hash) { func PluginPostTrieCommit(pl *plugins.PluginLoader, node common.Hash) {
fnList := pl.Lookup("PostTrieCommit", func(item interface{}) bool { fnList := pl.Lookup("PostTrieCommit", func(item interface{}) bool {
_, ok := item.(func(common.Hash)) _, ok := item.(func(core.Hash))
return ok return ok
}) })
for _, fni := range fnList { for _, fni := range fnList {
if fn, ok := fni.(func(common.Hash)); ok { if fn, ok := fni.(func(core.Hash)); ok {
fn(node) fn(core.Hash(node))
} }
} }
} }
func pluginPostTrieCommit(node common.Hash,) { func pluginPostTrieCommit(node common.Hash) {
if plugins.DefaultPluginLoader == nil { if plugins.DefaultPluginLoader == nil {
log.Warn("Attempting PostTrieCommit, but default PluginLoader has not been initialized") log.Warn("Attempting PostTrieCommit, but default PluginLoader has not been initialized")
return return
} }
PluginPostTrieCommit(plugins.DefaultPluginLoader, node) PluginPostTrieCommit(plugins.DefaultPluginLoader, node)
} }
// func PluginGetRPCCalls(pl *plugins.PluginLoader, id, method, params string) {
// fnList := pl.Lookup("GetRPCCalls", func(item interface{}) bool {
// _, ok := item.(func(string, string, string))
// return ok
// })
// for _, fni := range fnList {
// if fn, ok := fni.(func(string, string, string)); ok {
// fn(id, method, params)
// }
// }
// }
// func pluginGetRPCCalls(id, method, params string) {
// if plugins.DefaultPluginLoader == nil {
// log.Warn("Attempting GerRPCCalls, but default PluginLoader has not been initialized")
// return
// }
// PluginGetRPCCalls(plugins.DefaultPluginLoader, id, method, params)
// }