From f0ef135ce28b15d166a5a222db75292a604592fe Mon Sep 17 00:00:00 2001 From: Jesse Date: Fri, 1 Nov 2024 16:12:12 +0100 Subject: [PATCH] add pluginPeerEval injection to eth/downloader/queue.go --- eth/downloader/queue.go | 4 ++++ eth/downloader/xplugeth_hooks.go | 14 ++++++++++++++ internal/cli/server/xplugeth_imports.go | 6 ++---- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 eth/downloader/xplugeth_hooks.go diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index 25e7ed84d..5bb6a8577 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -720,6 +720,10 @@ func (q *queue) DeliverHeaders(id string, headers []*types.Header, hashes []comm q.lock.Lock() defer q.lock.Unlock() + //begin PluGeth code injection + pluginPeerEval(id, headers, hashes) + //end PluGeth code injection + var logger log.Logger if len(id) < 16 { // Tests use short IDs, don't choke on them diff --git a/eth/downloader/xplugeth_hooks.go b/eth/downloader/xplugeth_hooks.go new file mode 100644 index 000000000..63cffeca8 --- /dev/null +++ b/eth/downloader/xplugeth_hooks.go @@ -0,0 +1,14 @@ +package downloader + +import ( + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/openrelayxyz/xplugeth" + "github.com/openrelayxyz/xplugeth/hooks/blockchain" +) + +func pluginPeerEval(id string, headers []*types.Header, hashes []common.Hash) { + for _, m := range xplugeth.GetModules[blockchain.PeerEvalPlugin]() { + m.PeerEval(id, headers, hashes) + } +} diff --git a/internal/cli/server/xplugeth_imports.go b/internal/cli/server/xplugeth_imports.go index e0dc7a60a..9a84168dd 100644 --- a/internal/cli/server/xplugeth_imports.go +++ b/internal/cli/server/xplugeth_imports.go @@ -1,7 +1,5 @@ package server -// +build example_plugin - import ( - _ "github.com/openrelayxyz/xplugeth/plugins/example" -) \ No newline at end of file + _ "github.com/openrelayxyz/xplugeth/plugins/peerEval" +)