Skip to content

Commit 22e7fb6

Browse files
authored
Merge pull request #43 from blinklabs-io/feat/metadata-messages
feat: log metadata messages at debug
2 parents ed283eb + 443df73 commit 22e7fb6

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ $(BINARY): mod-tidy $(GO_FILES)
2424
mod-tidy:
2525
go mod tidy
2626

27+
clean:
28+
rm -f $(BINARY)
29+
30+
format:
31+
go fmt ./...
32+
33+
golines:
34+
golines -w --ignore-generated --chain-split-dots --max-len=80 --reformat-tags .
35+
36+
test:
37+
go test -v ./...
38+
2739
# Build docker image
2840
image: build
2941
docker build -t $(BINARY) .

api/api.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ import (
77
"io"
88
"net/http"
99
"net/http/httptrace"
10+
"strings"
1011
"time"
1112

13+
"github.com/blinklabs-io/cardano-models"
1214
"github.com/blinklabs-io/gouroboros/ledger"
15+
"github.com/fxamacker/cbor/v2"
1316
ginzap "github.com/gin-contrib/zap"
1417
"github.com/gin-gonic/gin"
1518

@@ -79,7 +82,21 @@ func handleSubmitTx(c *gin.Context) {
7982
c.String(400, fmt.Sprintf("failed to parse transaction CBOR: %s", err))
8083
return
8184
}
82-
logger.Debugf("transaction ID %s", tx.Hash())
85+
logger.Debugf("transaction ID: %s", tx.Hash())
86+
// Debug log metadata messages
87+
if tx.Metadata() != nil {
88+
mdCbor := tx.Metadata().Cbor()
89+
var msgMetadata models.Cip20Metadata
90+
err := cbor.Unmarshal(mdCbor, &msgMetadata)
91+
if err == nil {
92+
if msgMetadata.Num674.Msg != nil {
93+
logger.Debugf(
94+
"metadata msg: %s",
95+
strings.Join(msgMetadata.Num674.Msg, "\n"),
96+
)
97+
}
98+
}
99+
}
83100
// Send request to each backend
84101
for _, backend := range cfg.Backends {
85102
go func(backend string) {

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ module github.com/blinklabs-io/tx-submit-api-mirror
33
go 1.20
44

55
require (
6+
github.com/blinklabs-io/cardano-models v0.0.0-20231017185043-3138e1eca17e
67
github.com/blinklabs-io/gouroboros v0.61.0
8+
github.com/fxamacker/cbor/v2 v2.5.0
79
github.com/gin-contrib/zap v0.2.0
810
github.com/gin-gonic/gin v1.9.1
911
github.com/kelseyhightower/envconfig v1.4.0
@@ -15,7 +17,6 @@ require (
1517
github.com/bytedance/sonic v1.10.0 // indirect
1618
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
1719
github.com/chenzhuoyu/iasm v0.9.0 // indirect
18-
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
1920
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
2021
github.com/gin-contrib/sse v0.1.0 // indirect
2122
github.com/go-playground/locales v0.14.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/blinklabs-io/cardano-models v0.0.0-20231017185043-3138e1eca17e h1:Ci4jouvRLR7wjvsl2symiMsXChcqykjL0eqkr+VyWng=
2+
github.com/blinklabs-io/cardano-models v0.0.0-20231017185043-3138e1eca17e/go.mod h1:WrWzWgqqsY9sFQ0qpZw1hO4A9OdG5peIFQ1SCM5JTJ0=
13
github.com/blinklabs-io/gouroboros v0.61.0 h1:HSAo2thM/4JM6tVF4e/o9f20aVElSckJVX6LdkvuNyE=
24
github.com/blinklabs-io/gouroboros v0.61.0/go.mod h1:D5YJka8EyVmiXNMbRvjH23H9lNMLA4+qSlNNC/j7R0k=
35
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=

0 commit comments

Comments
 (0)