1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-18 04:40:03 +02:00

Also move "redis wrapper" into it's own package.

This commit is contained in:
Henrik Hautakoski 2022-03-11 11:35:33 +01:00
parent 8df93439c3
commit 231b467dbe
5 changed files with 71 additions and 64 deletions

View file

@ -5,6 +5,7 @@ import (
"log"
"encoding/json"
"github.com/eoscanada/eos-go/ship"
"eosio-ship-trace-reader/redis"
)
func processBlock(block *ship.GetBlocksResultV0) {
@ -20,8 +21,8 @@ func processTraces(traces []*ship.TransactionTraceV0) {
payload, err := json.Marshal(trace)
if err == nil {
channel := RedisKey("transactions")
if err := RedisPublish(channel, payload).Err(); err != nil {
channel := redis.Key("transactions")
if err := redis.Publish(channel, payload).Err(); err != nil {
log.Printf("Failed to post to channel '%s': %s", channel, err)
}
} else {
@ -57,21 +58,21 @@ func processTraces(traces []*ship.TransactionTraceV0) {
}
channels := []string{
RedisKey("actions"),
RedisKey(string(act.Contract), "actions"),
RedisKey(string(act.Contract), "actions", string(act.Action)),
redis.Key("actions"),
redis.Key(string(act.Contract), "actions"),
redis.Key(string(act.Contract), "actions", string(act.Action)),
}
for _, channel := range channels {
if err := RedisRegisterPublish(channel, payload).Err(); err != nil {
if err := redis.RegisterPublish(channel, payload).Err(); err != nil {
log.Printf("Failed to post to channel '%s': %s", channel, err)
}
}
}
}
_, err := RedisSend()
_, err := redis.Send()
if err != nil {
log.Println("Failed to send redis command:", err)
log.Println("Failed to send redis. command:", err)
}
}