ax(mining): rename msg to clientMessage in wsClient.readPump
AX Principle 1 — predictable names over short names. `msg` required reading the struct to understand what it contained; `clientMessage` is self-describing at the call site. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
aba728ff83
commit
9096452ff1
1 changed files with 5 additions and 5 deletions
|
|
@ -348,24 +348,24 @@ func (client *wsClient) readPump() {
|
|||
}
|
||||
|
||||
// Parse client message
|
||||
var msg struct {
|
||||
var clientMessage struct {
|
||||
Type string `json:"type"`
|
||||
Miners []string `json:"miners,omitempty"`
|
||||
}
|
||||
if err := UnmarshalJSON(message, &msg); err != nil {
|
||||
if err := UnmarshalJSON(message, &clientMessage); err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
switch msg.Type {
|
||||
switch clientMessage.Type {
|
||||
case "subscribe":
|
||||
// Update miner subscription (protected by mutex)
|
||||
client.minersMutex.Lock()
|
||||
client.miners = make(map[string]bool)
|
||||
for _, m := range msg.Miners {
|
||||
for _, m := range clientMessage.Miners {
|
||||
client.miners[m] = true
|
||||
}
|
||||
client.minersMutex.Unlock()
|
||||
logging.Debug("client subscribed to miners", logging.Fields{"miners": msg.Miners})
|
||||
logging.Debug("client subscribed to miners", logging.Fields{"miners": clientMessage.Miners})
|
||||
|
||||
case "ping":
|
||||
// Respond with pong
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue