Skip to content

Commit

Permalink
Update to use antelope-go instead of eos-go library
Browse files Browse the repository at this point in the history
  • Loading branch information
pnx committed Apr 29, 2024
1 parent 8aa93dd commit 63da39f
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 211 deletions.
26 changes: 13 additions & 13 deletions cmd/thalos/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

"github.com/cenkalti/backoff/v4"
eos "github.com/eoscanada/eos-go"
shipclient "github.com/eosswedenorg-go/antelope-ship-client"
shipws "github.com/eosswedenorg-go/antelope-ship-client/websocket"
"github.com/eosswedenorg-go/pid"
Expand All @@ -30,6 +29,7 @@ import (
redis_cache "github.com/go-redis/cache/v9"
"github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/telegram"
antelopeapi "github.com/pnx/antelope-go/api"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -155,12 +155,12 @@ func LogLevels() []string {
return list
}

func initAbiManager(api *eos.API, store cache.Store, chain_id string) *abi.AbiManager {
func initAbiManager(api *antelopeapi.Client, store cache.Store, chain_id string) *abi.AbiManager {
cache := cache.NewCache("thalos::cache::abi::"+chain_id, store)
return abi.NewAbiManager(cache, api)
}

func stateLoader(conf *config.Config, start_block_flag *pflag.Flag, chainInfo func() *eos.InfoResp, cache *cache.Cache, current_block_no_cache bool) StateLoader {
func stateLoader(conf *config.Config, start_block_flag *pflag.Flag, chainInfo func() *antelopeapi.Info, cache *cache.Cache, current_block_no_cache bool) StateLoader {
return func(state *State) {
var source string

Expand All @@ -186,7 +186,7 @@ func stateLoader(conf *config.Config, start_block_flag *pflag.Flag, chainInfo fu
// Otherwise, set from api.
if conf.Ship.IrreversibleOnly {
source = "api (LIB)"
state.CurrentBlock = uint32(chainInfo().LastIrreversibleBlockNum)
state.CurrentBlock = uint32(chainInfo().LastIrreversableBlockNum)
} else {
source = "api (HEAD)"
state.CurrentBlock = uint32(chainInfo().HeadBlockNum)
Expand Down Expand Up @@ -246,12 +246,12 @@ func GetConfig(flags *pflag.FlagSet) (*config.Config, error) {
// that pointer will live as long as the closure lives.
// and inside the closure we will reference the pointer and only
// call the api if it is nil.
func chainInfoOnce(api *eos.API) func() *eos.InfoResp {
var info *eos.InfoResp
return func() *eos.InfoResp {
func chainInfoOnce(api *antelopeapi.Client) func() *antelopeapi.Info {
var info *antelopeapi.Info
return func() *antelopeapi.Info {
if info == nil {

log.WithField("api", api.BaseURL).Info("Get chain info from api")
log.WithField("api", api.Url).Info("Get chain info from api")

ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
Expand All @@ -262,7 +262,7 @@ func chainInfoOnce(api *eos.API) func() *eos.InfoResp {
return nil
}

info = result
info = &result
}
return info
}
Expand Down Expand Up @@ -381,7 +381,7 @@ func serverCmd(cmd *cobra.Command, args []string) {
// Setup general cache
cache := cache.NewCache("thalos::cache::instance::"+conf.Name, cacheStore)

eosClient := eos.New(conf.Api)
antelopeClient := antelopeapi.New(conf.Api)

shClient := shipclient.NewStream(func(s *shipclient.Stream) {
s.StartBlock = conf.Ship.StartBlockNum
Expand All @@ -396,11 +396,11 @@ func serverCmd(cmd *cobra.Command, args []string) {
return
}

chainInfo := chainInfoOnce(eosClient)
chainInfo := chainInfoOnce(antelopeClient)

chain_id := conf.Ship.Chain
if len(chain_id) < 1 {
chain_id = chainInfo().ChainID.String()
chain_id = chainInfo().ChainID
}

processor := SpawnProccessor(
Expand All @@ -411,7 +411,7 @@ func serverCmd(cmd *cobra.Command, args []string) {
Prefix: conf.Redis.Prefix,
ChainID: chain_id,
}),
initAbiManager(eosClient, cacheStore, chain_id),
initAbiManager(antelopeClient, cacheStore, chain_id),
codec,
)

Expand Down
27 changes: 12 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,41 @@ go 1.20
require (
github.com/cenkalti/backoff/v4 v4.2.1
github.com/docker/go-units v0.5.0
github.com/eoscanada/eos-go v0.10.3-0.20231109144819-59afdfa3a37d
github.com/eosswedenorg-go/antelope-ship-client v0.2.8
github.com/eosswedenorg-go/antelope-ship-client v0.2.9
github.com/eosswedenorg-go/pid v1.0.1
github.com/eosswedenorg/thalos/api v1.0.0
github.com/go-redis/cache/v9 v9.0.0
github.com/go-redis/redismock/v9 v9.2.0
github.com/mitchellh/mapstructure v1.5.0
github.com/nikoksr/notify v0.41.0
github.com/pnx/antelope-go v0.0.2-0.20240425200605-62ec2abfe722
github.com/redis/go-redis/v9 v9.5.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/blendle/zapdriver v1.3.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/eosswedenorg-go/jsontime v0.0.0-20230509125027-08422d6236c7 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imroc/req/v3 v3.7.6 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/liamylian/jsontime/v2 v2.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/onsi/gomega v1.31.1 // indirect
Expand All @@ -49,27 +51,22 @@ require (
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
github.com/tidwall/gjson v1.17.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/vmihailenco/go-tinylfu v0.2.2 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.20.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)

replace github.com/eosswedenorg/thalos/api => ./api

replace github.com/pnx/antelope-go => ../../go/antelope-go
Loading

0 comments on commit 63da39f

Please sign in to comment.