From 5be3014e0bf045822cd1f2c614baf5659b046506 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Thu, 28 Sep 2023 12:34:38 -0700 Subject: [PATCH] Added first etc hook into test plugin --- cmd/utils/flags.go | 18 +++++++----------- plugins/test-plugin/hooks.go | 16 +++++++++++++--- plugins/test-plugin/main.go | 14 ++++++++------ 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 5e99b9a87..3925bf38d 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -95,12 +95,6 @@ var ( Value: flags.DirectoryString(filepath.Join("", "plugins")), Category: flags.EthCategory, } - // ClassicFlag = &cli.BoolFlag{ - // Name: "Classic", - // Usage: "Sepolia network: pre-configured proof-of-work test network", - // Category: flags.EthCategory, - // } - //end PluGeth code injection DataDirFlag = &flags.DirectoryFlag{ Name: "datadir", @@ -1671,11 +1665,13 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if pluginNetworkId := pluginNetworkId(); pluginNetworkId != nil { cfg.NetworkId = *pluginNetworkId } - if pluginETHDiscoveryURLs := pluginETHDiscoveryURLs(); pluginETHDiscoveryURLs != nil { - cfg.EthDiscoveryURLs = pluginETHDiscoveryURLs - } - if pluginSnapDiscoveryURLs := pluginSnapDiscoveryURLs(); pluginSnapDiscoveryURLs != nil { - cfg.SnapDiscoveryURLs = pluginSnapDiscoveryURLs + if cfg.EthDiscoveryURLs == nil { + var lightMode bool + if cfg.SyncMode == downloader.LightSync { + lightMode = true + } + cfg.EthDiscoveryURLs := pluginETHDiscoveryURLs(lightMode) { + cfg.SnapDiscoveryURLs := pluginSnapDiscoveryURLs() } //end PluGeth injection diff --git a/plugins/test-plugin/hooks.go b/plugins/test-plugin/hooks.go index 7667c616d..950339da8 100644 --- a/plugins/test-plugin/hooks.go +++ b/plugins/test-plugin/hooks.go @@ -41,6 +41,15 @@ func GetAPIs(stack core.Node, backend core.Backend) []core.API { // this injection is covered by another test in this package. See documentation for details. // } +// cmd/utils/ + +func SetSnapDiscoveryURLs() { + m := map[string]struct{}{ + "SetSnapDiscoveryURLs":struct{}{}, + } + hookChan <- m +} + // core/ @@ -176,12 +185,13 @@ var plugins map[string]struct{} = map[string]struct{}{ "LivePostProcessBlock": struct{}{}, "LiveCaptureStart": struct{}{}, "LiveCaptureState": struct{}{}, + "LiveCaptureEnd": struct{}{}, + "PreTrieCommit": struct{}{}, + "PostTrieCommit": struct{}{}, // "LiveCaptureFault": struct{}{}, // "LiveCaptureEnter": struct{}{}, // "LiveCaptureExit": struct{}{}, // "LiveTracerResult": struct{}{}, - "LiveCaptureEnd": struct{}{}, - "PreTrieCommit": struct{}{}, - "PostTrieCommit": struct{}{}, + "SetSnapDiscoveryURLs": struct{}{}, } diff --git a/plugins/test-plugin/main.go b/plugins/test-plugin/main.go index bd6cd6a06..f78a66fcd 100644 --- a/plugins/test-plugin/main.go +++ b/plugins/test-plugin/main.go @@ -101,6 +101,12 @@ func BlockChain() { delete(plugins, "LiveCaptureStart") case f("LiveCaptureState"): delete(plugins, "LiveCaptureState") + case f("LiveCaptureEnd"): + delete(plugins, "LiveCaptureEnd") + case f("PreTrieCommit"): + delete(plugins, "PreTrieCommit") + case f("PostTrieCommit"): + delete(plugins, "PostTrieCommit") // These methods are not covered by tests at this time // case f("LiveCaptureFault"): // delete(plugins, "LiveCaptureFault") @@ -110,12 +116,8 @@ func BlockChain() { // delete(plugins, "LiveCaptureExit") // case f("LiveTracerResult"): // delete(plugins, "LiveTracerResult") - case f("LiveCaptureEnd"): - delete(plugins, "LiveCaptureEnd") - case f("PreTrieCommit"): - delete(plugins, "PreTrieCommit") - case f("PostTrieCommit"): - delete(plugins, "PostTrieCommit") + case f("SetSnapDiscoveryURLs"): + delete(plugins, "SetSnapDiscoveryURLs") } } }