fixed self sending TRX issue

This commit is contained in:
Stephan D
2025-12-25 19:54:01 +01:00
parent bcb3e9e647
commit 8c87e5534e
4 changed files with 75 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package rpcclient
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
@@ -175,11 +176,16 @@ func (l *loggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, erro
respFields := append(fields,
zap.Int("status_code", resp.StatusCode),
)
if contentType := strings.TrimSpace(resp.Header.Get("Content-Type")); contentType != "" {
respFields = append(respFields, zap.String("content_type", contentType))
}
if len(bodyBytes) > 0 {
respFields = append(respFields, zap.String("rpc_response", truncate(string(bodyBytes), 2048)))
}
if resp.StatusCode >= 400 {
l.logger.Warn("RPC response error", respFields...)
} else if len(bodyBytes) > 0 && !json.Valid(bodyBytes) {
l.logger.Warn("RPC response invalid JSON", respFields...)
}
return resp, nil