cleaning up some chat logging

This commit is contained in:
cryptonote-social 2020-12-27 08:19:13 -08:00
parent 8ef2262545
commit 96ea5f3c9c
3 changed files with 14 additions and 6 deletions

View File

@ -150,7 +150,12 @@ func Mine(c *MinerConfig) error {
chatMsg := b[2:] chatMsg := b[2:]
id := chat.SendChat(chatMsg) id := chat.SendChat(chatMsg)
chatsSent[id] = struct{}{} 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(" s: print miner stats")
crylog.Info(" i: increase number of threads by 1") crylog.Info(" i: increase number of threads by 1")
crylog.Info(" d: decrease number of threads by 1") crylog.Info(" d: decrease number of threads by 1")
crylog.Info(" c <message>: send a message to the chatroom")
crylog.Info(" q: quit") crylog.Info(" q: quit")
crylog.Info(" <enter>: override a paused miner") crylog.Info(" <enter>: override a paused miner")
crylog.Info("") crylog.Info("")
@ -239,7 +245,7 @@ func printStatsPeriodically() {
if !ok { if !ok {
crylog.Info("\n\nCHAT MESSAGE RECEIVED:\n[", c.Username, "] (", time.Unix(c.Timestamp, 0), ")\n", c.Message, "\n") crylog.Info("\n\nCHAT MESSAGE RECEIVED:\n[", c.Username, "] (", time.Unix(c.Timestamp, 0), ")\n", c.Message, "\n")
} else { } else {
crylog.Info("Chat sent:", c.Message) crylog.Info("queued chat successfully sent")
} }
} }
} }

View File

@ -38,7 +38,6 @@ func SendChat(chat string) int64 {
mutex.Lock() mutex.Lock()
defer mutex.Unlock() defer mutex.Unlock()
chatQueue = append(chatQueue, chat) chatQueue = append(chatQueue, chat)
crylog.Info("Chat queued for sending:", chat)
return int64(len(chatQueue)-1) ^ randID return int64(len(chatQueue)-1) ^ randID
} }
@ -51,7 +50,6 @@ func GetChatToSend() (chat string, id int64) {
if chatToSendIndex >= len(chatQueue) { if chatToSendIndex >= len(chatQueue) {
return "", -1 return "", -1
} }
crylog.Info("ID:", int64(chatToSendIndex)^randID, randID)
return chatQueue[chatToSendIndex], int64(chatToSendIndex) ^ randID return chatQueue[chatToSendIndex], int64(chatToSendIndex) ^ randID
} }
@ -70,8 +68,8 @@ func ChatSent(id int64) {
} }
func ChatsReceived(chats []client.ChatResult, chatToken int64, fetchedToken int64) { func ChatsReceived(chats []client.ChatResult, chatToken int64, fetchedToken int64) {
if len(chats) != 0 { if len(chats) == 0 && chatToken == fetchedToken {
crylog.Info("Chats received:", chats) return
} }
mutex.Lock() mutex.Lock()
defer mutex.Unlock() 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) crylog.Warn("chats updated since this fetch, discarding:", chats)
return return
} }
crylog.Info("New chats received:", len(chats), chatToken, fetchedToken)
for i := range chats { for i := range chats {
receivedQueue = append(receivedQueue, &chats[i]) receivedQueue = append(receivedQueue, &chats[i])
} }

View File

@ -26,6 +26,9 @@ const (
MAX_REQUEST_SIZE = 50000 // Max # of bytes we will read per request MAX_REQUEST_SIZE = 50000 // Max # of bytes we will read per request
NO_WALLET_SPECIFIED_WARNING_CODE = 2 NO_WALLET_SPECIFIED_WARNING_CODE = 2
// user string used for chats sent by any unauthenticated user regardless of their login
UNAUTHENTICATED_USER_STRING = "<unauthenticated user>"
) )
type Job struct { type Job struct {