From b93908ea09eccfca666201ae5b22b0f860fb448a Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 28 Nov 2024 09:50:57 +0100 Subject: [PATCH] plugins: add SetHooks struct --- plugins/interface.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/interface.go b/plugins/interface.go index b94a651b87..52e6fd6bec 100644 --- a/plugins/interface.go +++ b/plugins/interface.go @@ -19,6 +19,7 @@ package plugins import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state/snapshot" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/holiman/uint256" ) @@ -28,7 +29,7 @@ import ( // without modifying the chain logic. type Plugin interface { // Setup is called on startup when the Plugin is initialized. - Setup(chain Chain) + Setup(chain Chain, hooks SetHooks) // Close is called when the geth node is torn down. Close() // NewHead is called when a new head is set. @@ -76,3 +77,11 @@ type Account interface { // StorageIterator creates an iterator over the storage slots of an account. StorageIterator(seek common.Hash) snapshot.StorageIterator } + +// SetHooks allows the plugin to install hooks dynamically on the node. +type SetHooks struct { + // SetTracingHooks allows a plugin to set tracing hooks. + SetTracingHooks func(hooks *tracing.Hooks) + // In the future we could add hooks here for plugins to hook deeper into + // block production, adding hooks into the txpool, etc. +}