github.com/gagliardetto/solana-go@v1.11.0/rpc/getHealth.go (about)

     1  // Copyright 2021 github.com/gagliardetto
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package rpc
    16  
    17  import (
    18  	"context"
    19  )
    20  
    21  // GetHealth returns the current health of the node.
    22  // If one or more --trusted-validator arguments are provided
    23  // to solana-validator, "ok" is returned when the node has within
    24  // HEALTH_CHECK_SLOT_DISTANCE slots of the highest trusted validator,
    25  // otherwise an error is returned. "ok" is always returned if no
    26  // trusted validators are provided.
    27  //
    28  // - If the node is healthy: "ok"
    29  // - If the node is unhealthy, a JSON RPC error response is returned.
    30  //   The specifics of the error response are UNSTABLE and may change in the future.
    31  func (cl *Client) GetHealth(ctx context.Context) (out string, err error) {
    32  	err = cl.rpcClient.CallForInto(ctx, &out, "getHealth", nil)
    33  	return
    34  }
    35  
    36  const HealthOk = "ok"