github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/network_version_info_query.go (about)

     1  package hedera
     2  
     3  /*-
     4   *
     5   * Hedera Go SDK
     6   *
     7   * Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
     8   *
     9   * Licensed under the Apache License, Version 2.0 (the "License");
    10   * you may not use this file except in compliance with the License.
    11   * You may obtain a copy of the License at
    12   *
    13   *      http://www.apache.org/licenses/LICENSE-2.0
    14   *
    15   * Unless required by applicable law or agreed to in writing, software
    16   * distributed under the License is distributed on an "AS IS" BASIS,
    17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    18   * See the License for the specific language governing permissions and
    19   * limitations under the License.
    20   *
    21   */
    22  
    23  import (
    24  	"time"
    25  
    26  	"github.com/hashgraph/hedera-protobufs-go/services"
    27  )
    28  
    29  // NetworkVersionInfoQuery is the query to be executed that would return the current version of the network's protobuf and services.
    30  type NetworkVersionInfoQuery struct {
    31  	Query
    32  }
    33  
    34  // NewNetworkVersionQuery creates a NetworkVersionInfoQuery builder which can be used to construct and execute a
    35  // Network Get Version Info Query containing the current version of the network's protobuf and services.
    36  func NewNetworkVersionQuery() *NetworkVersionInfoQuery {
    37  	header := services.QueryHeader{}
    38  	return &NetworkVersionInfoQuery{
    39  		Query: _NewQuery(true, &header),
    40  	}
    41  }
    42  
    43  // SetGrpcDeadline When execution is attempted, a single attempt will timeout when this deadline is reached. (The SDK may subsequently retry the execution.)
    44  func (q *NetworkVersionInfoQuery) SetGrpcDeadline(deadline *time.Duration) *NetworkVersionInfoQuery {
    45  	q.Query.SetGrpcDeadline(deadline)
    46  	return q
    47  }
    48  
    49  func (q *NetworkVersionInfoQuery) GetCost(client *Client) (Hbar, error) {
    50  	return q.Query.getCost(client, q)
    51  }
    52  
    53  // Execute executes the Query with the provided client
    54  func (q *NetworkVersionInfoQuery) Execute(client *Client) (NetworkVersionInfo, error) {
    55  	resp, err := q.Query.execute(client, q)
    56  
    57  	if err != nil {
    58  		return NetworkVersionInfo{}, err
    59  	}
    60  
    61  	return _NetworkVersionInfoFromProtobuf(resp.GetNetworkGetVersionInfo()), err
    62  }
    63  
    64  // SetMaxQueryPayment sets the maximum payment allowed for this Query.
    65  func (q *NetworkVersionInfoQuery) SetMaxQueryPayment(maxPayment Hbar) *NetworkVersionInfoQuery {
    66  	q.Query.SetMaxQueryPayment(maxPayment)
    67  	return q
    68  }
    69  
    70  // SetQueryPayment sets the payment amount for this Query.
    71  func (q *NetworkVersionInfoQuery) SetQueryPayment(paymentAmount Hbar) *NetworkVersionInfoQuery {
    72  	q.Query.SetQueryPayment(paymentAmount)
    73  	return q
    74  }
    75  
    76  // SetNodeAccountIDs sets the _Node AccountID for this NetworkVersionInfoQuery.
    77  func (q *NetworkVersionInfoQuery) SetNodeAccountIDs(accountID []AccountID) *NetworkVersionInfoQuery {
    78  	q.Query.SetNodeAccountIDs(accountID)
    79  	return q
    80  }
    81  
    82  // SetMaxRetry sets the max number of errors before execution will fail.
    83  func (q *NetworkVersionInfoQuery) SetMaxRetry(count int) *NetworkVersionInfoQuery {
    84  	q.Query.SetMaxRetry(count)
    85  	return q
    86  }
    87  
    88  // SetMaxBackoff The maximum amount of time to wait between retries.
    89  // Every retry attempt will increase the wait time exponentially until it reaches this time.
    90  func (q *NetworkVersionInfoQuery) SetMaxBackoff(max time.Duration) *NetworkVersionInfoQuery {
    91  	q.Query.SetMaxBackoff(max)
    92  	return q
    93  }
    94  
    95  // SetMinBackoff sets the minimum amount of time to wait between retries.
    96  func (q *NetworkVersionInfoQuery) SetMinBackoff(min time.Duration) *NetworkVersionInfoQuery {
    97  	q.Query.SetMinBackoff(min)
    98  	return q
    99  }
   100  
   101  // SetPaymentTransactionID assigns the payment transaction id.
   102  func (q *NetworkVersionInfoQuery) SetPaymentTransactionID(transactionID TransactionID) *NetworkVersionInfoQuery {
   103  	q.Query.SetPaymentTransactionID(transactionID)
   104  	return q
   105  }
   106  
   107  func (q *NetworkVersionInfoQuery) SetLogLevel(level LogLevel) *NetworkVersionInfoQuery {
   108  	q.Query.SetLogLevel(level)
   109  	return q
   110  }
   111  
   112  // ---------- Parent functions specific implementation ----------
   113  
   114  func (q *NetworkVersionInfoQuery) getMethod(channel *_Channel) _Method {
   115  	return _Method{
   116  		query: channel._GetNetwork().GetVersionInfo,
   117  	}
   118  }
   119  
   120  func (q *NetworkVersionInfoQuery) getName() string {
   121  	return "NetworkVersionInfoQuery"
   122  }
   123  
   124  func (q *NetworkVersionInfoQuery) buildQuery() *services.Query {
   125  	pb := services.Query_NetworkGetVersionInfo{
   126  		NetworkGetVersionInfo: &services.NetworkGetVersionInfoQuery{
   127  			Header: q.pbHeader,
   128  		},
   129  	}
   130  
   131  	return &services.Query{
   132  		Query: &pb,
   133  	}
   134  }
   135  
   136  func (q *NetworkVersionInfoQuery) validateNetworkOnIDs(*Client) error {
   137  	return nil
   138  }
   139  
   140  func (q *NetworkVersionInfoQuery) getQueryResponse(response *services.Response) queryResponse {
   141  	return response.GetNetworkGetVersionInfo()
   142  }