-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR #245: Breakup oversize relay msgs
- Loading branch information
1 parent
672917a
commit 39360aa
Showing
7 changed files
with
184 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/iqlusioninc/relayer/relayer" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// GetStrategyWithOptions sets strategy specific fields. | ||
func GetStrategyWithOptions(cmd *cobra.Command, strategy relayer.Strategy) (relayer.Strategy, error) { | ||
switch strategy.GetType() { | ||
case (&relayer.NaiveStrategy{}).GetType(): | ||
ns, ok := strategy.(*relayer.NaiveStrategy) | ||
if !ok { | ||
return strategy, fmt.Errorf("strategy.GetType() returns naive, but strategy type (%T) is not type NaiveStrategy", strategy) | ||
|
||
} | ||
|
||
maxTxSize, err := cmd.Flags().GetString(flagMaxTxSize) | ||
if err != nil { | ||
return ns, err | ||
} | ||
|
||
txSize, err := strconv.ParseUint(maxTxSize, 10, 64) | ||
if err != nil { | ||
return ns, err | ||
} | ||
|
||
// set max size of messages in a relay transaction | ||
ns.MaxTxSize = txSize * MB // in MB | ||
|
||
maxMsgLength, err := cmd.Flags().GetString(flagMaxMsgLength) | ||
if err != nil { | ||
return ns, err | ||
} | ||
|
||
msgLen, err := strconv.ParseUint(maxMsgLength, 10, 64) | ||
if err != nil { | ||
return ns, err | ||
} | ||
|
||
// set max length messages in relay transaction | ||
ns.MaxMsgLength = msgLen | ||
|
||
return ns, nil | ||
default: | ||
return strategy, nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters