From 96ea5f3c9c2611dcecbc0bf526c1bee26efc445e Mon Sep 17 00:00:00 2001 From: cryptonote-social Date: Sun, 27 Dec 2020 08:19:13 -0800 Subject: [PATCH] cleaning up some chat logging --- miner.go | 10 ++++++++-- minerlib/chat/chat.go | 7 +++---- stratum/client/client.go | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/miner.go b/miner.go index e2c3d49..017c56b 100644 --- a/miner.go +++ b/miner.go @@ -150,7 +150,12 @@ func Mine(c *MinerConfig) error { chatMsg := b[2:] id := chat.SendChat(chatMsg) chatsSent[id] = struct{}{} - crylog.Info("\n\nCHAT MESSAGE QUEUED TO SEND:\n[", c.Username, "] (", time.Now().Truncate(time.Second), ")\n", chatMsg, "\n") + u := c.Username + if c.Wallet == "" { + u = client.UNAUTHENTICATED_USER_STRING + crylog.Warn("Sending chat without authentication. Provide -wallet string with your user login to authenticate.") + } + crylog.Info("\n\nCHAT MESSAGE QUEUED TO SEND:\n[", u, "] (", time.Now().Truncate(time.Second), ")\n", chatMsg, "\n") } } @@ -198,6 +203,7 @@ func printKeyboardCommands() { crylog.Info(" s: print miner stats") crylog.Info(" i: increase number of threads by 1") crylog.Info(" d: decrease number of threads by 1") + crylog.Info(" c : send a message to the chatroom") crylog.Info(" q: quit") crylog.Info(" : override a paused miner") crylog.Info("") @@ -239,7 +245,7 @@ func printStatsPeriodically() { if !ok { crylog.Info("\n\nCHAT MESSAGE RECEIVED:\n[", c.Username, "] (", time.Unix(c.Timestamp, 0), ")\n", c.Message, "\n") } else { - crylog.Info("Chat sent:", c.Message) + crylog.Info("queued chat successfully sent") } } } diff --git a/minerlib/chat/chat.go b/minerlib/chat/chat.go index 58c46ac..f498fa0 100644 --- a/minerlib/chat/chat.go +++ b/minerlib/chat/chat.go @@ -38,7 +38,6 @@ func SendChat(chat string) int64 { mutex.Lock() defer mutex.Unlock() chatQueue = append(chatQueue, chat) - crylog.Info("Chat queued for sending:", chat) return int64(len(chatQueue)-1) ^ randID } @@ -51,7 +50,6 @@ func GetChatToSend() (chat string, id int64) { if chatToSendIndex >= len(chatQueue) { return "", -1 } - crylog.Info("ID:", int64(chatToSendIndex)^randID, randID) return chatQueue[chatToSendIndex], int64(chatToSendIndex) ^ randID } @@ -70,8 +68,8 @@ func ChatSent(id int64) { } func ChatsReceived(chats []client.ChatResult, chatToken int64, fetchedToken int64) { - if len(chats) != 0 { - crylog.Info("Chats received:", chats) + if len(chats) == 0 && chatToken == fetchedToken { + return } mutex.Lock() defer mutex.Unlock() @@ -80,6 +78,7 @@ func ChatsReceived(chats []client.ChatResult, chatToken int64, fetchedToken int6 crylog.Warn("chats updated since this fetch, discarding:", chats) return } + crylog.Info("New chats received:", len(chats), chatToken, fetchedToken) for i := range chats { receivedQueue = append(receivedQueue, &chats[i]) } diff --git a/stratum/client/client.go b/stratum/client/client.go index 68a34c1..d3dfe2a 100644 --- a/stratum/client/client.go +++ b/stratum/client/client.go @@ -26,6 +26,9 @@ const ( MAX_REQUEST_SIZE = 50000 // Max # of bytes we will read per request NO_WALLET_SPECIFIED_WARNING_CODE = 2 + + // user string used for chats sent by any unauthenticated user regardless of their login + UNAUTHENTICATED_USER_STRING = "" ) type Job struct {