merge transactions and update
This commit is contained in:
@@ -2,8 +2,10 @@ package logger
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
message "m2pool-payment/internal/msg"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
@@ -231,21 +233,25 @@ func LogWithdraw(toAddress string, status string, amount float64, fromAddress st
|
||||
}
|
||||
|
||||
// LogPay 记录支付消息
|
||||
func LogPay(toAddress string, status string, amount float64, fromAddress string, txHash string, blockHeight uint64, orderId string, queueId string) {
|
||||
func LogPay(status string, fromAddress string, queueId string, transactions map[string]*message.PayData_resp) {
|
||||
if txLogger == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 使用 toAddress 作为文件名
|
||||
lf, err := txLogger.getOrCreateLogFile(toAddress)
|
||||
lf, err := txLogger.getOrCreateLogFile(fromAddress)
|
||||
if err != nil {
|
||||
fmt.Printf("⚠️ 获取日志文件失败: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
t, err := json.Marshal(transactions)
|
||||
if err != nil {
|
||||
fmt.Println("Error marshalling to JSON:", err)
|
||||
return
|
||||
}
|
||||
timestamp := time.Now().Format("2006-01-02 15:04:05")
|
||||
content := fmt.Sprintf("%s [pay]-[%s] | 金额: %.6f | FromAddress: %s | ToAddress: %s | 交易哈希: %s | 区块高度: %d | OrderId: %s | QueueId: %s",
|
||||
timestamp, status, amount, fromAddress, toAddress, txHash, blockHeight, orderId, queueId)
|
||||
content := fmt.Sprintf("%s [pay]-[%s] | FromAddress: %s | QueueId: %s | Transactions: %v",
|
||||
timestamp, status, fromAddress, queueId, string(t))
|
||||
|
||||
if err := lf.write(content); err != nil {
|
||||
fmt.Printf("⚠️ 写入日志失败: %v\n", err)
|
||||
|
||||
Reference in New Issue
Block a user