Skip to content

Commit

Permalink
renamings and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
axenteoctavian committed Nov 1, 2024
1 parent d4ac5ee commit d935290
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
8 changes: 4 additions & 4 deletions server/cmd/server/.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ WALLET_PATH="wallet.pem"
WALLET_PASSWORD=""
# MultiversX proxy (e.g.: https://testnet-gateway.multiversx.com)
MULTIVERSX_PROXY="https://testnet-gateway.multiversx.com"
# Multi Sig address on MultiversX to register the transactions
MULTI_SIG_SC_ADDRESS="erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"
# Header verifier address on MultiversX to register the transactions
HEADER_VERIFIER_SC_ADDRESS="erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"
# ESDT Safe address on MultiversX to execute the transactions
ESDT_SAFE_SC_ADDRESS="erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"
# Max retries to wait in seconds for account nonce update after sending bridge txs
MAX_RETRIES_SECONDS_WAIT_NONCE=60
# Interval in milliseconds between sending bridge txs
INTERVAL_TO_SEND=60
# Server certificate for tls secured connection with clients.
# One should use the same certificate for clients as well.
# You can generate your own certificate files with the binary found in
Expand Down
40 changes: 20 additions & 20 deletions server/cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ const (
)

const (
envGRPCPort = "GRPC_PORT"
envWallet = "WALLET_PATH"
envPassword = "WALLET_PASSWORD"
envMultiSigSCAddr = "MULTI_SIG_SC_ADDRESS"
envEsdtSafeSCAddr = "ESDT_SAFE_SC_ADDRESS"
envMultiversXProxy = "MULTIVERSX_PROXY"
envMaxRetriesWaitNonce = "MAX_RETRIES_SECONDS_WAIT_NONCE"
envCertFile = "CERT_FILE"
envCertPkFile = "CERT_PK_FILE"
envHasher = "HASHER"
envGRPCPort = "GRPC_PORT"
envWallet = "WALLET_PATH"
envPassword = "WALLET_PASSWORD"
envHeaderVerifierSCAddr = "HEADER_VERIFIER_SC_ADDRESS"
envEsdtSafeSCAddr = "ESDT_SAFE_SC_ADDRESS"
envMultiversXProxy = "MULTIVERSX_PROXY"
envIntervalToSend = "INTERVAL_TO_SEND"
envCertFile = "CERT_FILE"
envCertPkFile = "CERT_PK_FILE"
envHasher = "HASHER"
)

func main() {
Expand Down Expand Up @@ -142,24 +142,24 @@ func loadConfig() (*config.ServerConfig, error) {
grpcPort := os.Getenv(envGRPCPort)
walletPath := os.Getenv(envWallet)
walletPassword := os.Getenv(envPassword)
multiSigSCAddress := os.Getenv(envMultiSigSCAddr)
headerVerifierSCAddress := os.Getenv(envHeaderVerifierSCAddr)
esdtSafeSCAddress := os.Getenv(envEsdtSafeSCAddr)
proxy := os.Getenv(envMultiversXProxy)
maxRetriesWaitNonceStr := os.Getenv(envMaxRetriesWaitNonce)
intervalToSendStr := os.Getenv(envIntervalToSend)
certFile := os.Getenv(envCertFile)
certPkFile := os.Getenv(envCertPkFile)
hasher := os.Getenv(envHasher)

maxRetriesWaitNonce, err := strconv.Atoi(maxRetriesWaitNonceStr)
intervalToSend, err := strconv.Atoi(intervalToSendStr)
if err != nil {
return nil, err
}

log.Info("loaded config", "grpc port", grpcPort)
log.Info("loaded config", "multiSigSCAddress", multiSigSCAddress)
log.Info("loaded config", "headerVerifierSCAddress", headerVerifierSCAddress)
log.Info("loaded config", "esdtSafeSCAddress", esdtSafeSCAddress)
log.Info("loaded config", "proxy", proxy)
log.Info("loaded config", "maxRetriesWaitNonce", maxRetriesWaitNonce)
log.Info("loaded config", "intervalToSend", intervalToSend)
log.Info("loaded config", "hasher", hasher)

log.Info("loaded config", "certificate file", certFile)
Expand All @@ -172,11 +172,11 @@ func loadConfig() (*config.ServerConfig, error) {
Password: walletPassword,
},
TxSenderConfig: txSender.TxSenderConfig{
MultisigSCAddress: multiSigSCAddress,
EsdtSafeSCAddress: esdtSafeSCAddress,
Proxy: proxy,
MaxRetriesSecondsWaitNonce: maxRetriesWaitNonce,
Hasher: hasher,
HeaderVerifierSCAddress: headerVerifierSCAddress,
EsdtSafeSCAddress: esdtSafeSCAddress,
Proxy: proxy,
IntervalToSend: intervalToSend,
Hasher: hasher,
},
CertificateConfig: cert.FileCfg{
CertFile: certFile,
Expand Down
10 changes: 5 additions & 5 deletions server/txSender/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ type WalletConfig struct {

// TxSenderConfig holds tx sender config
type TxSenderConfig struct {
MultisigSCAddress string
EsdtSafeSCAddress string
Proxy string
MaxRetriesSecondsWaitNonce int
Hasher string
HeaderVerifierSCAddress string
EsdtSafeSCAddress string
Proxy string
IntervalToSend int
Hasher string
}
4 changes: 2 additions & 2 deletions server/txSender/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func CreateTxSender(wallet core.CryptoComponentsHolder, cfg TxSenderConfig) (*tx

nonceHandler, err := nonceHandlerV3.NewNonceTransactionHandlerV3(nonceHandlerV3.ArgsNonceTransactionsHandlerV3{
Proxy: proxy,
IntervalToSend: time.Second * time.Duration(cfg.MaxRetriesSecondsWaitNonce),
IntervalToSend: time.Millisecond * time.Duration(cfg.IntervalToSend),
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -62,7 +62,7 @@ func CreateTxSender(wallet core.CryptoComponentsHolder, cfg TxSenderConfig) (*tx
TxInteractor: ti,
TxNonceHandler: nonceHandler,
DataFormatter: dtaFormatter,
SCMultiSigAddress: cfg.MultisigSCAddress,
SCMultiSigAddress: cfg.HeaderVerifierSCAddress,
SCEsdtSafeAddress: cfg.EsdtSafeSCAddress,
})
}

0 comments on commit d935290

Please sign in to comment.