github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/config/flags_transactor.go (about)

     1  /*
     2   * Copyright (C) 2019 The "MysteriumNetwork/node" Authors.
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License as published by
     6   * the Free Software Foundation, either version 3 of the License, or
     7   * (at your option) any later version.
     8   *
     9   * This program is distributed in the hope that it will be useful,
    10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12   * GNU General Public License for more details.
    13   *
    14   * You should have received a copy of the GNU General Public License
    15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16   */
    17  
    18  package config
    19  
    20  import (
    21  	"time"
    22  
    23  	"github.com/mysteriumnetwork/node/metadata"
    24  	"github.com/urfave/cli/v2"
    25  )
    26  
    27  var (
    28  	// FlagTransactorAddress transactor URL.
    29  	FlagTransactorAddress = cli.StringFlag{
    30  		Name:  metadata.FlagNames.TransactorAddress,
    31  		Usage: "Transactor URL address",
    32  		Value: metadata.DefaultNetwork.TransactorAddress,
    33  	}
    34  	// FlagTransactorProviderMaxRegistrationAttempts determines the number of registration attempts that the provider will attempt before giving up.
    35  	FlagTransactorProviderMaxRegistrationAttempts = cli.IntFlag{
    36  		Name:  "transactor.provider.max-registration-attempts",
    37  		Usage: "the max attempts the provider will make to register before giving up",
    38  		Value: 10,
    39  	}
    40  	// FlagTransactorFeesValidTime The duration we will consider transactor fees valid for.
    41  	FlagTransactorFeesValidTime = cli.DurationFlag{
    42  		Name:   "payments.transactor.fees-valid-time",
    43  		Value:  30 * time.Second,
    44  		Usage:  "The duration we will consider transactor fees valid for (more than 5 minutes is likely to fail)",
    45  		Hidden: true,
    46  	}
    47  	// FlagProviderTryFreeRegistration if set to true, the provider will try to register for free.
    48  	FlagProviderTryFreeRegistration = cli.BoolFlag{
    49  		Name:  "transactor.provider.try-free-registration",
    50  		Usage: "if set to true, the provider will try to register for free. ",
    51  		Value: false,
    52  	}
    53  )
    54  
    55  // RegisterFlagsTransactor function register network flags to flag list
    56  func RegisterFlagsTransactor(flags *[]cli.Flag) {
    57  	*flags = append(
    58  		*flags,
    59  		&FlagTransactorAddress,
    60  		&FlagTransactorProviderMaxRegistrationAttempts,
    61  		&FlagTransactorFeesValidTime,
    62  		&FlagProviderTryFreeRegistration,
    63  	)
    64  }
    65  
    66  // ParseFlagsTransactor function fills in transactor options from CLI context
    67  func ParseFlagsTransactor(ctx *cli.Context) {
    68  	Current.ParseStringFlag(ctx, FlagTransactorAddress)
    69  	Current.ParseIntFlag(ctx, FlagTransactorProviderMaxRegistrationAttempts)
    70  	Current.ParseDurationFlag(ctx, FlagTransactorFeesValidTime)
    71  	Current.ParseBoolFlag(ctx, FlagProviderTryFreeRegistration)
    72  }