Skip to content
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

retry sending specific messages #4969

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion api/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func buildWalletConfig(request *requests.WalletSecretsConfig) params.WalletConfi
return walletConfig
}

func defaultNodeConfig(installationID string, request *requests.CreateAccount) (*params.NodeConfig, error) {
func defaultNodeConfig(installationID string, request *requests.CreateAccount, opts ...params.Option) (*params.NodeConfig, error) {
// Set mainnet
nodeConfig := &params.NodeConfig{}
nodeConfig.LogEnabled = request.LogEnabled
Expand Down Expand Up @@ -335,6 +335,12 @@ func defaultNodeConfig(installationID string, request *requests.CreateAccount) (
nodeConfig.APIModules = request.APIConfig.APIModules
}

for _, opt := range opts {
if err := opt(nodeConfig); err != nil {
return nil, err
}
}

return nodeConfig, nil
}

Expand Down
10 changes: 6 additions & 4 deletions api/geth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ func (b *GethStatusBackend) GetKeyUIDByMnemonic(mnemonic string) (string, error)
return info.KeyUID, nil
}

func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizationColorClock uint64, fetchBackup bool, request *requests.CreateAccount) (*multiaccounts.Account, error) {
func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizationColorClock uint64, fetchBackup bool, request *requests.CreateAccount, opts ...params.Option) (*multiaccounts.Account, error) {
keystoreDir := keystoreRelativePath

b.UpdateRootDataDir(request.BackupDisabledDataDir)
Expand Down Expand Up @@ -1406,7 +1406,7 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
//settings.MnemonicWasNotShown = true
}

nodeConfig, err := defaultNodeConfig(settings.InstallationID, request)
nodeConfig, err := defaultNodeConfig(settings.InstallationID, request, opts...)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1454,14 +1454,16 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
return &account, nil
}

func (b *GethStatusBackend) CreateAccountAndLogin(request *requests.CreateAccount) (*multiaccounts.Account, error) {
// CreateAccountAndLogin creates a new account and logs in with it.
// NOTE: requests.CreateAccount is used for public, params.Option maybe used for internal usage.
func (b *GethStatusBackend) CreateAccountAndLogin(request *requests.CreateAccount, opts ...params.Option) (*multiaccounts.Account, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this changes expected here? I remember I added opts and later removed it.
Then this PR reintroduce it, and I don't see anywhere is using it. @qfrank

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kaichaosun , it's been used here

validation := &requests.CreateAccountValidation{
AllowEmptyDisplayName: false,
}
if err := request.Validate(validation); err != nil {
return nil, err
}
return b.generateOrImportAccount("", 1, false, request)
return b.generateOrImportAccount("", 1, false, request, opts...)
}

func (b *GethStatusBackend) ConvertToRegularAccount(mnemonic string, currPassword string, newPassword string) error {
Expand Down