Skip to content
Snippets Groups Projects
Commit 7ba07788 authored by Jono Wenger's avatar Jono Wenger
Browse files

XX-2066 / Force usage of historical rounds

parent 1ffe1e06
No related branches found
No related tags found
No related merge requests found
...@@ -158,6 +158,8 @@ Flags: ...@@ -158,6 +158,8 @@ Flags:
-d, --destid string ID to send message to (if below 40, will be -d, --destid string ID to send message to (if below 40, will be
precanned. Use '0x' or 'b64:' for hex and precanned. Use '0x' or 'b64:' for hex and
base64 representations) (default "0") base64 representations) (default "0")
--forceHistoricalRounds Force all rounds to be sent to historical
round retrieval
-h, --help help for client -h, --help help for client
-l, --log string Path to the log output path (- is stdout) -l, --log string Path to the log output path (- is stdout)
(default "-") (default "-")
......
...@@ -212,7 +212,10 @@ func createClient() *api.Client { ...@@ -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 { if err != nil {
jww.FATAL.Panicf("%+v", err) jww.FATAL.Panicf("%+v", err)
} }
...@@ -225,8 +228,11 @@ func initClient() *api.Client { ...@@ -225,8 +228,11 @@ func initClient() *api.Client {
pass := viper.GetString("password") pass := viper.GetString("password")
storeDir := viper.GetString("session") storeDir := viper.GetString("session")
netParams := params.GetDefaultNetwork()
netParams.ForceHistoricalRounds = viper.GetBool("forceHistoricalRounds")
//load the client //load the client
client, err := api.Login(storeDir, []byte(pass), params.GetDefaultNetwork()) client, err := api.Login(storeDir, []byte(pass), netParams)
if err != nil { if err != nil {
jww.FATAL.Panicf("%+v", err) jww.FATAL.Panicf("%+v", err)
} }
...@@ -613,6 +619,11 @@ func init() { ...@@ -613,6 +619,11 @@ func init() {
"Accept the channel request for the corresponding recipient ID") "Accept the channel request for the corresponding recipient ID")
viper.BindPFlag("accept-channel", viper.BindPFlag("accept-channel",
rootCmd.Flags().Lookup("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. // initConfig reads in config file and ENV variables if set.
......
...@@ -12,22 +12,25 @@ import ( ...@@ -12,22 +12,25 @@ import (
) )
type Rounds struct { 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 // before giving up on it
MaxAttemptsCheckingARound uint MaxAttemptsCheckingARound uint
// number of historical rounds required to automatically send a historical // Number of historical rounds required to automatically send a historical
// rounds query // rounds query
MaxHistoricalRounds uint MaxHistoricalRounds uint
// maximum period of time a pending historical round query will wait before // Maximum period of time a pending historical round query will wait before
// it si transmitted // it is transmitted
HistoricalRoundsPeriod time.Duration HistoricalRoundsPeriod time.Duration
// number of worker threads for retreiving messages from gateways // Number of worker threads for retrieving messages from gateways
NumMessageRetrievalWorkers uint NumMessageRetrievalWorkers uint
// Length of historical rounds channel buffer // Length of historical rounds channel buffer
HistoricalRoundsBufferLen uint HistoricalRoundsBufferLen uint
// Length of round lookup channel buffer // Length of round lookup channel buffer
LookupRoundsBufferLen uint LookupRoundsBufferLen uint
// Toggles if historical rounds should always be used
ForceHistoricalRounds bool
} }
func GetDefaultRounds() Rounds { func GetDefaultRounds() Rounds {
...@@ -39,5 +42,6 @@ func GetDefaultRounds() Rounds { ...@@ -39,5 +42,6 @@ func GetDefaultRounds() Rounds {
HistoricalRoundsBufferLen: 1000, HistoricalRoundsBufferLen: 1000,
LookupRoundsBufferLen: 2000, LookupRoundsBufferLen: 2000,
ForceHistoricalRounds: false,
} }
} }
...@@ -63,13 +63,17 @@ func (m *Manager) Checker(roundID id.Round, filters []*bloom.Ring) bool { ...@@ -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 // Go get the round from the round infos, if it exists
ri, err := m.Instance.GetRound(roundID) 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) jww.DEBUG.Printf("HistoricalRound <- %d", roundID)
// If we didn't find it, send to Historical Rounds Retrieval // If we didn't find it, send to Historical Rounds Retrieval
m.historicalRounds <- roundID m.historicalRounds <- roundID
} else { } else {
jww.DEBUG.Printf("lookupRoundMessages <- %d", roundID) jww.DEBUG.Printf("lookupRoundMessages <- %d", roundID)
// IF found, send to Message Retrieval Workers // If found, send to Message Retrieval Workers
m.lookupRoundMessages <- ri m.lookupRoundMessages <- ri
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment