diff --git a/README.md b/README.md index 2af8550a96b3620559315f707a57d85f53e5000d..130ac9a67170d20fe8f416c347afccb66f113b22 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,8 @@ Flags: -d, --destid string ID to send message to (if below 40, will be precanned. Use '0x' or 'b64:' for hex and base64 representations) (default "0") + --forceHistoricalRounds Force all rounds to be sent to historical + round retrieval -h, --help help for client -l, --log string Path to the log output path (- is stdout) (default "-") diff --git a/cmd/root.go b/cmd/root.go index 216eac07878059ffb05e20b5f6d538036bc4b6e3..d2237d293ae4670f714f7717034170dae7b609b4 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -212,7 +212,10 @@ func createClient() *api.Client { } } - client, err := api.OpenClient(storeDir, []byte(pass), params.GetDefaultNetwork()) + netParams := params.GetDefaultNetwork() + netParams.ForceHistoricalRounds = viper.GetBool("forceHistoricalRounds") + + client, err := api.OpenClient(storeDir, []byte(pass), netParams) if err != nil { jww.FATAL.Panicf("%+v", err) } @@ -225,8 +228,11 @@ func initClient() *api.Client { pass := viper.GetString("password") storeDir := viper.GetString("session") + netParams := params.GetDefaultNetwork() + netParams.ForceHistoricalRounds = viper.GetBool("forceHistoricalRounds") + //load the client - client, err := api.Login(storeDir, []byte(pass), params.GetDefaultNetwork()) + client, err := api.Login(storeDir, []byte(pass), netParams) if err != nil { jww.FATAL.Panicf("%+v", err) } @@ -613,6 +619,11 @@ func init() { "Accept the channel request for the corresponding recipient ID") viper.BindPFlag("accept-channel", rootCmd.Flags().Lookup("accept-channel")) + + rootCmd.Flags().BoolP("forceHistoricalRounds", "", false, + "Force all rounds to be sent to historical round retrieval") + viper.BindPFlag("forceHistoricalRounds", + rootCmd.Flags().Lookup("forceHistoricalRounds")) } // initConfig reads in config file and ENV variables if set. diff --git a/interfaces/params/rounds.go b/interfaces/params/rounds.go index 483e6872101ceee68e329173a09c92b0790886c9..dbf0d5a00fdbb07ad813244f75f84eda34ddcd57 100644 --- a/interfaces/params/rounds.go +++ b/interfaces/params/rounds.go @@ -12,22 +12,25 @@ import ( ) type Rounds struct { - // maximum number of times to attempt to retrieve a round from a gateway + // Maximum number of times to attempt to retrieve a round from a gateway // before giving up on it MaxAttemptsCheckingARound uint - // number of historical rounds required to automatically send a historical + // Number of historical rounds required to automatically send a historical // rounds query MaxHistoricalRounds uint - // maximum period of time a pending historical round query will wait before - // it si transmitted + // Maximum period of time a pending historical round query will wait before + // it is transmitted HistoricalRoundsPeriod time.Duration - // number of worker threads for retreiving messages from gateways + // Number of worker threads for retrieving messages from gateways NumMessageRetrievalWorkers uint - //Length of historical rounds channel buffer + // Length of historical rounds channel buffer HistoricalRoundsBufferLen uint - //Length of round lookup channel buffer + // Length of round lookup channel buffer LookupRoundsBufferLen uint + + // Toggles if historical rounds should always be used + ForceHistoricalRounds bool } func GetDefaultRounds() Rounds { @@ -39,5 +42,6 @@ func GetDefaultRounds() Rounds { HistoricalRoundsBufferLen: 1000, LookupRoundsBufferLen: 2000, + ForceHistoricalRounds: false, } } diff --git a/network/rounds/check.go b/network/rounds/check.go index 72d31bed5d1840f6d2b5f7b00f8b24607a7963a8..ae78be465f7f03b968641cd290cdd7b259dcd2c1 100644 --- a/network/rounds/check.go +++ b/network/rounds/check.go @@ -63,13 +63,17 @@ func (m *Manager) Checker(roundID id.Round, filters []*bloom.Ring) bool { // Go get the round from the round infos, if it exists ri, err := m.Instance.GetRound(roundID) - if err != nil { + if err != nil || m.params.ForceHistoricalRounds { + if m.params.ForceHistoricalRounds { + jww.WARN.Printf("Forcing use of historical rounds for round ID %d.", + roundID) + } jww.DEBUG.Printf("HistoricalRound <- %d", roundID) // If we didn't find it, send to Historical Rounds Retrieval m.historicalRounds <- roundID } else { jww.DEBUG.Printf("lookupRoundMessages <- %d", roundID) - // IF found, send to Message Retrieval Workers + // If found, send to Message Retrieval Workers m.lookupRoundMessages <- ri }