Skip to content

Commit

Permalink
unforgiving errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGruffins committed Jul 23, 2019
1 parent 24631dd commit 3d926d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
6 changes: 1 addition & 5 deletions backend/stakepoold/rpc/rpcserver/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,10 @@ func (ctx *AppContext) MyMasterPubKeys() (map[string]string, error) {
}
key, err := ctx.WalletConnection.GetMasterPubkey(acct, ctx.Params)
if err != nil {
log.Errorf("MyMasterPubKeys: GetMasterPubKey rpc failed: %v", err)
continue
return nil, fmt.Errorf("MyMasterPubKeys: GetMasterPubKey rpc failed: %v", err)
}
keyMap[acct] = key.String()
}
if len(keyMap) == 0 {
return nil, errors.New("MyMasterPubKeys: found no master extended public keys")
}
return keyMap, nil
}

Expand Down
10 changes: 3 additions & 7 deletions stakepooldclient/stakepooldclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,16 +500,15 @@ func (s *StakepooldManager) RPCStatus() []string {
}

// MyMasterPubKeys performs gRPC MasterPubKeys requests against all stakepoold
// instances and returns all results fetched without errors. Returns a map of keys
// to accounts or an error if no keys were found.
// instances and returns a map of keys to accounts or an error if any
// of the gRPC calls failed
func (s *StakepooldManager) MyMasterPubKeys() (map[string]string, error) {
pubKeyMap := make(map[string]string)
for i, conn := range s.grpcConnections {
client := pb.NewStakepooldServiceClient(conn)
resp, err := client.MyMasterPubKeys(context.Background(), &pb.MyMasterPubKeysRequest{})
if err != nil {
log.Warnf("GetMasterPubkeys gRPC failed on stakepoold instance %d: %v", i, err)
continue
return nil, fmt.Errorf("GetMasterPubkeys gRPC failed on stakepoold instance %d: %v", i, err)
}
for _, pubKey := range resp.MasterPubKeys {
// all public keys for the default account must be the same
Expand All @@ -519,9 +518,6 @@ func (s *StakepooldManager) MyMasterPubKeys() (map[string]string, error) {
pubKeyMap[pubKey.Account] = pubKey.PubKey
}
}
if len(pubKeyMap) == 0 {
return nil, errors.New("found no master extended public keys on any stakepoold instances")
}
for k, v := range pubKeyMap {
log.Infof("found master extended pubkey %s for account \"%s\"", v, k)
}
Expand Down

0 comments on commit 3d926d1

Please sign in to comment.