1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-17 04:30:03 +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 (
"encoding/hex"
@ -9,12 +9,27 @@ import (
"eosio-ship-trace-reader/transport"
"eosio-ship-trace-reader/transport/message"
"github.com/eoscanada/eos-go/ship"
shipclient "github.com/eosswedenorg-go/antelope-ship-client"
)
type ShipProcessor struct {
ns transport.Namespace
abi *abi.AbiManager
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 {

View file

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

19
main.go
View file

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