code.vegaprotocol.io/vega@v0.79.0/core/evtforward/config.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package evtforward
    17  
    18  import (
    19  	"time"
    20  
    21  	"code.vegaprotocol.io/vega/core/datasource/external/ethcall"
    22  	"code.vegaprotocol.io/vega/core/evtforward/ethereum"
    23  	"code.vegaprotocol.io/vega/libs/config/encoding"
    24  	"code.vegaprotocol.io/vega/logging"
    25  )
    26  
    27  const (
    28  	forwarderLogger = "forwarder"
    29  	// how often the Event Forwarder needs to select a node to send the event
    30  	// if nothing was received.
    31  	defaultRetryRate = 10 * time.Second
    32  
    33  	DefaultKeepHashesDuration = 24 * 2 * time.Hour
    34  )
    35  
    36  // Config represents governance specific configuration.
    37  type Config struct {
    38  	// Level specifies the logging level of the Event Forwarder engine.
    39  	Level                                    encoding.LogLevel `long:"log-level"`
    40  	RetryRate                                encoding.Duration `long:"retry-rate"`
    41  	KeepHashesDurationForTestOnlyDoNotChange encoding.Duration
    42  	// a list of allowlisted blockchain queue public keys
    43  	BlockchainQueueAllowlist []string `description:" " long:"blockchain-queue-allowlist"`
    44  	// Ethereum groups the configuration related to Ethereum implementation of
    45  	// the Event Forwarder.
    46  	Ethereum   ethereum.Config   `group:"Ethereum"   namespace:"ethereum"`
    47  	EVMBridges []ethereum.Config `group:"EVMBridges" namespace:"evmbridges"`
    48  	EthCall    ethcall.Config    `group:"EthCall"    namespace:"ethcall"`
    49  }
    50  
    51  // NewDefaultConfig creates an instance of the package specific configuration.
    52  func NewDefaultConfig() Config {
    53  	return Config{
    54  		Level:     encoding.LogLevel{Level: logging.InfoLevel},
    55  		RetryRate: encoding.Duration{Duration: defaultRetryRate},
    56  		KeepHashesDurationForTestOnlyDoNotChange: encoding.Duration{
    57  			Duration: DefaultKeepHashesDuration,
    58  		},
    59  		BlockchainQueueAllowlist: []string{},
    60  		Ethereum:                 ethereum.NewDefaultConfig(),
    61  		EthCall:                  ethcall.NewDefaultConfig(),
    62  	}
    63  }