@@ -34,24 +34,24 @@ type Server struct {
3434 listenAddrHTTP string
3535 qPool * qubic.Pool
3636 maxTickFetchUrl string
37- readRetryCount int
37+ ReadMaxRetries int
3838}
3939
40- func NewServer (listenAddrGRPC , listenAddrHTTP string , logger * log.Logger , qPool * qubic.Pool , maxTickFetchUrl string , readRetryCount int ) * Server {
40+ func NewServer (listenAddrGRPC , listenAddrHTTP string , logger * log.Logger , qPool * qubic.Pool , maxTickFetchUrl string , readMaxRetries int ) * Server {
4141 return & Server {
4242 listenAddrGRPC : listenAddrGRPC ,
4343 listenAddrHTTP : listenAddrHTTP ,
4444 logger : logger ,
4545 qPool : qPool ,
4646 maxTickFetchUrl : maxTickFetchUrl ,
47- readRetryCount : readRetryCount ,
47+ ReadMaxRetries : readMaxRetries ,
4848 }
4949}
5050
5151func (s * Server ) GetBalance (ctx context.Context , req * protobuff.GetBalanceRequest ) (* protobuff.GetBalanceResponse , error ) {
5252
5353 var identityInfo types.AddressInfo
54- err := WithRetry (ctx , s .qPool , s .readRetryCount , func (ctx context.Context , client * qubic.Client ) error {
54+ err := WithRetry (ctx , s .qPool , s .ReadMaxRetries , func (ctx context.Context , client * qubic.Client ) error {
5555 res , err := client .GetIdentity (ctx , req .Id )
5656 if err != nil {
5757 return errors .Wrap (err , "getting identity info from node" )
@@ -81,7 +81,7 @@ func (s *Server) GetBalance(ctx context.Context, req *protobuff.GetBalanceReques
8181func (s * Server ) GetTickInfo (ctx context.Context , _ * emptypb.Empty ) (* protobuff.GetTickInfoResponse , error ) {
8282
8383 var tickInfo types.TickInfo
84- err := WithRetry (ctx , s .qPool , s .readRetryCount , func (ctx context.Context , client * qubic.Client ) error {
84+ err := WithRetry (ctx , s .qPool , s .ReadMaxRetries , func (ctx context.Context , client * qubic.Client ) error {
8585 res , err := client .GetTickInfo (ctx )
8686 if err != nil {
8787 return errors .Wrap (err , "getting tick info from node" )
@@ -105,7 +105,7 @@ func (s *Server) GetTickInfo(ctx context.Context, _ *emptypb.Empty) (*protobuff.
105105func (s * Server ) GetBlockHeight (ctx context.Context , _ * emptypb.Empty ) (* protobuff.GetBlockHeightResponse , error ) {
106106
107107 var tickInfo types.TickInfo
108- err := WithRetry (ctx , s .qPool , s .readRetryCount , func (ctx context.Context , client * qubic.Client ) error {
108+ err := WithRetry (ctx , s .qPool , s .ReadMaxRetries , func (ctx context.Context , client * qubic.Client ) error {
109109 res , err := client .GetTickInfo (ctx )
110110 if err != nil {
111111 return errors .Wrap (err , "getting tick info from node" )
@@ -134,7 +134,7 @@ func (s *Server) QuerySmartContract(ctx context.Context, req *protobuff.QuerySma
134134
135135 var scData types.SmartContractData
136136
137- err = WithRetry (ctx , s .qPool , s .readRetryCount , func (ctx context.Context , client * qubic.Client ) error {
137+ err = WithRetry (ctx , s .qPool , s .ReadMaxRetries , func (ctx context.Context , client * qubic.Client ) error {
138138 res , err := client .QuerySmartContract (ctx , qubic.RequestContractFunction {
139139 ContractIndex : req .ContractIndex ,
140140 InputType : uint16 (req .InputType ),
@@ -157,7 +157,7 @@ func (s *Server) QuerySmartContract(ctx context.Context, req *protobuff.QuerySma
157157func (s * Server ) GetIssuedAssets (ctx context.Context , req * protobuff.IssuedAssetsRequest ) (* protobuff.IssuedAssetsResponse , error ) {
158158
159159 var assets types.IssuedAssets
160- err := WithRetry (ctx , s .qPool , s .readRetryCount , func (ctx context.Context , client * qubic.Client ) error {
160+ err := WithRetry (ctx , s .qPool , s .ReadMaxRetries , func (ctx context.Context , client * qubic.Client ) error {
161161 res , err := client .GetIssuedAssets (ctx , req .Identity )
162162 if err != nil {
163163 return errors .Wrap (err , "getting issued assets from node" )
@@ -208,7 +208,7 @@ func (s *Server) GetIssuedAssets(ctx context.Context, req *protobuff.IssuedAsset
208208func (s * Server ) GetOwnedAssets (ctx context.Context , req * protobuff.OwnedAssetsRequest ) (* protobuff.OwnedAssetsResponse , error ) {
209209
210210 var assets types.OwnedAssets
211- err := WithRetry (ctx , s .qPool , s .readRetryCount , func (ctx context.Context , client * qubic.Client ) error {
211+ err := WithRetry (ctx , s .qPool , s .ReadMaxRetries , func (ctx context.Context , client * qubic.Client ) error {
212212 res , err := client .GetOwnedAssets (ctx , req .Identity )
213213 if err != nil {
214214 return errors .Wrap (err , "getting owned assets from node" )
@@ -277,7 +277,7 @@ func (s *Server) GetOwnedAssets(ctx context.Context, req *protobuff.OwnedAssetsR
277277func (s * Server ) GetPossessedAssets (ctx context.Context , req * protobuff.PossessedAssetsRequest ) (* protobuff.PossessedAssetsResponse , error ) {
278278
279279 var assets types.PossessedAssets
280- err := WithRetry (ctx , s .qPool , s .readRetryCount , func (ctx context.Context , client * qubic.Client ) error {
280+ err := WithRetry (ctx , s .qPool , s .ReadMaxRetries , func (ctx context.Context , client * qubic.Client ) error {
281281 res , err := client .GetPossessedAssets (ctx , req .Identity )
282282 if err != nil {
283283 return errors .Wrap (err , "getting possessed assets from node" )
@@ -428,7 +428,7 @@ type RetryableCall func(ctx context.Context, client *qubic.Client) error
428428func WithRetry (ctx context.Context , pool * qubic.Pool , maxRetries int , call RetryableCall ) error {
429429 var lastErr error
430430
431- for attempt := 0 ; attempt <= maxRetries ; attempt ++ {
431+ for attempt := 0 ; attempt < maxRetries ; attempt ++ {
432432 client , err := pool .Get ()
433433 if err != nil {
434434 lastErr = status .Errorf (codes .Internal , "failed to get client from pool: %v" , err )
0 commit comments