Add error to login signal (#1594)
We add an error to login signal so that the caller can tell whether login was successful or not
This commit is contained in:
parent
4ef35fa1bc
commit
42199e682f
|
@ -237,7 +237,7 @@ func (b *StatusBackend) StartNodeWithKey(acc multiaccounts.Account, password str
|
||||||
return b.injectAccountIntoServices()
|
return b.injectAccountIntoServices()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *StatusBackend) StartNodeWithAccount(acc multiaccounts.Account, password string) error {
|
func (b *StatusBackend) startNodeWithAccount(acc multiaccounts.Account, password string) error {
|
||||||
err := b.ensureAppDBOpened(acc, password)
|
err := b.ensureAppDBOpened(acc, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -280,10 +280,19 @@ func (b *StatusBackend) StartNodeWithAccount(acc multiaccounts.Account, password
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
signal.SendLoggedIn()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *StatusBackend) StartNodeWithAccount(acc multiaccounts.Account, password string) error {
|
||||||
|
err := b.startNodeWithAccount(acc, password)
|
||||||
|
signal.SendLoggedIn(err)
|
||||||
|
if err != nil {
|
||||||
|
// Stop node for clean up
|
||||||
|
_ = b.StopNode()
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// StartNodeWithAccountAndConfig is used after account and config was generated.
|
// StartNodeWithAccountAndConfig is used after account and config was generated.
|
||||||
// In current setup account name and config is generated on the client side. Once/if it will be generated on
|
// In current setup account name and config is generated on the client side. Once/if it will be generated on
|
||||||
// status-go side this flow can be simplified.
|
// status-go side this flow can be simplified.
|
||||||
|
|
|
@ -26,6 +26,11 @@ type NodeCrashEvent struct {
|
||||||
Error string `json:"error"`
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NodeLoginEvent returns the result of the login event
|
||||||
|
type NodeLoginEvent struct {
|
||||||
|
Error string `json:"error,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// SendNodeCrashed emits a signal when status node has crashed, and
|
// SendNodeCrashed emits a signal when status node has crashed, and
|
||||||
// provides error description.
|
// provides error description.
|
||||||
func SendNodeCrashed(err error) {
|
func SendNodeCrashed(err error) {
|
||||||
|
@ -57,6 +62,10 @@ func SendChainDataRemoved() {
|
||||||
send(EventChainDataRemoved, nil)
|
send(EventChainDataRemoved, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendLoggedIn() {
|
func SendLoggedIn(err error) {
|
||||||
send(EventLoggedIn, nil)
|
event := NodeLoginEvent{}
|
||||||
|
if err != nil {
|
||||||
|
event.Error = err.Error()
|
||||||
|
}
|
||||||
|
send(EventLoggedIn, event)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue