2023-03-08 17:59:47 +00:00
|
|
|
package trie
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
|
|
|
"github.com/ethereum/go-ethereum/plugins"
|
2023-03-08 18:10:52 +00:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2023-03-08 19:37:28 +00:00
|
|
|
"github.com/openrelayxyz/plugeth-utils/core"
|
2023-03-08 17:59:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func PluginPreTrieCommit(pl *plugins.PluginLoader, node common.Hash) {
|
|
|
|
fnList := pl.Lookup("PreTrieCommit", func(item interface{}) bool {
|
2023-03-08 19:37:28 +00:00
|
|
|
_, ok := item.(func(core.Hash))
|
2023-03-08 17:59:47 +00:00
|
|
|
return ok
|
|
|
|
})
|
|
|
|
for _, fni := range fnList {
|
2023-03-08 19:37:28 +00:00
|
|
|
if fn, ok := fni.(func(core.Hash)); ok {
|
|
|
|
fn(core.Hash(node))
|
2023-03-08 17:59:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-08 19:37:28 +00:00
|
|
|
func pluginPreTrieCommit(node common.Hash) {
|
2023-03-08 17:59:47 +00:00
|
|
|
if plugins.DefaultPluginLoader == nil {
|
|
|
|
log.Warn("Attempting PreTrieCommit, but default PluginLoader has not been initialized")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
PluginPreTrieCommit(plugins.DefaultPluginLoader, node)
|
|
|
|
}
|
|
|
|
|
|
|
|
func PluginPostTrieCommit(pl *plugins.PluginLoader, node common.Hash) {
|
|
|
|
fnList := pl.Lookup("PostTrieCommit", func(item interface{}) bool {
|
2023-03-08 19:37:28 +00:00
|
|
|
_, ok := item.(func(core.Hash))
|
2023-03-08 17:59:47 +00:00
|
|
|
return ok
|
|
|
|
})
|
|
|
|
for _, fni := range fnList {
|
2023-03-08 19:37:28 +00:00
|
|
|
if fn, ok := fni.(func(core.Hash)); ok {
|
|
|
|
fn(core.Hash(node))
|
2023-03-08 17:59:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-08 19:37:28 +00:00
|
|
|
func pluginPostTrieCommit(node common.Hash) {
|
2023-03-08 17:59:47 +00:00
|
|
|
if plugins.DefaultPluginLoader == nil {
|
|
|
|
log.Warn("Attempting PostTrieCommit, but default PluginLoader has not been initialized")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
PluginPostTrieCommit(plugins.DefaultPluginLoader, node)
|
2023-03-08 19:37:28 +00:00
|
|
|
}
|