From f66a36325c7996e5fb2ac55fdfae917a3c043772 Mon Sep 17 00:00:00 2001 From: WhoSoup <34172041+WhoSoup@users.noreply.github.com> Date: Tue, 6 Oct 2020 04:34:49 +0200 Subject: [PATCH] pass input regex from state to bmv (#1071) --- modules/debugsettings/settings.go | 2 +- simTest/MessageFilteringInput_test.go | 3 ++- state/state.go | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/debugsettings/settings.go b/modules/debugsettings/settings.go index 3032b4eb5f..73b58d8561 100644 --- a/modules/debugsettings/settings.go +++ b/modules/debugsettings/settings.go @@ -59,7 +59,7 @@ func (s *Settings) UpdateInputRegex(re string) error { return nil } -func (s *Settings) UpdateOuputRegex(re string) error { +func (s *Settings) UpdateOutputRegex(re string) error { v, err := regexp.Compile(re) if err != nil { return err diff --git a/simTest/MessageFilteringInput_test.go b/simTest/MessageFilteringInput_test.go index f0c85bb49a..22dbda14b0 100644 --- a/simTest/MessageFilteringInput_test.go +++ b/simTest/MessageFilteringInput_test.go @@ -1,10 +1,11 @@ package simtest import ( - "github.com/FactomProject/factomd/testHelper/simulation" "strings" "testing" + "github.com/FactomProject/factomd/testHelper/simulation" + "github.com/FactomProject/factomd/fnode" . "github.com/FactomProject/factomd/testHelper" diff --git a/state/state.go b/state/state.go index d20cb78858..5bbf3acf49 100644 --- a/state/state.go +++ b/state/state.go @@ -29,6 +29,7 @@ import ( "github.com/FactomProject/factomd/database/databaseOverlay" "github.com/FactomProject/factomd/database/leveldb" "github.com/FactomProject/factomd/database/mapdb" + "github.com/FactomProject/factomd/modules/debugsettings" "github.com/FactomProject/factomd/modules/events" "github.com/FactomProject/factomd/modules/pubsub" "github.com/FactomProject/factomd/modules/pubsub/pubregistry" @@ -2376,6 +2377,9 @@ func (s *State) PassOutputRegEx(RegEx *regexp.Regexp, RegExString string) { s.LogPrintf("networkOutputs", "SetOutputRegEx to '%s'", RegExString) s.OutputRegEx = RegEx s.OutputRegExString = RegExString + // this returns an error but the function that calls PassOutputRegEx already ran a + // .MustCompile on the string, so it will compile a second time + debugsettings.GetSettings(s.GetFactomNodeName()).UpdateOutputRegex(RegExString) } func (s *State) GetOutputRegEx() (*regexp.Regexp, string) { @@ -2386,6 +2390,9 @@ func (s *State) PassInputRegEx(RegEx *regexp.Regexp, RegExString string) { s.LogPrintf("networkInputs", "SetInputRegEx to '%s'", RegExString) s.InputRegEx = RegEx s.InputRegExString = RegExString + // this returns an error but the function that calls PassInputRegEx already ran a + // .MustCompile on the string, so it will compile a second time + debugsettings.GetSettings(s.GetFactomNodeName()).UpdateInputRegex(RegExString) } func (s *State) GetInputRegEx() (*regexp.Regexp, string) {