Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use instance of config instead of reference #689

Merged
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
6 changes: 3 additions & 3 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func SupportedAPIs(
pullAPI *PullAPI,
debugAPI *DebugAPI,
walletAPI *WalletAPI,
config *config.Config,
config config.Config,
) []rpc.API {
apis := []rpc.API{{
Namespace: "eth",
Expand Down Expand Up @@ -151,7 +151,7 @@ func SupportedAPIs(

type BlockChainAPI struct {
logger zerolog.Logger
config *config.Config
config config.Config
evm requester.Requester
blocks storage.BlockIndexer
transactions storage.TransactionIndexer
Expand All @@ -163,7 +163,7 @@ type BlockChainAPI struct {

func NewBlockChainAPI(
logger zerolog.Logger,
config *config.Config,
config config.Config,
evm requester.Requester,
blocks storage.BlockIndexer,
transactions storage.TransactionIndexer,
Expand Down
4 changes: 2 additions & 2 deletions api/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type DebugAPI struct {
transactions storage.TransactionIndexer
receipts storage.ReceiptIndexer
client *requester.CrossSporkClient
config *config.Config
config config.Config
collector metrics.Collector
}

Expand All @@ -60,7 +60,7 @@ func NewDebugAPI(
transactions storage.TransactionIndexer,
receipts storage.ReceiptIndexer,
client *requester.CrossSporkClient,
config *config.Config,
config config.Config,
logger zerolog.Logger,
collector metrics.Collector,
) *DebugAPI {
Expand Down
4 changes: 2 additions & 2 deletions api/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

// NetAPI offers network related RPC methods
type NetAPI struct {
config *config.Config
config config.Config
}

func NewNetAPI(config *config.Config) *NetAPI {
func NewNetAPI(config config.Config) *NetAPI {
return &NetAPI{
config: config,
}
Expand Down
4 changes: 2 additions & 2 deletions api/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func newLogsFilter(

type PullAPI struct {
logger zerolog.Logger
config *config.Config
config config.Config
blocks storage.BlockIndexer
transactions storage.TransactionIndexer
receipts storage.ReceiptIndexer
Expand All @@ -140,7 +140,7 @@ type PullAPI struct {

func NewPullAPI(
logger zerolog.Logger,
config *config.Config,
config config.Config,
blocks storage.BlockIndexer,
transactions storage.TransactionIndexer,
receipts storage.ReceiptIndexer,
Expand Down
2 changes: 1 addition & 1 deletion api/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestFilterExpiryChecker(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
api := &PullAPI{
filters: make(map[rpc.ID]filter),
config: &config.Config{FilterExpiry: time.Millisecond * 5},
config: config.Config{FilterExpiry: time.Millisecond * 5},
}

tc.setup(api)
Expand Down
4 changes: 2 additions & 2 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type Server struct {
host string
port int

config *config.Config
config config.Config
collector metrics.Collector
}

Expand All @@ -66,7 +66,7 @@ const (
func NewServer(
logger zerolog.Logger,
collector metrics.Collector,
cfg *config.Config,
cfg config.Config,
) *Server {
logger = logger.With().Str("component", "API").Logger()

Expand Down
4 changes: 2 additions & 2 deletions api/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

type StreamAPI struct {
logger zerolog.Logger
config *config.Config
config config.Config
blocks storage.BlockIndexer
transactions storage.TransactionIndexer
receipts storage.ReceiptIndexer
Expand All @@ -32,7 +32,7 @@ type StreamAPI struct {

func NewStreamAPI(
logger zerolog.Logger,
config *config.Config,
config config.Config,
blocks storage.BlockIndexer,
transactions storage.TransactionIndexer,
receipts storage.ReceiptIndexer,
Expand Down
4 changes: 2 additions & 2 deletions api/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (

type WalletAPI struct {
net *BlockChainAPI
config *config.Config
config config.Config
}

func NewWalletAPI(config *config.Config, net *BlockChainAPI) *WalletAPI {
func NewWalletAPI(config config.Config, net *BlockChainAPI) *WalletAPI {
return &WalletAPI{
net: net,
config: config,
Expand Down
10 changes: 5 additions & 5 deletions bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Publishers struct {

type Bootstrap struct {
logger zerolog.Logger
config *config.Config
config config.Config
client *requester.CrossSporkClient
storages *Storages
publishers *Publishers
Expand All @@ -63,7 +63,7 @@ type Bootstrap struct {
db *pebbleDB.DB
}

func New(config *config.Config) (*Bootstrap, error) {
func New(config config.Config) (*Bootstrap, error) {
logger := zerolog.New(config.LogWriter).
With().Timestamp().Str("version", api.Version).
Logger().Level(config.LogLevel)
Expand Down Expand Up @@ -437,7 +437,7 @@ func StartEngine(
}

// setupCrossSporkClient sets up a cross-spork AN client.
func setupCrossSporkClient(config *config.Config, logger zerolog.Logger) (*requester.CrossSporkClient, error) {
func setupCrossSporkClient(config config.Config, logger zerolog.Logger) (*requester.CrossSporkClient, error) {
// create access client with cross-spork capabilities
currentSporkClient, err := grpc.NewClient(
config.AccessNodeHost,
Expand Down Expand Up @@ -479,7 +479,7 @@ func setupCrossSporkClient(config *config.Config, logger zerolog.Logger) (*reque
// setupStorage creates storage and initializes it with configured starting cadence height
// in case such a height doesn't already exist in the database.
func setupStorage(
config *config.Config,
config config.Config,
client *requester.CrossSporkClient,
logger zerolog.Logger,
) (*pebbleDB.DB, *Storages, error) {
Expand Down Expand Up @@ -576,7 +576,7 @@ func setupStorage(
// Run will run complete bootstrap of the EVM gateway with all the engines.
// Run is a blocking call, but it does signal readiness of the service
// through a channel provided as an argument.
func Run(ctx context.Context, cfg *config.Config, ready component.ReadyFunc) error {
func Run(ctx context.Context, cfg config.Config, ready component.ReadyFunc) error {
boot, err := New(cfg)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func parseConfigFromFlags() error {
return nil
}

var cfg = &config.Config{}
var cfg = config.Config{}
var (
coinbase,
gas,
Expand Down
4 changes: 2 additions & 2 deletions services/requester/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type EVM struct {
registerStore *pebble.RegisterStorage
blocksProvider *replayer.BlocksProvider
client *CrossSporkClient
config *config.Config
config config.Config
signer crypto.Signer
txPool *TxPool
logger zerolog.Logger
Expand All @@ -112,7 +112,7 @@ func NewEVM(
registerStore *pebble.RegisterStorage,
blocksProvider *replayer.BlocksProvider,
client *CrossSporkClient,
config *config.Config,
config config.Config,
signer crypto.Signer,
logger zerolog.Logger,
blocks storage.BlockIndexer,
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func servicesSetup(t *testing.T) (emulator.Emulator, func()) {
service := emu.ServiceKey()

// default config
cfg := &config.Config{
cfg := config.Config{
DatabaseDir: t.TempDir(),
AccessNodeHost: "localhost:3569", // emulator
RPCPort: 8545,
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Test_ConcurrentTransactionSubmission(t *testing.T) {
)
require.NoError(t, err)

cfg := &config.Config{
cfg := config.Config{
DatabaseDir: t.TempDir(),
AccessNodeHost: grpcHost,
RPCPort: 8545,
Expand Down Expand Up @@ -164,7 +164,7 @@ func Test_EthClientTest(t *testing.T) {
)
require.NoError(t, err)

cfg := &config.Config{
cfg := config.Config{
DatabaseDir: t.TempDir(),
AccessNodeHost: grpcHost,
RPCPort: 8545,
Expand Down Expand Up @@ -266,7 +266,7 @@ func Test_CloudKMSConcurrentTransactionSubmission(t *testing.T) {
)
require.NoError(t, err)

cfg := &config.Config{
cfg := config.Config{
DatabaseDir: t.TempDir(),
AccessNodeHost: grpcHost,
RPCPort: 8545,
Expand Down