From 6cdb596b41fe7ca329efd4c4edb5cea134fac294 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 20 Jan 2022 11:24:18 +0100 Subject: [PATCH] ship_processor.go: also publish transactions to redis. --- ship_processor.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ship_processor.go b/ship_processor.go index c973aab..5063628 100644 --- a/ship_processor.go +++ b/ship_processor.go @@ -17,8 +17,18 @@ func processBlock(block *ship.GetBlocksResultV0) { func processTraces(traces []*ship.TransactionTraceV0) { for _, trace := range traces { - //log.Println("Trace ID:", trace.ID) + payload, err := json.Marshal(trace) + if err == nil { + channel := RedisKey("transactions") + if err := RedisPublish(channel, payload).Err(); err != nil { + log.Printf("Failed to post to channel '%s': %s", channel, err) + } + } else { + log.Println("Failed to encode transaction:", err) + } + + // Actions for _, actionTraceVar := range trace.ActionTraces { trace := actionTraceVar.Impl.(*ship.ActionTraceV0)