> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getClusterNodes

> 返回参与集群的所有节点的信息

## 参数

此方法不接受任何参数。

## 响应

<ResponseField name="result" type="array">
  包含节点信息的对象数组：

  <Expandable title="result fields">
    <ResponseField name="pubkey" type="string">
      节点公钥（base-58）
    </ResponseField>

    <ResponseField name="gossip" type="string | null">
      节点的 Gossip 网络地址
    </ResponseField>

    <ResponseField name="tpu" type="string | null">
      节点的 TPU 网络地址
    </ResponseField>

    <ResponseField name="rpc" type="string | null">
      节点的 JSON RPC 网络地址
    </ResponseField>

    <ResponseField name="version" type="string | null">
      节点的软件版本
    </ResponseField>

    <ResponseField name="featureSet" type="number | null">
      节点功能集的唯一标识符
    </ResponseField>

    <ResponseField name="shredVersion" type="number | null">
      节点配置使用的 shred 版本
    </ResponseField>
  </Expandable>
</ResponseField>

## 代码示例

### 基本请求

```bash theme={null}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getClusterNodes"
}'
```

### 使用 web3.js

```typescript theme={null}
import { Connection } from '@solana/web3.js';

const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');

const nodes = await connection.getClusterNodes();
console.log('Cluster nodes:', nodes);

// Example: Find all nodes running a specific version
const version = '1.16.0';
const nodesWithVersion = nodes.filter(node => node.version === version);
console.log(`Nodes running version ${version}:`, nodesWithVersion);

// Example: Get all RPC endpoints
const rpcEndpoints = nodes
  .filter(node => node.rpc)
  .map(node => node.rpc);
console.log('Available RPC endpoints:', rpcEndpoints);
```

## 注意事项

1. 某些字段如果信息不可用可能为 `null`
2. 节点信息通过 gossip 网络获取
3. 列表包含所有已知节点，无论它们当前是否活跃
4. 网络地址采用标准 socket 格式（IP:端口）

## 最佳实践

1. 缓存结果以减少 RPC 负载（每隔几分钟刷新一次）
2. 使用版本信息检测网络升级
3. 处理网络地址时过滤 null 值
4. 选择 RPC 端点时考虑节点版本
5. 使用 TPU 地址优化交易转发

## 常见错误

| 错误码    | 消息                           | 解决方案                     |
| ------ | ---------------------------- | ------------------------ |
| -32601 | Method not found             | 验证是否连接到 Solana RPC 节点    |
| -32007 | Node information unavailable | 节点可能正在启动或 gossip 服务可能已停止 |
| -32008 | Node list too large          | 稍后网络条件改善时重试              |

## 用例

1. **负载均衡**
   * 发现可用的 RPC 端点
   * 分配客户端连接

2. **网络健康监控**
   * 跟踪节点版本
   * 监控网络分布
   * 识别网络分区

3. **交易优化**
   * 查找最近的 TPU 地址
   * 实现领导者感知的交易转发

4. **版本管理**
   * 跟踪网络升级
   * 确保客户端兼容性
   * 规划维护窗口
