Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ func NewListener(c *cli.Context) (*listener.Listener, error) {
l.Infow("Using HTTP block poller", "rpc", httpRPC, "interval", pollIntervalFlag.Value.String())
}

l.Infow("Get chainID from node")
chainID, err := httpEVMClient.ChainID(c.Context)
if err != nil {
l.Errorw("Fail to get chainID", "error", err)

return nil, err
}

l = l.With("chainID", chainID.Int64())

sanityCheckInterval := sanityCheckIntervalFlag.Value
var sanityEVMClient evmclient.IClient
sanityRPC := sanityNodeRPCFlag.Value
Expand Down
3 changes: 2 additions & 1 deletion pkg/block/base_block_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"fmt"
"sync"

"github.com/emirpasic/gods/queues/circularbuffer"

"github.com/KyberNetwork/evmlistener/pkg/errors"
"github.com/KyberNetwork/evmlistener/pkg/types"
"github.com/emirpasic/gods/queues/circularbuffer"
)

const zeroHash = "0x0000000000000000000000000000000000000000000000000000000000000000"
Expand Down
3 changes: 2 additions & 1 deletion pkg/block/base_block_keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"math/big"
"testing"

"github.com/stretchr/testify/suite"

"github.com/KyberNetwork/evmlistener/pkg/errors"
"github.com/KyberNetwork/evmlistener/pkg/types"
"github.com/stretchr/testify/suite"
)

// nolint
Expand Down
3 changes: 2 additions & 1 deletion pkg/block/redis_block_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"fmt"
"time"

"go.uber.org/zap"

"github.com/KyberNetwork/evmlistener/pkg/errors"
"github.com/KyberNetwork/evmlistener/pkg/redis"
"github.com/KyberNetwork/evmlistener/pkg/types"
"go.uber.org/zap"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions pkg/block/redis_block_keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
"testing"
"time"

"github.com/stretchr/testify/suite"
"go.uber.org/zap"

"github.com/KyberNetwork/evmlistener/pkg/errors"
"github.com/KyberNetwork/evmlistener/pkg/redis"
"github.com/KyberNetwork/evmlistener/pkg/types"
"github.com/stretchr/testify/suite"
"go.uber.org/zap"
)

type RedisBlockKeeperTestSuite struct {
Expand Down
16 changes: 2 additions & 14 deletions pkg/evmclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,18 @@ type IClient interface {
}

type Client struct {
chainID uint64
ethClient *ethclient.Client
customClient *commonclient.Client
}

func DialContext(ctx context.Context, rawurl string, httpClient *http.Client) (*Client, error) {
client := &Client{}

rpcClient, err := rpc.DialOptions(ctx, rawurl, rpc.WithHTTPClient(httpClient))
if err != nil {
return nil, err
}

ethClient := ethclient.NewClient(rpcClient)
chainID, err := ethClient.ChainID(ctx)
if err != nil {
return nil, err
}

client := &Client{
chainID: chainID.Uint64(),
}

switch {
case UseCustomClient:
Expand Down Expand Up @@ -101,10 +93,6 @@ func DialContextWithTimeout(
}
}

func (c *Client) ChainID(_ context.Context) (*big.Int, error) {
return new(big.Int).SetUint64(c.chainID), nil
}

func (c *Client) BlockNumber(ctx context.Context) (uint64, error) {
switch {
case c.customClient != nil:
Expand Down
3 changes: 2 additions & 1 deletion pkg/listener/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"math/big"
"time"

"go.uber.org/zap"

"github.com/KyberNetwork/evmlistener/pkg/block"
"github.com/KyberNetwork/evmlistener/pkg/encoder"
"github.com/KyberNetwork/evmlistener/pkg/errors"
"github.com/KyberNetwork/evmlistener/pkg/evmclient"
"github.com/KyberNetwork/evmlistener/pkg/publisher"
"github.com/KyberNetwork/evmlistener/pkg/types"
"go.uber.org/zap"
)

type HandlerConfig struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/listener/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"testing"

"github.com/stretchr/testify/suite"
"go.uber.org/zap"

"github.com/KyberNetwork/evmlistener/pkg/block"
"github.com/KyberNetwork/evmlistener/pkg/encoder"
"github.com/KyberNetwork/evmlistener/pkg/errors"
ltypes "github.com/KyberNetwork/evmlistener/pkg/types"
"github.com/stretchr/testify/suite"
"go.uber.org/zap"
)

type HandlerTestSuite struct {
Expand Down
Loading