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:
-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 "-")
......
......@@ -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.
......
......@@ -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,
}
}
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment