mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-17 04:30:03 +02:00
26 lines
657 B
Go
26 lines
657 B
Go
package shipclient
|
|
|
|
import (
|
|
"eosio-ship-trace-reader/config"
|
|
|
|
"github.com/eoscanada/eos-go"
|
|
shipclient "github.com/eosswedenorg-go/antelope-ship-client"
|
|
)
|
|
|
|
func NewClient(cfg *config.Config, chain *eos.InfoResp) (*shipclient.Client, error) {
|
|
if cfg.StartBlockNum == config.NULL_BLOCK_NUMBER {
|
|
if cfg.IrreversibleOnly {
|
|
cfg.StartBlockNum = uint32(chain.LastIrreversibleBlockNum)
|
|
} else {
|
|
cfg.StartBlockNum = uint32(chain.HeadBlockNum)
|
|
}
|
|
}
|
|
|
|
options := func(c *shipclient.Client) {
|
|
c.StartBlock = cfg.StartBlockNum
|
|
c.EndBlock = cfg.EndBlockNum
|
|
c.IrreversibleOnly = cfg.IrreversibleOnly
|
|
}
|
|
|
|
return shipclient.NewClient(options), nil
|
|
}
|