1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-07-04 12:03:41 +02:00

Move ship_processor.go and types.go into app package.

This commit is contained in:
Henrik Hautakoski 2023-01-19 14:07:54 +01:00
parent a9c512d0b0
commit 0027a80af0
3 changed files with 26 additions and 12 deletions

View file

@ -1,4 +1,4 @@
package main package app
import ( import (
"encoding/hex" "encoding/hex"
@ -9,12 +9,27 @@ import (
"eosio-ship-trace-reader/transport" "eosio-ship-trace-reader/transport"
"eosio-ship-trace-reader/transport/message" "eosio-ship-trace-reader/transport/message"
"github.com/eoscanada/eos-go/ship" "github.com/eoscanada/eos-go/ship"
shipclient "github.com/eosswedenorg-go/antelope-ship-client"
) )
type ShipProcessor struct { type ShipProcessor struct {
ns transport.Namespace ns transport.Namespace
abi *abi.AbiManager abi *abi.AbiManager
publisher transport.Publisher publisher transport.Publisher
shClient *shipclient.ShipClient
}
func SpawnProccessor(shClient *shipclient.ShipClient, ns transport.Namespace, publisher transport.Publisher, abi *abi.AbiManager) {
processor := &ShipProcessor{
ns: ns,
abi: abi,
publisher: publisher,
shClient: shClient,
}
// Attach handlers
shClient.BlockHandler = processor.processBlock
shClient.TraceHandler = processor.processTraces
} }
func (processor *ShipProcessor) queueMessage(channel transport.ChannelInterface, payload []byte) bool { func (processor *ShipProcessor) queueMessage(channel transport.ChannelInterface, payload []byte) bool {

View file

@ -1,4 +1,4 @@
package main package app
import ( import (
eos "github.com/eoscanada/eos-go" eos "github.com/eoscanada/eos-go"

19
main.go
View file

@ -10,6 +10,7 @@ import (
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"eosio-ship-trace-reader/app"
"eosio-ship-trace-reader/config" "eosio-ship-trace-reader/config"
"eosio-ship-trace-reader/transport" "eosio-ship-trace-reader/transport"
"eosio-ship-trace-reader/transport/redis_pubsub" "eosio-ship-trace-reader/transport/redis_pubsub"
@ -236,19 +237,17 @@ func main() {
} }
} }
processor := ShipProcessor{ shClient = shipclient.NewClient(conf.StartBlockNum, conf.EndBlockNum, conf.IrreversibleOnly)
ns: transport.Namespace{
app.SpawnProccessor(
shClient,
transport.Namespace{
Prefix: conf.Redis.Prefix, Prefix: conf.Redis.Prefix,
ChainID: chainInfo.ChainID.String(), ChainID: chainInfo.ChainID.String(),
}, },
publisher: redis_pubsub.New(rdb), redis_pubsub.New(rdb),
abi: abi.NewAbiManager(rdb, eosClient, conf.Redis.CacheID), abi.NewAbiManager(rdb, eosClient, conf.Redis.CacheID),
} )
// Construct ship client
shClient = shipclient.NewClient(conf.StartBlockNum, conf.EndBlockNum, conf.IrreversibleOnly)
shClient.BlockHandler = processor.processBlock
shClient.TraceHandler = processor.processTraces
// Run the application // Run the application
run() run()