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.
此方法不需要任何参数。
在 epoch 开始之前用于计算该 epoch 领导者计划的 slot 数
第一个正常长度的 epoch,log2(slotsPerEpoch) - log2(MINIMUM_SLOTS_PER_EPOCH)
MINIMUM_SLOTS_PER_EPOCH * (2.pow(firstNormalEpoch) - 1)
代码示例
基本请求
curl http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getEpochSchedule"
}'
使用 web3.js
import { Connection } from '@solana/web3.js';
const connection = new Connection('http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
const epochSchedule = await connection.getEpochSchedule();
console.log(epochSchedule);
使用 Python
from solana.rpc.api import Client
client = Client("http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY")
response = client.get_epoch_schedule()
print(response)
注意事项
- 返回集群创世配置中的 epoch 计划信息
- 返回的数据是静态的,对于给定的网络/集群不会改变
- 对于计算 epoch 边界和领导者计划时间非常有用
- warmup 参数指示 epoch 是否从短周期开始并增长到完整大小
最佳实践
- 在本地缓存此信息,因为它不会改变
- 使用返回的值计算 epoch 过渡
- 使用 firstNormalEpoch 和 firstNormalSlot 进行 epoch 时间计算
- 适当处理网络错误并重试