-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move retry config out of reporter so its accessible by other clients #78
Move retry config out of reporter so its accessible by other clients #78
Conversation
04e571e
to
011bdce
Compare
While this PR is still WIP, one comment is to make retry config (and other potential ones in the future) a part of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Finally we can merge all redundant configs in different modules to CommonConfig
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Added some comments related to refactoring (and some others that are not entirely related to this PR, we can create another one to address those or do that here, your call):
config/common.go
Outdated
// CommonConfig defines the server's basic configuration | ||
type CommonConfig struct { | ||
// Backoff interval for the first retry. | ||
RetrySleepTime string `mapstructure:"retry-sleep-time"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some configuration entries are parseable time strings, while others are name-denomination
(e.g. resend-interval-seconds
). We should decide on the format that we want to use and stick to that for everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we can make it consistent. Should I change all of them to strings? As this involves submitter also, I will probably do this in a separate PR. cc @gitferry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Is the format that we want to stick with the one that you have here or the name-denomination
one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem with me and ok with this happening on another PR or here. In this PR we should make sure that we use the final version.
@vitsalis I have added suggested fixes in this PR now, feel free to review it again. Here is the summary of issues and fixes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work, much cleaner! Some very very minor comments, but I'm ok with most of them not happening.
return err | ||
} | ||
if cfg.BlockTimeout < 0 { | ||
return errors.New("block-timeout can't be negative") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BlockTimeout
is not being used anywhere in the code but it exists in the config so I think it's fine to keep it 0sec as of now.
@@ -46,7 +51,7 @@ func DefaultBTCConfig() BTCConfig { | |||
WalletCAFile: defaultBtcWalletCAFile, | |||
WalletLockTime: 10, | |||
TxFee: feeAmount, | |||
NetParams: "simnet", | |||
NetParams: types.BtcSimnet.String(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
reporter/reporter.go
Outdated
return nil, err | ||
} | ||
|
||
func New(cfg *config.ReporterConfig, btcClient *btcclient.Client, babylonClient *babylonclient.Client, retrySleepTime, maxRetrySleepTime time.Duration) (*Reporter, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe split this line since it's getting too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -27,7 +28,7 @@ babylon: | |||
key-directory: $TESTNET_PATH/node0/babylond | |||
debug: true | |||
timeout: 20s | |||
block-timeout: "" | |||
block-timeout: ~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a placeholder for an empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block-timeout is a time duration, so it can't be a string. ~ is null value so by default while parsing it will parse it as 0 sec
@@ -5,6 +5,18 @@ import ( | |||
"github.com/btcsuite/btcd/wire" | |||
) | |||
|
|||
type SupportedBtcNetwork string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@@ -17,3 +29,13 @@ func GetWrappedTxs(msg *wire.MsgBlock) []*btcutil.Tx { | |||
|
|||
return btcTxs | |||
} | |||
|
|||
func GetValidNetParams() map[string]bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this function is only used for an existence check, why do we abstract this existence check behind a function that returns a map and this map is being used to check for inclusion? No problem with it if it matches your style.
Co-authored-by: Vitalis Salis <[email protected]>
Fixes BM-199
Retry config is part of Reporter as of now due to which Babylon and BTC client can't access config params. This PR moves Retry in common config which will be accessible by all clients.