Process credentials for correctness: remove duplicate and unknown methods. In case of duplicate methods only the first one satisfying valueRequired is kept. If valueRequired is true, keep only those where Value is non-empty.
(creds []MsgCredClient, valueRequired bool)
| 117 | // In case of duplicate methods only the first one satisfying valueRequired is kept. |
| 118 | // If valueRequired is true, keep only those where Value is non-empty. |
| 119 | func normalizeCredentials(creds []MsgCredClient, valueRequired bool) []MsgCredClient { |
| 120 | if len(creds) == 0 { |
| 121 | return nil |
| 122 | } |
| 123 | |
| 124 | index := make(map[string]*MsgCredClient) |
| 125 | for i := range creds { |
| 126 | c := &creds[i] |
| 127 | if _, ok := globals.validators[c.Method]; ok && (!valueRequired || c.Value != "") { |
| 128 | index[c.Method] = c |
| 129 | } |
| 130 | } |
| 131 | creds = make([]MsgCredClient, 0, len(index)) |
| 132 | for _, c := range index { |
| 133 | creds = append(creds, *index[c.Method]) |
| 134 | } |
| 135 | return creds |
| 136 | } |
| 137 | |
| 138 | // Get a string slice with methods of credentials. |
| 139 | func credentialMethods(creds []MsgCredClient) []string { |
no outgoing calls
no test coverage detected
searching dependent graphs…